@gearbox-protocol/permissionless-ui 1.22.0-next.81 → 1.22.0-next.82

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 o=require("react/jsx-runtime"),H=require("@radix-ui/react-tooltip"),I=require("react");require("@gearbox-protocol/sdk");const m=require("../../utils/cn.cjs");require("sonner");require("luxon");function T(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const c in r)if(c!=="default"){const e=Object.getOwnPropertyDescriptor(r,c);Object.defineProperty(a,c,e.get?e:{enumerable:!0,get:()=>r[c]})}}return a.default=r,Object.freeze(a)}const l=T(H),i=T(I),O=7,K=12;function D({children:r,title:a,placement:c="top",trigger:e="hover",triangle:R=!0,delayShow:k=5,maxWidth:C="200px",minWidth:P,type:E="tooltip",open:b,onOpenChange:h,className:_,triggerClassName:y}){const[q,S]=i.useState(!1),d=i.useRef(null),u=i.useRef(null),p=b!==void 0,s=p?b:q,n=i.useCallback(t=>{p?h?.(t):S(t)},[p,h]),N=i.useCallback(t=>{e!=="click"&&n(t)},[e,n]),g=i.useCallback(t=>{e==="click"&&(t.stopPropagation(),n(!s))},[e,s,n]),A=i.useCallback(t=>{e==="click"&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),n(!s))},[e,s,n]);i.useEffect(()=>{if(e!=="click"||!s)return;const t=f=>{const w=f.target;d.current&&!d.current.contains(w)&&u.current&&!u.current.contains(w)&&n(!1)},v=f=>{f.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",t),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",t),document.removeEventListener("keydown",v)}},[e,s,n]);const x=E==="modal-tooltip",j=R&&!x,L=m.cn("z-50 pointer-events-auto","animate-in fade-in-0 duration-100","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-75",x?"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",_);return o.jsx(l.Provider,{delayDuration:e==="click"?0:k,skipDelayDuration:0,children:o.jsxs(l.Root,{open:s,onOpenChange:N,delayDuration:e==="click"?0:k,children:[o.jsx(l.Trigger,{asChild:!0,children:e==="click"?o.jsx("button",{ref:u,type:"button",onClick:g,onKeyDown:A,className:m.cn("inline-flex appearance-none border-0 bg-transparent p-0 text-inherit font-inherit cursor-pointer",y),children:a}):o.jsx("span",{ref:u,className:m.cn("inline-flex",y),children:a})}),o.jsx(l.Portal,{children:o.jsxs(l.Content,{ref:d,side:c,sideOffset:j?O-4:8,className:L,style:{maxWidth:C,minWidth:P},children:[r,j&&o.jsx(l.Arrow,{width:K,height:O,className:"fill-black/85"})]})})]})})}D.displayName="SimpleTooltip";exports.SimpleTooltip=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),I=require("@radix-ui/react-tooltip"),K=require("react");require("@gearbox-protocol/sdk");const m=require("../../utils/cn.cjs");require("sonner");require("luxon");function T(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const c in s)if(c!=="default"){const e=Object.getOwnPropertyDescriptor(s,c);Object.defineProperty(a,c,e.get?e:{enumerable:!0,get:()=>s[c]})}}return a.default=s,Object.freeze(a)}const l=T(I),i=T(K),O=7,M=12;function D({children:s,title:a,placement:c="top",trigger:e="hover",triangle:R=!0,delayShow:k=5,maxWidth:C="200px",minWidth:P,type:E="tooltip",open:b,onOpenChange:h,className:_,triggerClassName:y,useTitleAsTrigger:q=!1}){const[S,N]=i.useState(!1),d=i.useRef(null),u=i.useRef(null),p=b!==void 0,r=p?b:S,t=i.useCallback(n=>{p?h?.(n):N(n)},[p,h]),g=i.useCallback(n=>{e!=="click"&&t(n)},[e,t]),A=i.useCallback(n=>{e==="click"&&(n.stopPropagation(),t(!r))},[e,r,t]),L=i.useCallback(n=>{e==="click"&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),t(!r))},[e,r,t]);i.useEffect(()=>{if(e!=="click"||!r)return;const n=f=>{const w=f.target;d.current&&!d.current.contains(w)&&u.current&&!u.current.contains(w)&&t(!1)},v=f=>{f.key==="Escape"&&t(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",v)}},[e,r,t]);const x=E==="modal-tooltip",j=R&&!x,H=m.cn("z-50 pointer-events-auto","animate-in fade-in-0 duration-100","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:duration-75",x?"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",_);return o.jsx(l.Provider,{delayDuration:e==="click"?0:k,skipDelayDuration:0,children:o.jsxs(l.Root,{open:r,onOpenChange:g,delayDuration:e==="click"?0:k,children:[o.jsx(l.Trigger,{asChild:!0,children:q?a:e==="click"?o.jsx("button",{ref:u,type:"button",onClick:A,onKeyDown:L,className:m.cn("inline-flex appearance-none border-0 bg-transparent p-0 text-inherit font-inherit cursor-pointer",y),children:a}):o.jsx("span",{ref:u,className:m.cn("inline-flex",y),children:a})}),o.jsx(l.Portal,{children:o.jsxs(l.Content,{ref:d,side:c,sideOffset:j?O-4:8,className:H,style:{maxWidth:C,minWidth:P},children:[s,j&&o.jsx(l.Arrow,{width:M,height:O,className:"fill-black/85"})]})})]})})}D.displayName="SimpleTooltip";exports.SimpleTooltip=D;
@@ -1,14 +1,14 @@
1
1
  import { jsx as i, jsxs as x } from "react/jsx-runtime";
2
- import * as r from "@radix-ui/react-tooltip";
2
+ import * as s from "@radix-ui/react-tooltip";
3
3
  import * as o from "react";
4
4
  import "@gearbox-protocol/sdk";
5
- import { cn as d } from "../../utils/cn.js";
5
+ import { cn as u } from "../../utils/cn.js";
6
6
  import "sonner";
7
7
  import "luxon";
8
- const C = 7, j = 12;
9
- function S({
8
+ const C = 7, S = 12;
9
+ function _({
10
10
  children: D,
11
- title: u,
11
+ title: c,
12
12
  placement: R = "top",
13
13
  trigger: n = "hover",
14
14
  triangle: T = !0,
@@ -19,24 +19,25 @@ function S({
19
19
  open: m,
20
20
  onOpenChange: k,
21
21
  className: A,
22
- triggerClassName: h
22
+ triggerClassName: h,
23
+ useTitleAsTrigger: L = !1
23
24
  }) {
24
- const [L, N] = o.useState(!1), c = o.useRef(null), s = o.useRef(null), l = m !== void 0, a = l ? m : L, t = o.useCallback(
25
+ const [N, H] = o.useState(!1), l = o.useRef(null), r = o.useRef(null), p = m !== void 0, a = p ? m : N, t = o.useCallback(
25
26
  (e) => {
26
- l ? k?.(e) : N(e);
27
+ p ? k?.(e) : H(e);
27
28
  },
28
- [l, k]
29
- ), H = o.useCallback(
29
+ [p, k]
30
+ ), I = o.useCallback(
30
31
  (e) => {
31
32
  n !== "click" && t(e);
32
33
  },
33
34
  [n, t]
34
- ), I = o.useCallback(
35
+ ), K = o.useCallback(
35
36
  (e) => {
36
37
  n === "click" && (e.stopPropagation(), t(!a));
37
38
  },
38
39
  [n, a, t]
39
- ), K = o.useCallback(
40
+ ), W = o.useCallback(
40
41
  (e) => {
41
42
  n === "click" && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), t(!a));
42
43
  },
@@ -44,17 +45,17 @@ function S({
44
45
  );
45
46
  o.useEffect(() => {
46
47
  if (n !== "click" || !a) return;
47
- const e = (p) => {
48
- const v = p.target;
49
- c.current && !c.current.contains(v) && s.current && !s.current.contains(v) && t(!1);
50
- }, w = (p) => {
51
- p.key === "Escape" && t(!1);
48
+ const e = (d) => {
49
+ const v = d.target;
50
+ l.current && !l.current.contains(v) && r.current && !r.current.contains(v) && t(!1);
51
+ }, w = (d) => {
52
+ d.key === "Escape" && t(!1);
52
53
  };
53
54
  return document.addEventListener("pointerdown", e), document.addEventListener("keydown", w), () => {
54
55
  document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", w);
55
56
  };
56
57
  }, [n, a, t]);
57
- const y = P === "modal-tooltip", b = T && !y, W = d(
58
+ const y = P === "modal-tooltip", b = T && !y, j = u(
58
59
  // Base
59
60
  "z-50 pointer-events-auto",
60
61
  "animate-in fade-in-0 duration-100",
@@ -64,52 +65,52 @@ function S({
64
65
  A
65
66
  );
66
67
  return /* @__PURE__ */ i(
67
- r.Provider,
68
+ s.Provider,
68
69
  {
69
70
  delayDuration: n === "click" ? 0 : f,
70
71
  skipDelayDuration: 0,
71
72
  children: /* @__PURE__ */ x(
72
- r.Root,
73
+ s.Root,
73
74
  {
74
75
  open: a,
75
- onOpenChange: H,
76
+ onOpenChange: I,
76
77
  delayDuration: n === "click" ? 0 : f,
77
78
  children: [
78
- /* @__PURE__ */ i(r.Trigger, { asChild: !0, children: n === "click" ? /* @__PURE__ */ i(
79
+ /* @__PURE__ */ i(s.Trigger, { asChild: !0, children: L ? c : n === "click" ? /* @__PURE__ */ i(
79
80
  "button",
80
81
  {
81
- ref: s,
82
+ ref: r,
82
83
  type: "button",
83
- onClick: I,
84
- onKeyDown: K,
85
- className: d(
84
+ onClick: K,
85
+ onKeyDown: W,
86
+ className: u(
86
87
  "inline-flex appearance-none border-0 bg-transparent p-0 text-inherit font-inherit cursor-pointer",
87
88
  h
88
89
  ),
89
- children: u
90
+ children: c
90
91
  }
91
92
  ) : /* @__PURE__ */ i(
92
93
  "span",
93
94
  {
94
- ref: s,
95
- className: d("inline-flex", h),
96
- children: u
95
+ ref: r,
96
+ className: u("inline-flex", h),
97
+ children: c
97
98
  }
98
99
  ) }),
99
- /* @__PURE__ */ i(r.Portal, { children: /* @__PURE__ */ x(
100
- r.Content,
100
+ /* @__PURE__ */ i(s.Portal, { children: /* @__PURE__ */ x(
101
+ s.Content,
101
102
  {
102
- ref: c,
103
+ ref: l,
103
104
  side: R,
104
105
  sideOffset: b ? C - 4 : 8,
105
- className: W,
106
+ className: j,
106
107
  style: { maxWidth: E, minWidth: O },
107
108
  children: [
108
109
  D,
109
110
  b && /* @__PURE__ */ i(
110
- r.Arrow,
111
+ s.Arrow,
111
112
  {
112
- width: j,
113
+ width: S,
113
114
  height: C,
114
115
  className: "fill-black/85"
115
116
  }
@@ -123,7 +124,7 @@ function S({
123
124
  }
124
125
  );
125
126
  }
126
- S.displayName = "SimpleTooltip";
127
+ _.displayName = "SimpleTooltip";
127
128
  export {
128
- S as SimpleTooltip
129
+ _ as SimpleTooltip
129
130
  };
@@ -42,6 +42,8 @@ export interface SimpleTooltipProps {
42
42
  className?: string;
43
43
  /** Extra className applied to the trigger wrapper `<span>`. */
44
44
  triggerClassName?: string;
45
+ /** Whether to use the title as the trigger element. */
46
+ useTitleAsTrigger?: boolean;
45
47
  }
46
48
  /**
47
49
  * `SimpleTooltip` — a drop-in replacement for the legacy
@@ -78,7 +80,7 @@ export interface SimpleTooltipProps {
78
80
  * </SimpleTooltip>
79
81
  * ```
80
82
  */
81
- export declare function SimpleTooltip({ children, title, placement, trigger, triangle, delayShow, maxWidth, minWidth, type, open: controlledOpen, onOpenChange: controlledOnOpenChange, className, triggerClassName, }: SimpleTooltipProps): import("react/jsx-runtime").JSX.Element;
83
+ export declare function SimpleTooltip({ children, title, placement, trigger, triangle, delayShow, maxWidth, minWidth, type, open: controlledOpen, onOpenChange: controlledOnOpenChange, className, triggerClassName, useTitleAsTrigger, }: SimpleTooltipProps): import("react/jsx-runtime").JSX.Element;
82
84
  export declare namespace SimpleTooltip {
83
85
  var displayName: string;
84
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/permissionless-ui",
3
- "version": "1.22.0-next.81",
3
+ "version": "1.22.0-next.82",
4
4
  "description": "Internal UI components",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",