@elcrm/tooltip 0.1.1 → 0.1.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.
- package/README.md +8 -6
- package/dist/index.css +1 -1
- package/dist/index.es.js +136 -122
- package/dist/index.umd.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -75,12 +75,14 @@ import {
|
|
|
75
75
|
| ----------------------- | ----------------- |
|
|
76
76
|
| `--tooltip-bg` | Фон |
|
|
77
77
|
| `--tooltip-fg` | Цвет текста |
|
|
78
|
-
| `--tooltip-radius`
|
|
79
|
-
| `--tooltip-max-width`
|
|
80
|
-
| `--tooltip-font-size`
|
|
81
|
-
| `--tooltip-padding`
|
|
82
|
-
| `--tooltip-
|
|
83
|
-
| `--tooltip-
|
|
78
|
+
| `--tooltip-radius` | Скругление (по умолчанию `8px`) |
|
|
79
|
+
| `--tooltip-max-width` | Макс. ширина |
|
|
80
|
+
| `--tooltip-font-size` | Размер шрифта |
|
|
81
|
+
| `--tooltip-padding-block` | Вертикальный padding |
|
|
82
|
+
| `--tooltip-padding-inline` | Горизонтальный padding |
|
|
83
|
+
| `--tooltip-padding` | Shorthand padding |
|
|
84
|
+
| `--tooltip-shadow` | Тень |
|
|
85
|
+
| `--tooltip-gap` | Зазор до якоря |
|
|
84
86
|
|
|
85
87
|
## Поведение
|
|
86
88
|
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer elcrm-tooltip{.ttr{display:inline-flex;vertical-align:middle;max-width:100%}.ttt{position:fixed;box-sizing:border-box;max-width:var(--tooltip-max-width);padding:var(--tooltip-padding);border-radius:var(--tooltip-radius);background:var(--tooltip-bg);color:var(--tooltip-fg);font-size:var(--tooltip-font-size);line-height:1.35;font-weight:500;box-shadow:var(--tooltip-shadow);pointer-events:none;opacity:0;transition:opacity .12s ease;white-space:normal;word-break:break-word}.ttv{opacity:1}.ttl{text-align:left}.ttm{text-align:center}.ttx{text-align:right}.ttt:before{content:"";position:
|
|
1
|
+
@layer elcrm-tooltip{.ttr{display:inline-flex;vertical-align:middle;max-width:100%}.ttt{position:fixed;box-sizing:border-box;max-width:var(--tooltip-max-width, 280px);padding:var(--tooltip-padding-block, 6px) var(--tooltip-padding-inline, 12px);border-radius:var(--tooltip-radius, 8px);background:var(--tooltip-bg, #1e1f24);color:var(--tooltip-fg, #eaeaea);font-size:var(--tooltip-font-size, 13px);line-height:1.35;font-weight:500;box-shadow:var(--tooltip-shadow, 0 8px 24px rgba(0, 0, 0, .28));pointer-events:none;opacity:0;transition:opacity .12s ease;white-space:normal;word-break:break-word}.ttv{opacity:1}.ttl{text-align:left}.ttm{text-align:center}.ttx{text-align:right}.ttt:before{content:"";position:absolute;width:0;height:0;pointer-events:none;border-style:solid;border-width:6px}.tta:before{top:100%;left:var(--tooltip-arrow-offset);margin-left:-6px;border-color:var(--tooltip-bg, #1e1f24) transparent transparent transparent}.ttb:before{bottom:100%;left:var(--tooltip-arrow-offset);margin-left:-6px;border-color:transparent transparent var(--tooltip-bg, #1e1f24) transparent}.ttc:before{left:100%;top:var(--tooltip-arrow-offset);margin-top:-6px;border-color:transparent transparent transparent var(--tooltip-bg, #1e1f24)}.ttd:before{right:100%;top:var(--tooltip-arrow-offset);margin-top:-6px;border-color:transparent var(--tooltip-bg, #1e1f24) transparent transparent}}
|
package/dist/index.es.js
CHANGED
|
@@ -1,163 +1,177 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createPortal as
|
|
3
|
-
import './index.css';const
|
|
4
|
-
version:
|
|
5
|
-
},
|
|
6
|
-
r:
|
|
7
|
-
t:
|
|
8
|
-
v:
|
|
9
|
-
l:
|
|
10
|
-
m:
|
|
11
|
-
x:
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import k, { useId as K, useRef as w, useState as T, useCallback as A, useLayoutEffect as G, useEffect as Q } from "react";
|
|
2
|
+
import { createPortal as U } from "react-dom";
|
|
3
|
+
import './index.css';const tt = "0.1.2", et = {
|
|
4
|
+
version: tt
|
|
5
|
+
}, nt = "ttr", rt = "ttt", ot = "ttv", it = "ttl", lt = "ttm", st = "ttx", ct = "tta", ut = "ttb", ft = "ttc", at = "ttd", i = {
|
|
6
|
+
r: nt,
|
|
7
|
+
t: rt,
|
|
8
|
+
v: ot,
|
|
9
|
+
l: it,
|
|
10
|
+
m: lt,
|
|
11
|
+
x: st,
|
|
12
|
+
a: ct,
|
|
13
|
+
b: ut,
|
|
14
|
+
c: ft,
|
|
15
|
+
d: at
|
|
16
|
+
}, s = 10, c = 8, W = 10;
|
|
17
|
+
function j(t, e) {
|
|
18
|
+
return Math.min(Math.max(c, t), window.innerWidth - e - c);
|
|
19
|
+
}
|
|
20
|
+
function D(t, e) {
|
|
21
|
+
return Math.min(Math.max(c, t), window.innerHeight - e - c);
|
|
22
|
+
}
|
|
23
|
+
function p(t, e) {
|
|
24
|
+
return Math.min(Math.max(W, t), e - W);
|
|
25
|
+
}
|
|
26
|
+
function dt(t, e, b) {
|
|
27
|
+
const f = t.left + t.width / 2, a = t.top + t.height / 2;
|
|
28
|
+
switch (b) {
|
|
29
|
+
case "top": {
|
|
30
|
+
let n = t.top - e.height - s, r = j(f - e.width / 2, e.width), o = "top";
|
|
31
|
+
return n < c && (n = t.bottom + s, o = "bottom"), { top: n, left: r, side: o, arrow: p(f - r, e.width) };
|
|
32
|
+
}
|
|
33
|
+
case "bottom": {
|
|
34
|
+
let n = t.bottom + s, r = j(f - e.width / 2, e.width), o = "bottom";
|
|
35
|
+
return n + e.height > window.innerHeight - c && (n = t.top - e.height - s, o = "top"), { top: n, left: r, side: o, arrow: p(f - r, e.width) };
|
|
36
|
+
}
|
|
37
|
+
case "left": {
|
|
38
|
+
let n = D(a - e.height / 2, e.height), r = t.left - e.width - s, o = "left";
|
|
39
|
+
return r < c && (r = t.right + s, o = "right"), { top: n, left: r, side: o, arrow: p(a - n, e.height) };
|
|
40
|
+
}
|
|
41
|
+
case "right": {
|
|
42
|
+
let n = D(a - e.height / 2, e.height), r = t.right + s, o = "right";
|
|
43
|
+
return r + e.width > window.innerWidth - c && (r = t.left - e.width - s, o = "left"), { top: n, left: r, side: o, arrow: p(a - n, e.height) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const X = 1e3, mt = 10;
|
|
48
|
+
function z() {
|
|
14
49
|
const t = globalThis;
|
|
15
50
|
return t.elcrm || (t.elcrm = {}), t.elcrm.overlayZ || (t.elcrm.overlayZ = { seq: 0, active: /* @__PURE__ */ new Set() }), t.elcrm.overlayZ;
|
|
16
51
|
}
|
|
17
|
-
function
|
|
18
|
-
const t =
|
|
52
|
+
function ht() {
|
|
53
|
+
const t = z();
|
|
19
54
|
t.seq += 1;
|
|
20
|
-
const e =
|
|
55
|
+
const e = X + t.seq * mt;
|
|
21
56
|
return t.active.add(e), e;
|
|
22
57
|
}
|
|
23
|
-
function
|
|
24
|
-
const e =
|
|
58
|
+
function N(t) {
|
|
59
|
+
const e = z();
|
|
25
60
|
e.active.delete(t), e.active.size === 0 && (e.seq = 0);
|
|
26
61
|
}
|
|
27
|
-
function
|
|
28
|
-
const t =
|
|
29
|
-
return t.active.size === 0 ?
|
|
30
|
-
}
|
|
31
|
-
const n = 8, s = 8;
|
|
32
|
-
function lt(t, e, y) {
|
|
33
|
-
const w = t.left + t.width / 2, d = t.top + t.height / 2;
|
|
34
|
-
let o = 0, i = 0, c = w, l = 0, r = "";
|
|
35
|
-
const g = (b) => Math.min(
|
|
36
|
-
Math.max(s, b),
|
|
37
|
-
window.innerWidth - e.width - s
|
|
38
|
-
);
|
|
39
|
-
switch (y) {
|
|
40
|
-
case "top":
|
|
41
|
-
o = t.top - e.height - n, i = g(w - e.width / 2), l = t.top - n, r = "", o < s && (o = t.bottom + n, l = t.bottom + n - 2, r = "rotate(180deg)");
|
|
42
|
-
break;
|
|
43
|
-
case "bottom":
|
|
44
|
-
o = t.bottom + n, i = g(w - e.width / 2), l = t.bottom + n - 2, r = "rotate(180deg)", o + e.height > window.innerHeight - s && (o = t.top - e.height - n, l = t.top - n, r = "");
|
|
45
|
-
break;
|
|
46
|
-
case "left":
|
|
47
|
-
o = Math.min(
|
|
48
|
-
Math.max(s, d - e.height / 2),
|
|
49
|
-
window.innerHeight - e.height - s
|
|
50
|
-
), i = t.left - e.width - n, c = t.left - n + 2, l = d, r = "rotate(270deg)", i < s && (i = t.right + n, c = t.right + n - 2, r = "rotate(90deg)");
|
|
51
|
-
break;
|
|
52
|
-
case "right":
|
|
53
|
-
o = Math.min(
|
|
54
|
-
Math.max(s, d - e.height / 2),
|
|
55
|
-
window.innerHeight - e.height - s
|
|
56
|
-
), i = t.right + n, c = t.right + n - 2, l = d, r = "rotate(90deg)", i + e.width > window.innerWidth - s && (i = t.left - e.width - n, c = t.left - n + 2, r = "rotate(270deg)");
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
return { top: o, left: i, arrowX: c, arrowY: l, arrowR: r };
|
|
62
|
+
function bt() {
|
|
63
|
+
const t = z();
|
|
64
|
+
return t.active.size === 0 ? X : Math.max(...t.active);
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
const wt = {
|
|
67
|
+
top: i.a,
|
|
68
|
+
bottom: i.b,
|
|
69
|
+
left: i.c,
|
|
70
|
+
right: i.d
|
|
71
|
+
};
|
|
72
|
+
function gt(t) {
|
|
73
|
+
return t === "left" ? i.l : t === "right" ? i.x : i.m;
|
|
63
74
|
}
|
|
64
|
-
function
|
|
75
|
+
function xt({
|
|
65
76
|
content: t,
|
|
66
77
|
children: e,
|
|
67
|
-
placement:
|
|
68
|
-
orientation:
|
|
69
|
-
textAlign:
|
|
70
|
-
delay:
|
|
71
|
-
delayHide:
|
|
72
|
-
className:
|
|
73
|
-
disabled:
|
|
74
|
-
open:
|
|
78
|
+
placement: b,
|
|
79
|
+
orientation: f,
|
|
80
|
+
textAlign: a = "center",
|
|
81
|
+
delay: n = 180,
|
|
82
|
+
delayHide: r = 60,
|
|
83
|
+
className: o,
|
|
84
|
+
disabled: I = !1,
|
|
85
|
+
open: x
|
|
75
86
|
}) {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
}, [t,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
}, [
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
|
|
87
|
+
const R = b ?? f ?? "top", M = K(), O = w(null), L = w(null), g = w(null), v = w(null), l = w(null), [Y, Z] = T(!1), [u, C] = T(null), [S, q] = T(null), E = () => {
|
|
88
|
+
g.current != null && (window.clearTimeout(g.current), g.current = null), v.current != null && (window.clearTimeout(v.current), v.current = null);
|
|
89
|
+
}, B = A(() => {
|
|
90
|
+
I || t == null || t === "" || (E(), g.current = window.setTimeout(() => {
|
|
91
|
+
Z(!0);
|
|
92
|
+
}, n));
|
|
93
|
+
}, [t, n, I]), P = A(() => {
|
|
94
|
+
x || (E(), v.current = window.setTimeout(() => {
|
|
95
|
+
Z(!1), C(null);
|
|
96
|
+
}, r));
|
|
97
|
+
}, [r, x]), d = x || Y;
|
|
98
|
+
G(() => {
|
|
99
|
+
if (d) {
|
|
100
|
+
if (l.current == null) {
|
|
101
|
+
const m = ht();
|
|
102
|
+
l.current = m, q(m);
|
|
92
103
|
}
|
|
93
104
|
return;
|
|
94
105
|
}
|
|
95
|
-
|
|
96
|
-
}, [
|
|
97
|
-
|
|
98
|
-
}, []),
|
|
99
|
-
if (!
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
106
|
+
l.current != null && (N(l.current), l.current = null, q(null));
|
|
107
|
+
}, [d]), Q(() => () => {
|
|
108
|
+
E(), l.current != null && (N(l.current), l.current = null);
|
|
109
|
+
}, []), G(() => {
|
|
110
|
+
if (!d) return;
|
|
111
|
+
const m = O.current, $ = L.current;
|
|
112
|
+
if (!m || !$) return;
|
|
113
|
+
const h = () => {
|
|
114
|
+
const F = m.getBoundingClientRect(), J = $.getBoundingClientRect();
|
|
115
|
+
C(dt(F, J, R));
|
|
105
116
|
};
|
|
106
|
-
return
|
|
107
|
-
window.removeEventListener("resize",
|
|
117
|
+
return h(), window.addEventListener("resize", h), window.addEventListener("scroll", h, !0), () => {
|
|
118
|
+
window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0);
|
|
108
119
|
};
|
|
109
|
-
}, [
|
|
110
|
-
const H =
|
|
111
|
-
top:
|
|
112
|
-
left:
|
|
113
|
-
zIndex:
|
|
114
|
-
"--tooltip-arrow-
|
|
115
|
-
"--tooltip-arrow-y": `${a.arrowY}px`,
|
|
116
|
-
"--tooltip-arrow-r": a.arrowR || "none"
|
|
120
|
+
}, [d, R, t]);
|
|
121
|
+
const H = u ? {
|
|
122
|
+
top: u.top,
|
|
123
|
+
left: u.left,
|
|
124
|
+
zIndex: S ?? 1e3,
|
|
125
|
+
"--tooltip-arrow-offset": `${u.arrow}px`
|
|
117
126
|
} : {
|
|
118
127
|
top: -9999,
|
|
119
128
|
left: -9999,
|
|
120
|
-
zIndex:
|
|
129
|
+
zIndex: S ?? 1e3,
|
|
121
130
|
visibility: "hidden"
|
|
122
|
-
},
|
|
123
|
-
|
|
131
|
+
}, V = [
|
|
132
|
+
i.t,
|
|
133
|
+
u ? wt[u.side] : "",
|
|
134
|
+
gt(a),
|
|
135
|
+
u ? i.v : ""
|
|
136
|
+
].filter(Boolean).join(" "), _ = d && typeof document < "u" ? U(
|
|
137
|
+
/* @__PURE__ */ k.createElement(
|
|
124
138
|
"div",
|
|
125
139
|
{
|
|
126
|
-
ref:
|
|
127
|
-
id:
|
|
140
|
+
ref: L,
|
|
141
|
+
id: M,
|
|
128
142
|
role: "tooltip",
|
|
129
|
-
className:
|
|
143
|
+
className: V,
|
|
130
144
|
style: H
|
|
131
145
|
},
|
|
132
146
|
t
|
|
133
147
|
),
|
|
134
148
|
document.body
|
|
135
149
|
) : null;
|
|
136
|
-
return /* @__PURE__ */
|
|
150
|
+
return /* @__PURE__ */ k.createElement(
|
|
137
151
|
"span",
|
|
138
152
|
{
|
|
139
|
-
ref:
|
|
140
|
-
className:
|
|
141
|
-
onMouseEnter:
|
|
142
|
-
onMouseLeave:
|
|
143
|
-
onFocus:
|
|
144
|
-
onBlur:
|
|
145
|
-
"aria-describedby":
|
|
153
|
+
ref: O,
|
|
154
|
+
className: o ? `${i.r} ${o}` : i.r,
|
|
155
|
+
onMouseEnter: B,
|
|
156
|
+
onMouseLeave: P,
|
|
157
|
+
onFocus: B,
|
|
158
|
+
onBlur: P,
|
|
159
|
+
"aria-describedby": d ? M : void 0
|
|
146
160
|
},
|
|
147
161
|
e,
|
|
148
|
-
|
|
162
|
+
_
|
|
149
163
|
);
|
|
150
164
|
}
|
|
151
|
-
const
|
|
152
|
-
function
|
|
165
|
+
const Et = () => null;
|
|
166
|
+
function y() {
|
|
153
167
|
return typeof globalThis < "u" ? globalThis : {};
|
|
154
168
|
}
|
|
155
|
-
|
|
156
|
-
Object.assign(
|
|
169
|
+
y().elcrm || (y().elcrm = {});
|
|
170
|
+
Object.assign(y().elcrm, { tooltip: et.version });
|
|
157
171
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
Et as Item,
|
|
173
|
+
xt as Tooltip,
|
|
174
|
+
ht as acquireOverlayZIndex,
|
|
175
|
+
bt as peekOverlayZIndex,
|
|
176
|
+
N as releaseOverlayZIndex
|
|
163
177
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(
|
|
1
|
+
(function(i,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(i=typeof globalThis<"u"?globalThis:i||self,n((i.elCRM=i.elCRM||{},i.elCRM.tooltip={}),i.React,i.ReactDOM))})(this,function(i,n,N){"use strict";var z=document.createElement("style");z.textContent=`@layer elcrm-tooltip{.ttr{display:inline-flex;vertical-align:middle;max-width:100%}.ttt{position:fixed;box-sizing:border-box;max-width:var(--tooltip-max-width, 280px);padding:var(--tooltip-padding-block, 6px) var(--tooltip-padding-inline, 12px);border-radius:var(--tooltip-radius, 8px);background:var(--tooltip-bg, #1e1f24);color:var(--tooltip-fg, #eaeaea);font-size:var(--tooltip-font-size, 13px);line-height:1.35;font-weight:500;box-shadow:var(--tooltip-shadow, 0 8px 24px rgba(0, 0, 0, .28));pointer-events:none;opacity:0;transition:opacity .12s ease;white-space:normal;word-break:break-word}.ttv{opacity:1}.ttl{text-align:left}.ttm{text-align:center}.ttx{text-align:right}.ttt:before{content:"";position:absolute;width:0;height:0;pointer-events:none;border-style:solid;border-width:6px}.tta:before{top:100%;left:var(--tooltip-arrow-offset);margin-left:-6px;border-color:var(--tooltip-bg, #1e1f24) transparent transparent transparent}.ttb:before{bottom:100%;left:var(--tooltip-arrow-offset);margin-left:-6px;border-color:transparent transparent var(--tooltip-bg, #1e1f24) transparent}.ttc:before{left:100%;top:var(--tooltip-arrow-offset);margin-top:-6px;border-color:transparent transparent transparent var(--tooltip-bg, #1e1f24)}.ttd:before{right:100%;top:var(--tooltip-arrow-offset);margin-top:-6px;border-color:transparent var(--tooltip-bg, #1e1f24) transparent transparent}}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(z);const X={version:"0.1.2"},s={r:"ttr",t:"ttt",v:"ttv",l:"ttl",m:"ttm",x:"ttx",a:"tta",b:"ttb",c:"ttc",d:"ttd"},a=10,c=8,O=10;function C(t,e){return Math.min(Math.max(c,t),window.innerWidth-e-c)}function S(t,e){return Math.min(Math.max(c,t),window.innerHeight-e-c)}function v(t,e){return Math.min(Math.max(O,t),e-O)}function Y(t,e,T){const f=t.left+t.width/2,p=t.top+t.height/2;switch(T){case"top":{let r=t.top-e.height-a,o=C(f-e.width/2,e.width),l="top";return r<c&&(r=t.bottom+a,l="bottom"),{top:r,left:o,side:l,arrow:v(f-o,e.width)}}case"bottom":{let r=t.bottom+a,o=C(f-e.width/2,e.width),l="bottom";return r+e.height>window.innerHeight-c&&(r=t.top-e.height-a,l="top"),{top:r,left:o,side:l,arrow:v(f-o,e.width)}}case"left":{let r=S(p-e.height/2,e.height),o=t.left-e.width-a,l="left";return o<c&&(o=t.right+a,l="right"),{top:r,left:o,side:l,arrow:v(p-r,e.height)}}case"right":{let r=S(p-e.height/2,e.height),o=t.right+a,l="right";return o+e.width>window.innerWidth-c&&(o=t.left-e.width-a,l="left"),{top:r,left:o,side:l,arrow:v(p-r,e.height)}}}}const Z=1e3,H=10;function x(){const t=globalThis;return t.elcrm||(t.elcrm={}),t.elcrm.overlayZ||(t.elcrm.overlayZ={seq:0,active:new Set}),t.elcrm.overlayZ}function k(){const t=x();t.seq+=1;const e=Z+t.seq*H;return t.active.add(e),e}function y(t){const e=x();e.active.delete(t),e.active.size===0&&(e.seq=0)}function V(){const t=x();return t.active.size===0?Z:Math.max(...t.active)}const F={top:s.a,bottom:s.b,left:s.c,right:s.d};function J(t){return t==="left"?s.l:t==="right"?s.x:s.m}function K({content:t,children:e,placement:T,orientation:f,textAlign:p="center",delay:r=180,delayHide:o=60,className:l,disabled:q=!1,open:I}){const L=T??f??"top",_=n.useId(),$=n.useRef(null),P=n.useRef(null),g=n.useRef(null),b=n.useRef(null),u=n.useRef(null),[U,j]=n.useState(!1),[d,B]=n.useState(null),[A,D]=n.useState(null),M=()=>{g.current!=null&&(window.clearTimeout(g.current),g.current=null),b.current!=null&&(window.clearTimeout(b.current),b.current=null)},G=n.useCallback(()=>{q||t==null||t===""||(M(),g.current=window.setTimeout(()=>{j(!0)},r))},[t,r,q]),R=n.useCallback(()=>{I||(M(),b.current=window.setTimeout(()=>{j(!1),B(null)},o))},[o,I]),h=I||U;n.useLayoutEffect(()=>{if(h){if(u.current==null){const m=k();u.current=m,D(m)}return}u.current!=null&&(y(u.current),u.current=null,D(null))},[h]),n.useEffect(()=>()=>{M(),u.current!=null&&(y(u.current),u.current=null)},[]),n.useLayoutEffect(()=>{if(!h)return;const m=$.current,W=P.current;if(!m||!W)return;const w=()=>{const rt=m.getBoundingClientRect(),ot=W.getBoundingClientRect();B(Y(rt,ot,L))};return w(),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),()=>{window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0)}},[h,L,t]);const tt=d?{top:d.top,left:d.left,zIndex:A??1e3,"--tooltip-arrow-offset":`${d.arrow}px`}:{top:-9999,left:-9999,zIndex:A??1e3,visibility:"hidden"},et=[s.t,d?F[d.side]:"",J(p),d?s.v:""].filter(Boolean).join(" "),nt=h&&typeof document<"u"?N.createPortal(n.createElement("div",{ref:P,id:_,role:"tooltip",className:et,style:tt},t),document.body):null;return n.createElement("span",{ref:$,className:l?`${s.r} ${l}`:s.r,onMouseEnter:G,onMouseLeave:R,onFocus:G,onBlur:R,"aria-describedby":h?_:void 0},e,nt)}const Q=()=>null;function E(){return typeof globalThis<"u"?globalThis:{}}E().elcrm||(E().elcrm={}),Object.assign(E().elcrm,{tooltip:X.version}),i.Item=Q,i.Tooltip=K,i.acquireOverlayZIndex=k,i.peekOverlayZIndex=V,i.releaseOverlayZIndex=y,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elcrm/tooltip",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React-подсказки для elCRM: portal, общий overlayZ-стек, hover/focus, CSS-переменные.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MaSkal <dev@elcrm.online>",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"./package.json": "./package.json"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
|
-
"dev": "vite",
|
|
58
|
+
"dev": "vite --port 3001",
|
|
59
59
|
"build": "vite build && node scripts/postbuild.mjs",
|
|
60
60
|
"check:css": "bun scripts/check-css-scoped.mjs",
|
|
61
61
|
"check:tokens": "bun scripts/check-tokens.mjs",
|