@ssaprt/tooltip 1.0.3 → 1.0.5
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/index.js +189 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +189 -91
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -168,20 +168,19 @@ var presets = {
|
|
|
168
168
|
animation: animations.bounce
|
|
169
169
|
}),
|
|
170
170
|
manga: createTheme({
|
|
171
|
-
background: "
|
|
171
|
+
background: "linear-gradient(145deg, #ffffff, #f4f4f5)",
|
|
172
172
|
color: "#000000",
|
|
173
173
|
fontFamily: "Impact, Haettenschweiler, Arial Narrow Bold, sans-serif",
|
|
174
174
|
fontSize: "13px",
|
|
175
175
|
fontWeight: 900,
|
|
176
176
|
border: "3px solid #000000",
|
|
177
|
-
borderRadius: "
|
|
178
|
-
filter: "drop-shadow(4px 4px 0 #000000)",
|
|
177
|
+
borderRadius: "10px 3px 10px 3px",
|
|
179
178
|
padding: "9px 15px",
|
|
180
179
|
letterSpacing: "0.04em",
|
|
181
180
|
textTransform: "uppercase",
|
|
182
|
-
arrowSize: "
|
|
181
|
+
arrowSize: "10px",
|
|
183
182
|
arrowWidth: "17px",
|
|
184
|
-
animation: animations.
|
|
183
|
+
animation: animations.pop
|
|
185
184
|
}),
|
|
186
185
|
newspaper: createTheme({
|
|
187
186
|
background: "repeating-linear-gradient(0deg, rgba(68, 64, 60, 0.035) 0, rgba(68, 64, 60, 0.035) 1px, transparent 1px, transparent 4px), #f5f0e6",
|
|
@@ -237,54 +236,48 @@ var presets = {
|
|
|
237
236
|
}
|
|
238
237
|
}),
|
|
239
238
|
terminal: createTheme({
|
|
240
|
-
background: "
|
|
241
|
-
color: "#
|
|
239
|
+
background: "#020a04",
|
|
240
|
+
color: "#4ade80",
|
|
242
241
|
fontFamily: "Consolas, Monaco, Courier New, monospace",
|
|
243
242
|
fontSize: "12px",
|
|
244
243
|
fontWeight: 600,
|
|
245
244
|
border: "1px solid #22c55e",
|
|
246
245
|
borderRadius: "3px",
|
|
247
|
-
filter: "drop-shadow(0 0 5px rgba(34, 197, 94, 0.65))",
|
|
248
246
|
padding: "8px 12px",
|
|
249
247
|
letterSpacing: "0.035em",
|
|
250
|
-
textShadow: "0 0 5px rgba(34, 197, 94, 0.9)",
|
|
251
248
|
textAlign: "left",
|
|
252
249
|
arrowSize: "7px",
|
|
253
250
|
arrowWidth: "13px",
|
|
254
|
-
animation: animations.
|
|
251
|
+
animation: animations.soft
|
|
255
252
|
}),
|
|
256
253
|
crt: createTheme({
|
|
257
|
-
background: "
|
|
254
|
+
background: "linear-gradient(180deg, #07150b, #020804)",
|
|
258
255
|
color: "#86efac",
|
|
259
256
|
fontFamily: "Lucida Console, Monaco, monospace",
|
|
260
257
|
fontSize: "12px",
|
|
261
258
|
fontWeight: 600,
|
|
262
259
|
border: "2px solid #166534",
|
|
263
|
-
borderRadius: "
|
|
264
|
-
filter: "drop-shadow(0 0 8px rgba(34, 197, 94, 0.5)) drop-shadow(0 0 18px rgba(34, 197, 94, 0.18))",
|
|
260
|
+
borderRadius: "12px",
|
|
265
261
|
padding: "10px 15px",
|
|
266
|
-
textShadow: "0 0 6px rgba(134, 239, 172, 0.85)",
|
|
267
262
|
arrowSize: "8px",
|
|
268
263
|
arrowWidth: "18px",
|
|
269
|
-
animation: animations.
|
|
264
|
+
animation: animations.soft
|
|
270
265
|
}),
|
|
271
266
|
pixel: createTheme({
|
|
272
|
-
background: "linear-gradient(135deg, #4c1d95
|
|
267
|
+
background: "linear-gradient(135deg, #4c1d95, #581c87)",
|
|
273
268
|
color: "#fef08a",
|
|
274
|
-
fontFamily: "
|
|
269
|
+
fontFamily: "Courier New, monospace",
|
|
275
270
|
fontSize: "10px",
|
|
276
271
|
fontWeight: 700,
|
|
277
272
|
lineHeight: 1.7,
|
|
278
273
|
border: "4px solid #fef08a",
|
|
279
274
|
borderRadius: "0px",
|
|
280
|
-
filter: "drop-shadow(6px 6px 0 #18181b)",
|
|
281
275
|
padding: "10px 14px",
|
|
282
276
|
letterSpacing: "0.03em",
|
|
283
|
-
textShadow: "2px 2px 0 #18181b",
|
|
284
277
|
textTransform: "uppercase",
|
|
285
278
|
arrowSize: "10px",
|
|
286
279
|
arrowWidth: "18px",
|
|
287
|
-
animation: animations.
|
|
280
|
+
animation: animations.pop
|
|
288
281
|
}),
|
|
289
282
|
arcade: createTheme({
|
|
290
283
|
background: "radial-gradient(circle at 20% 0%, rgba(34, 211, 238, 0.45), transparent 38%), radial-gradient(circle at 90% 100%, rgba(236, 72, 153, 0.55), transparent 45%), #150629",
|
|
@@ -498,20 +491,19 @@ var presets = {
|
|
|
498
491
|
animation: animations.blur
|
|
499
492
|
}),
|
|
500
493
|
toxic: createTheme({
|
|
501
|
-
background: "
|
|
494
|
+
background: "linear-gradient(135deg, #bef264, #84cc16)",
|
|
502
495
|
color: "#1a2e05",
|
|
503
496
|
fontFamily: "Arial Black, Impact, sans-serif",
|
|
504
497
|
fontSize: "12px",
|
|
505
498
|
fontWeight: 900,
|
|
506
499
|
border: "3px solid #1a2e05",
|
|
507
|
-
borderRadius: "
|
|
508
|
-
filter: "drop-shadow(4px 5px 0 #365314)",
|
|
500
|
+
borderRadius: "3px 10px 3px 10px",
|
|
509
501
|
padding: "9px 14px",
|
|
510
502
|
letterSpacing: "0.08em",
|
|
511
503
|
textTransform: "uppercase",
|
|
512
504
|
arrowSize: "10px",
|
|
513
505
|
arrowWidth: "20px",
|
|
514
|
-
animation: animations.
|
|
506
|
+
animation: animations.pop
|
|
515
507
|
}),
|
|
516
508
|
radioactive: createTheme({
|
|
517
509
|
background: "conic-gradient(from 45deg at 50% 50%, #facc15 0 12.5%, #18181b 12.5% 25%, #facc15 25% 37.5%, #18181b 37.5% 50%, #facc15 50% 62.5%, #18181b 62.5% 75%, #facc15 75% 87.5%, #18181b 87.5%)",
|
|
@@ -531,20 +523,18 @@ var presets = {
|
|
|
531
523
|
animation: animations.zoom
|
|
532
524
|
}),
|
|
533
525
|
hazard: createTheme({
|
|
534
|
-
background: "
|
|
526
|
+
background: "linear-gradient(135deg, #fb923c, #ea580c)",
|
|
535
527
|
color: "#ffffff",
|
|
536
528
|
fontFamily: "Arial Black, Impact, sans-serif",
|
|
537
529
|
fontSize: "12px",
|
|
538
530
|
fontWeight: 900,
|
|
539
531
|
border: "3px solid #18181b",
|
|
540
532
|
borderRadius: "4px",
|
|
541
|
-
filter: "drop-shadow(5px 5px 0 rgba(24, 24, 27, 0.6))",
|
|
542
533
|
padding: "9px 15px",
|
|
543
|
-
textShadow: "2px 2px 0 #18181b, -1px -1px 0 #18181b",
|
|
544
534
|
textTransform: "uppercase",
|
|
545
535
|
arrowSize: "10px",
|
|
546
536
|
arrowWidth: "20px",
|
|
547
|
-
animation: animations.
|
|
537
|
+
animation: animations.pop
|
|
548
538
|
}),
|
|
549
539
|
policeTape: createTheme({
|
|
550
540
|
background: "repeating-linear-gradient(135deg, #f8fafc 0, #f8fafc 11px, #2563eb 11px, #2563eb 22px)",
|
|
@@ -662,21 +652,20 @@ var presets = {
|
|
|
662
652
|
animation: animations.slide
|
|
663
653
|
}),
|
|
664
654
|
dossier: createTheme({
|
|
665
|
-
background: "linear-gradient(
|
|
655
|
+
background: "linear-gradient(180deg, #f2e5c8, #dfc99f)",
|
|
666
656
|
color: "#3f2d1d",
|
|
667
657
|
fontFamily: "Courier New, monospace",
|
|
668
658
|
fontSize: "11px",
|
|
669
659
|
fontWeight: 800,
|
|
670
660
|
border: "2px solid #92400e",
|
|
671
|
-
borderRadius: "
|
|
672
|
-
filter: "drop-shadow(5px 7px 0 rgba(120, 53, 15, 0.35))",
|
|
661
|
+
borderRadius: "2px 7px 2px 7px",
|
|
673
662
|
padding: "11px 16px",
|
|
674
663
|
letterSpacing: "0.08em",
|
|
675
664
|
textTransform: "uppercase",
|
|
676
665
|
textAlign: "left",
|
|
677
666
|
arrowSize: "8px",
|
|
678
667
|
arrowWidth: "17px",
|
|
679
|
-
animation: animations.
|
|
668
|
+
animation: animations.soft
|
|
680
669
|
}),
|
|
681
670
|
medical: createTheme({
|
|
682
671
|
background: "linear-gradient(90deg, transparent 44%, rgba(14, 165, 233, 0.08) 44% 56%, transparent 56%), linear-gradient(0deg, transparent 44%, rgba(14, 165, 233, 0.08) 44% 56%, transparent 56%), #f8fafc",
|
|
@@ -712,20 +701,18 @@ var presets = {
|
|
|
712
701
|
}
|
|
713
702
|
}),
|
|
714
703
|
circuit: createTheme({
|
|
715
|
-
background: "linear-gradient(
|
|
704
|
+
background: "linear-gradient(135deg, #052e16, #022c22)",
|
|
716
705
|
color: "#bbf7d0",
|
|
717
706
|
fontFamily: "Consolas, monospace",
|
|
718
707
|
fontSize: "11px",
|
|
719
708
|
fontWeight: 700,
|
|
720
709
|
border: "2px solid #22c55e",
|
|
721
710
|
borderRadius: "5px",
|
|
722
|
-
filter: "drop-shadow(0 0 7px rgba(34, 197, 94, 0.55))",
|
|
723
711
|
padding: "9px 14px",
|
|
724
712
|
letterSpacing: "0.05em",
|
|
725
|
-
textShadow: "0 0 4px rgba(34, 197, 94, 0.75)",
|
|
726
713
|
arrowSize: "8px",
|
|
727
714
|
arrowWidth: "16px",
|
|
728
|
-
animation: animations.
|
|
715
|
+
animation: animations.soft
|
|
729
716
|
}),
|
|
730
717
|
galaxy: createTheme({
|
|
731
718
|
background: "radial-gradient(circle at 12% 25%, #ffffff 0 1px, transparent 1.5px), radial-gradient(circle at 76% 18%, #c4b5fd 0 1px, transparent 1.5px), radial-gradient(circle at 63% 78%, #ffffff 0 1.2px, transparent 1.8px), radial-gradient(circle at 28% 72%, rgba(236, 72, 153, 0.55), transparent 22%), radial-gradient(circle at 70% 20%, rgba(99, 102, 241, 0.55), transparent 32%), #09051f",
|
|
@@ -901,27 +888,24 @@ var presets = {
|
|
|
901
888
|
fontWeight: 900,
|
|
902
889
|
border: "4px solid #000000",
|
|
903
890
|
borderRadius: "0px",
|
|
904
|
-
filter: "drop-shadow(7px 7px 0 #ef4444)",
|
|
905
891
|
padding: "10px 16px",
|
|
906
892
|
letterSpacing: "-0.03em",
|
|
907
893
|
textTransform: "uppercase",
|
|
908
894
|
textAlign: "left",
|
|
909
895
|
arrowSize: "11px",
|
|
910
896
|
arrowWidth: "19px",
|
|
911
|
-
animation: animations.
|
|
897
|
+
animation: animations.pop
|
|
912
898
|
}),
|
|
913
899
|
chalkboard: createTheme({
|
|
914
|
-
background: "
|
|
900
|
+
background: "linear-gradient(145deg, #183f30, #102a21)",
|
|
915
901
|
color: "#f5f5dc",
|
|
916
902
|
fontFamily: "Comic Sans MS, Chalkboard, cursive",
|
|
917
903
|
fontSize: "13px",
|
|
918
904
|
fontWeight: 600,
|
|
919
905
|
border: "3px solid #8b5e3c",
|
|
920
906
|
borderRadius: "2px",
|
|
921
|
-
filter: "drop-shadow(4px 6px 0 rgba(66, 32, 6, 0.45))",
|
|
922
907
|
padding: "10px 16px",
|
|
923
908
|
letterSpacing: "0.025em",
|
|
924
|
-
textShadow: "0 0 2px rgba(255, 255, 255, 0.55)",
|
|
925
909
|
textAlign: "left",
|
|
926
910
|
arrowSize: "9px",
|
|
927
911
|
arrowWidth: "18px",
|
|
@@ -951,6 +935,63 @@ var INTERACTIVE_RECHECK_INTERVAL = 50;
|
|
|
951
935
|
var TOUCH_MOVE_THRESHOLD = 10;
|
|
952
936
|
var TOUCH_MAX_TAP_DURATION = 600;
|
|
953
937
|
var TOUCH_FOCUS_SUPPRESSION = 700;
|
|
938
|
+
var activeTooltipSession = null;
|
|
939
|
+
var inputModality = "pointer";
|
|
940
|
+
var inputModalitySubscribers = 0;
|
|
941
|
+
var handleGlobalPointerDown = () => {
|
|
942
|
+
inputModality = "pointer";
|
|
943
|
+
};
|
|
944
|
+
var keyboardFocusKeys = /* @__PURE__ */ new Set([
|
|
945
|
+
"Tab",
|
|
946
|
+
"Enter",
|
|
947
|
+
" ",
|
|
948
|
+
"ArrowUp",
|
|
949
|
+
"ArrowDown",
|
|
950
|
+
"ArrowLeft",
|
|
951
|
+
"ArrowRight",
|
|
952
|
+
"Home",
|
|
953
|
+
"End",
|
|
954
|
+
"PageUp",
|
|
955
|
+
"PageDown"
|
|
956
|
+
]);
|
|
957
|
+
var handleGlobalKeyDown = (event) => {
|
|
958
|
+
if (event.metaKey || event.ctrlKey || event.altKey || !keyboardFocusKeys.has(event.key)) {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
inputModality = "keyboard";
|
|
962
|
+
};
|
|
963
|
+
var subscribeInputModality = () => {
|
|
964
|
+
inputModalitySubscribers += 1;
|
|
965
|
+
if (inputModalitySubscribers !== 1) {
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
document.addEventListener("pointerdown", handleGlobalPointerDown, true);
|
|
969
|
+
document.addEventListener("keydown", handleGlobalKeyDown, true);
|
|
970
|
+
};
|
|
971
|
+
var unsubscribeInputModality = () => {
|
|
972
|
+
inputModalitySubscribers = Math.max(0, inputModalitySubscribers - 1);
|
|
973
|
+
if (inputModalitySubscribers !== 0) {
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
document.removeEventListener("pointerdown", handleGlobalPointerDown, true);
|
|
977
|
+
document.removeEventListener("keydown", handleGlobalKeyDown, true);
|
|
978
|
+
};
|
|
979
|
+
var requestTooltipActivation = (session, point) => {
|
|
980
|
+
const currentSession = activeTooltipSession;
|
|
981
|
+
if (currentSession && currentSession.owner !== session.owner) {
|
|
982
|
+
if (point && currentSession.interactive && currentSession.protectsPoint(point)) {
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
currentSession.close();
|
|
986
|
+
}
|
|
987
|
+
activeTooltipSession = session;
|
|
988
|
+
return true;
|
|
989
|
+
};
|
|
990
|
+
var clearTooltipActivation = (owner) => {
|
|
991
|
+
if (activeTooltipSession?.owner === owner) {
|
|
992
|
+
activeTooltipSession = null;
|
|
993
|
+
}
|
|
994
|
+
};
|
|
954
995
|
var oppositePlacement = {
|
|
955
996
|
top: "bottom",
|
|
956
997
|
bottom: "top",
|
|
@@ -1076,6 +1117,7 @@ var useTooltip = ({
|
|
|
1076
1117
|
}) => {
|
|
1077
1118
|
const tooltipRef = useRef(null);
|
|
1078
1119
|
const bodyRef = useRef(null);
|
|
1120
|
+
const ownerRef = useRef(/* @__PURE__ */ Symbol("tooltip"));
|
|
1079
1121
|
const hideTimerRef = useRef(null);
|
|
1080
1122
|
const firstFrameRef = useRef(null);
|
|
1081
1123
|
const secondFrameRef = useRef(null);
|
|
@@ -1088,6 +1130,7 @@ var useTooltip = ({
|
|
|
1088
1130
|
y: Number.NaN,
|
|
1089
1131
|
pointerType: ""
|
|
1090
1132
|
});
|
|
1133
|
+
const interactiveAreaAtPointRef = useRef(() => "outside");
|
|
1091
1134
|
const touchGestureRef = useRef(null);
|
|
1092
1135
|
const suppressFocusUntilRef = useRef(0);
|
|
1093
1136
|
const [mounted, setMounted] = useState(false);
|
|
@@ -1226,7 +1269,7 @@ var useTooltip = ({
|
|
|
1226
1269
|
});
|
|
1227
1270
|
}, [anchor, getAvailableSpace, preferredPlacement]);
|
|
1228
1271
|
const isFocusInsideTooltipRegion = useCallback(() => {
|
|
1229
|
-
if (!anchor || typeof document === "undefined") {
|
|
1272
|
+
if (!anchor || typeof document === "undefined" || inputModality !== "keyboard") {
|
|
1230
1273
|
return false;
|
|
1231
1274
|
}
|
|
1232
1275
|
const activeElement = document.activeElement;
|
|
@@ -1234,50 +1277,60 @@ var useTooltip = ({
|
|
|
1234
1277
|
if (!(activeElement instanceof Node)) {
|
|
1235
1278
|
return false;
|
|
1236
1279
|
}
|
|
1237
|
-
|
|
1238
|
-
return true;
|
|
1239
|
-
}
|
|
1240
|
-
return anchor.contains(activeElement) && activeElement instanceof Element && activeElement.matches(":focus-visible");
|
|
1280
|
+
return anchor.contains(activeElement) || Boolean(interactive && tooltip?.contains(activeElement));
|
|
1241
1281
|
}, [anchor, interactive]);
|
|
1282
|
+
const getInteractivePointerAreaAtPoint = useCallback(
|
|
1283
|
+
(point) => {
|
|
1284
|
+
if (!interactive || !anchor) {
|
|
1285
|
+
return "outside";
|
|
1286
|
+
}
|
|
1287
|
+
const tooltip = tooltipRef.current;
|
|
1288
|
+
if (!tooltip || !Number.isFinite(point.x) || !Number.isFinite(point.y)) {
|
|
1289
|
+
return "outside";
|
|
1290
|
+
}
|
|
1291
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
1292
|
+
const tooltipRect = tooltip.getBoundingClientRect();
|
|
1293
|
+
if (isPointInsideRect(
|
|
1294
|
+
point,
|
|
1295
|
+
anchorRect,
|
|
1296
|
+
INTERACTIVE_DIRECT_PADDING
|
|
1297
|
+
) || isPointInsideRect(
|
|
1298
|
+
point,
|
|
1299
|
+
tooltipRect,
|
|
1300
|
+
INTERACTIVE_DIRECT_PADDING
|
|
1301
|
+
)) {
|
|
1302
|
+
return "direct";
|
|
1303
|
+
}
|
|
1304
|
+
const bridge = createInteractiveBridge(
|
|
1305
|
+
anchorRect,
|
|
1306
|
+
tooltipRect,
|
|
1307
|
+
placement
|
|
1308
|
+
);
|
|
1309
|
+
return isPointInsidePolygon(point, bridge) ? "bridge" : "outside";
|
|
1310
|
+
},
|
|
1311
|
+
[anchor, interactive, placement]
|
|
1312
|
+
);
|
|
1313
|
+
useLayoutEffect(() => {
|
|
1314
|
+
interactiveAreaAtPointRef.current = getInteractivePointerAreaAtPoint;
|
|
1315
|
+
}, [getInteractivePointerAreaAtPoint]);
|
|
1242
1316
|
const getInteractivePointerArea = useCallback(() => {
|
|
1243
|
-
if (!interactive || !anchor) {
|
|
1244
|
-
return "outside";
|
|
1245
|
-
}
|
|
1246
1317
|
const pointer = pointerRef.current;
|
|
1247
|
-
|
|
1248
|
-
if (!tooltip || pointer.pointerType !== "mouse" && pointer.pointerType !== "pen" || !Number.isFinite(pointer.x) || !Number.isFinite(pointer.y)) {
|
|
1318
|
+
if (pointer.pointerType !== "mouse" && pointer.pointerType !== "pen" || !Number.isFinite(pointer.x) || !Number.isFinite(pointer.y)) {
|
|
1249
1319
|
return "outside";
|
|
1250
1320
|
}
|
|
1251
|
-
|
|
1321
|
+
return getInteractivePointerAreaAtPoint({
|
|
1252
1322
|
x: pointer.x,
|
|
1253
1323
|
y: pointer.y
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
const tooltipRect = tooltip.getBoundingClientRect();
|
|
1257
|
-
if (isPointInsideRect(
|
|
1258
|
-
point,
|
|
1259
|
-
anchorRect,
|
|
1260
|
-
INTERACTIVE_DIRECT_PADDING
|
|
1261
|
-
) || isPointInsideRect(
|
|
1262
|
-
point,
|
|
1263
|
-
tooltipRect,
|
|
1264
|
-
INTERACTIVE_DIRECT_PADDING
|
|
1265
|
-
)) {
|
|
1266
|
-
return "direct";
|
|
1267
|
-
}
|
|
1268
|
-
const bridge = createInteractiveBridge(
|
|
1269
|
-
anchorRect,
|
|
1270
|
-
tooltipRect,
|
|
1271
|
-
placement
|
|
1272
|
-
);
|
|
1273
|
-
return isPointInsidePolygon(point, bridge) ? "bridge" : "outside";
|
|
1274
|
-
}, [anchor, interactive, placement]);
|
|
1324
|
+
});
|
|
1325
|
+
}, [getInteractivePointerAreaAtPoint]);
|
|
1275
1326
|
const removeTooltip = useCallback(() => {
|
|
1276
1327
|
clearHideTimer();
|
|
1277
1328
|
clearEnterFrames();
|
|
1278
1329
|
clearInteractiveFrame();
|
|
1279
1330
|
pendingHideRef.current = false;
|
|
1280
1331
|
interactiveBridgeDeadlineRef.current = 0;
|
|
1332
|
+
clearTooltipActivation(ownerRef.current);
|
|
1333
|
+
setMounted(false);
|
|
1281
1334
|
updatePhase("hidden");
|
|
1282
1335
|
}, [clearEnterFrames, clearHideTimer, clearInteractiveFrame, updatePhase]);
|
|
1283
1336
|
const runHide = useCallback(() => {
|
|
@@ -1353,21 +1406,51 @@ var useTooltip = ({
|
|
|
1353
1406
|
runHide
|
|
1354
1407
|
]
|
|
1355
1408
|
);
|
|
1356
|
-
const showTooltip = useCallback(
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1409
|
+
const showTooltip = useCallback(
|
|
1410
|
+
(activationPoint) => {
|
|
1411
|
+
if (!anchor || disabled) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
const activated = requestTooltipActivation(
|
|
1415
|
+
{
|
|
1416
|
+
owner: ownerRef.current,
|
|
1417
|
+
interactive,
|
|
1418
|
+
protectsPoint: (point) => {
|
|
1419
|
+
if (phaseRef.current === "hidden") {
|
|
1420
|
+
return false;
|
|
1421
|
+
}
|
|
1422
|
+
return interactiveAreaAtPointRef.current(point) !== "outside";
|
|
1423
|
+
},
|
|
1424
|
+
close: () => {
|
|
1425
|
+
hideTooltip(true);
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1428
|
+
activationPoint
|
|
1429
|
+
);
|
|
1430
|
+
if (!activated) {
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
clearHideTimer();
|
|
1434
|
+
clearEnterFrames();
|
|
1435
|
+
interactiveBridgeDeadlineRef.current = 0;
|
|
1436
|
+
pendingHideRef.current = false;
|
|
1437
|
+
setMounted(true);
|
|
1438
|
+
if (phaseRef.current === "entering" || phaseRef.current === "visible") {
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
updatePhase("preparing");
|
|
1442
|
+
setShowVersion((value) => value + 1);
|
|
1443
|
+
},
|
|
1444
|
+
[
|
|
1445
|
+
anchor,
|
|
1446
|
+
clearEnterFrames,
|
|
1447
|
+
clearHideTimer,
|
|
1448
|
+
disabled,
|
|
1449
|
+
hideTooltip,
|
|
1450
|
+
interactive,
|
|
1451
|
+
updatePhase
|
|
1452
|
+
]
|
|
1453
|
+
);
|
|
1371
1454
|
const keepTooltipOpen = useCallback(() => {
|
|
1372
1455
|
if (!interactive || disabled) {
|
|
1373
1456
|
return;
|
|
@@ -1457,6 +1540,13 @@ var useTooltip = ({
|
|
|
1457
1540
|
showVersion,
|
|
1458
1541
|
updatePhase
|
|
1459
1542
|
]);
|
|
1543
|
+
useEffect(() => {
|
|
1544
|
+
subscribeInputModality();
|
|
1545
|
+
return () => {
|
|
1546
|
+
unsubscribeInputModality();
|
|
1547
|
+
clearTooltipActivation(ownerRef.current);
|
|
1548
|
+
};
|
|
1549
|
+
}, []);
|
|
1460
1550
|
useEffect(() => {
|
|
1461
1551
|
if (!anchor) {
|
|
1462
1552
|
removeTooltip();
|
|
@@ -1474,7 +1564,10 @@ var useTooltip = ({
|
|
|
1474
1564
|
if (event.pointerType === "touch") {
|
|
1475
1565
|
return;
|
|
1476
1566
|
}
|
|
1477
|
-
showTooltip(
|
|
1567
|
+
showTooltip({
|
|
1568
|
+
x: event.clientX,
|
|
1569
|
+
y: event.clientY
|
|
1570
|
+
});
|
|
1478
1571
|
};
|
|
1479
1572
|
const onPointerLeave = (event) => {
|
|
1480
1573
|
updatePointer(event);
|
|
@@ -1546,7 +1639,10 @@ var useTooltip = ({
|
|
|
1546
1639
|
return;
|
|
1547
1640
|
}
|
|
1548
1641
|
if (phaseRef.current === "hidden" || phaseRef.current === "leaving") {
|
|
1549
|
-
showTooltip(
|
|
1642
|
+
showTooltip({
|
|
1643
|
+
x: event.clientX,
|
|
1644
|
+
y: event.clientY
|
|
1645
|
+
});
|
|
1550
1646
|
} else {
|
|
1551
1647
|
hideTooltip(true);
|
|
1552
1648
|
}
|
|
@@ -1643,7 +1739,9 @@ var useTooltip = ({
|
|
|
1643
1739
|
scheduleInteractivePointerProcessing();
|
|
1644
1740
|
};
|
|
1645
1741
|
const onFocusIn = () => {
|
|
1646
|
-
|
|
1742
|
+
if (inputModality === "keyboard") {
|
|
1743
|
+
keepTooltipOpen();
|
|
1744
|
+
}
|
|
1647
1745
|
};
|
|
1648
1746
|
const onFocusOut = (event) => {
|
|
1649
1747
|
const relatedTarget = event.relatedTarget;
|