@selectwin/kit 0.1.214 → 0.1.215
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/dist/SelectTooltip.d.ts +3 -1
- package/dist/SelectTooltip.js +38 -37
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectTooltip.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { SelectPlacement } from './positioning';
|
|
3
|
-
export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, }: {
|
|
3
|
+
export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, focusable, }: {
|
|
4
4
|
content: ReactNode;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
placement?: SelectPlacement;
|
|
@@ -12,4 +12,6 @@ export declare function SelectTooltip({ content, children, placement, delay, ope
|
|
|
12
12
|
/** Não abre (0.1.188): o gatilho já mostra o mesmo conteúdo noutro lugar (ex.: o painel de páginas do trilho aberto
|
|
13
13
|
* ao lado do ícone). O embrulho continua no lugar, então o gatilho não remonta nem perde o foco. */
|
|
14
14
|
disabled?: boolean;
|
|
15
|
+
/** 0.1.215: o embrulho recebe o foco (o filho não é focável): o Tab chega na dica, e ela abre no foco do teclado. */
|
|
16
|
+
focusable?: boolean;
|
|
15
17
|
}): import("react").JSX.Element;
|
package/dist/SelectTooltip.js
CHANGED
|
@@ -14,77 +14,78 @@ function f(e) {
|
|
|
14
14
|
return !0;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1 }) {
|
|
18
|
-
let [
|
|
19
|
-
d() && (
|
|
20
|
-
}, N = () => {
|
|
21
|
-
O.current && clearTimeout(O.current), b(!1), w(!1);
|
|
17
|
+
function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1, focusable: y = !1 }) {
|
|
18
|
+
let [b, x] = o(!1), [S, C] = o(!1), [w, T] = o(!1), E = !v && (S || b && !w), D = a(null), O = a(null), k = a(null), [A, j] = o(null), M = r(), N = () => {
|
|
19
|
+
d() && (k.current && clearTimeout(k.current), k.current = setTimeout(() => x(!0), g));
|
|
22
20
|
}, P = () => {
|
|
23
|
-
|
|
21
|
+
k.current && clearTimeout(k.current), x(!1), T(!1);
|
|
22
|
+
}, F = () => {
|
|
23
|
+
_ && (k.current && clearTimeout(k.current), E ? (C(!1), x(!1), T(!0)) : C(!0));
|
|
24
24
|
};
|
|
25
25
|
n(() => () => {
|
|
26
|
-
|
|
26
|
+
k.current && clearTimeout(k.current);
|
|
27
27
|
}, []);
|
|
28
|
-
let
|
|
28
|
+
let I = t(() => {
|
|
29
29
|
var t;
|
|
30
|
-
let n = ((t =
|
|
30
|
+
let n = ((t = D.current) == null ? void 0 : t.firstElementChild) ?? D.current, r = O.current;
|
|
31
31
|
if (!n || !r) return;
|
|
32
32
|
let i = e(n.getBoundingClientRect(), {
|
|
33
33
|
width: r.offsetWidth,
|
|
34
34
|
height: r.offsetHeight
|
|
35
35
|
}, h, 6);
|
|
36
|
-
|
|
36
|
+
j({
|
|
37
37
|
top: i.top,
|
|
38
38
|
left: i.left
|
|
39
39
|
});
|
|
40
40
|
}, [h]);
|
|
41
41
|
return i(() => {
|
|
42
|
-
if (!
|
|
43
|
-
|
|
42
|
+
if (!E) {
|
|
43
|
+
j(null);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
if (!
|
|
49
|
-
let e = () =>
|
|
46
|
+
I();
|
|
47
|
+
}, [E, I]), n(() => {
|
|
48
|
+
if (!E) return;
|
|
49
|
+
let e = () => I();
|
|
50
50
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
51
51
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
52
52
|
};
|
|
53
|
-
}, [
|
|
54
|
-
if (!
|
|
53
|
+
}, [E, I]), n(() => {
|
|
54
|
+
if (!E) return;
|
|
55
55
|
let e = (e) => {
|
|
56
|
-
e.key === "Escape" && (
|
|
56
|
+
e.key === "Escape" && (C(!1), x(!1));
|
|
57
57
|
};
|
|
58
58
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
59
|
-
}, [
|
|
60
|
-
if (!
|
|
59
|
+
}, [E]), n(() => {
|
|
60
|
+
if (!S) return;
|
|
61
61
|
let e = (e) => {
|
|
62
62
|
var t, n;
|
|
63
63
|
let r = e.target;
|
|
64
|
-
(t =
|
|
64
|
+
(t = D.current) != null && t.contains(r) || (n = O.current) != null && n.contains(r) || (C(!1), x(!1));
|
|
65
65
|
};
|
|
66
66
|
return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
|
|
67
|
-
}, [
|
|
67
|
+
}, [S]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
|
|
68
68
|
className: "select-tip__trigger",
|
|
69
|
-
ref:
|
|
70
|
-
onMouseEnter:
|
|
71
|
-
onMouseLeave:
|
|
69
|
+
ref: D,
|
|
70
|
+
onMouseEnter: N,
|
|
71
|
+
onMouseLeave: P,
|
|
72
72
|
onFocusCapture: (e) => {
|
|
73
|
-
f(e.target) &&
|
|
73
|
+
f(e.target) && x(!0);
|
|
74
74
|
},
|
|
75
|
-
onBlurCapture:
|
|
76
|
-
onClick: _ ?
|
|
77
|
-
|
|
75
|
+
onBlurCapture: P,
|
|
76
|
+
onClick: _ ? F : void 0,
|
|
77
|
+
tabIndex: y ? 0 : void 0,
|
|
78
|
+
"aria-describedby": E ? M : void 0,
|
|
78
79
|
children: m
|
|
79
|
-
}),
|
|
80
|
-
ref:
|
|
81
|
-
id:
|
|
80
|
+
}), E && u(/* @__PURE__ */ c("div", {
|
|
81
|
+
ref: O,
|
|
82
|
+
id: M,
|
|
82
83
|
role: "tooltip",
|
|
83
|
-
className: `select select-tip${
|
|
84
|
-
style:
|
|
84
|
+
className: `select select-tip${S ? " select-tip--pinned" : ""}`,
|
|
85
|
+
style: A ? {
|
|
85
86
|
position: "fixed",
|
|
86
|
-
top:
|
|
87
|
-
left:
|
|
87
|
+
top: A.top,
|
|
88
|
+
left: A.left
|
|
88
89
|
} : {
|
|
89
90
|
position: "fixed",
|
|
90
91
|
top: 0,
|