@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.js
CHANGED
|
@@ -186,20 +186,19 @@ var presets = {
|
|
|
186
186
|
animation: animations.bounce
|
|
187
187
|
}),
|
|
188
188
|
manga: createTheme({
|
|
189
|
-
background: "
|
|
189
|
+
background: "linear-gradient(145deg, #ffffff, #f4f4f5)",
|
|
190
190
|
color: "#000000",
|
|
191
191
|
fontFamily: "Impact, Haettenschweiler, Arial Narrow Bold, sans-serif",
|
|
192
192
|
fontSize: "13px",
|
|
193
193
|
fontWeight: 900,
|
|
194
194
|
border: "3px solid #000000",
|
|
195
|
-
borderRadius: "
|
|
196
|
-
filter: "drop-shadow(4px 4px 0 #000000)",
|
|
195
|
+
borderRadius: "10px 3px 10px 3px",
|
|
197
196
|
padding: "9px 15px",
|
|
198
197
|
letterSpacing: "0.04em",
|
|
199
198
|
textTransform: "uppercase",
|
|
200
|
-
arrowSize: "
|
|
199
|
+
arrowSize: "10px",
|
|
201
200
|
arrowWidth: "17px",
|
|
202
|
-
animation: animations.
|
|
201
|
+
animation: animations.pop
|
|
203
202
|
}),
|
|
204
203
|
newspaper: createTheme({
|
|
205
204
|
background: "repeating-linear-gradient(0deg, rgba(68, 64, 60, 0.035) 0, rgba(68, 64, 60, 0.035) 1px, transparent 1px, transparent 4px), #f5f0e6",
|
|
@@ -255,54 +254,48 @@ var presets = {
|
|
|
255
254
|
}
|
|
256
255
|
}),
|
|
257
256
|
terminal: createTheme({
|
|
258
|
-
background: "
|
|
259
|
-
color: "#
|
|
257
|
+
background: "#020a04",
|
|
258
|
+
color: "#4ade80",
|
|
260
259
|
fontFamily: "Consolas, Monaco, Courier New, monospace",
|
|
261
260
|
fontSize: "12px",
|
|
262
261
|
fontWeight: 600,
|
|
263
262
|
border: "1px solid #22c55e",
|
|
264
263
|
borderRadius: "3px",
|
|
265
|
-
filter: "drop-shadow(0 0 5px rgba(34, 197, 94, 0.65))",
|
|
266
264
|
padding: "8px 12px",
|
|
267
265
|
letterSpacing: "0.035em",
|
|
268
|
-
textShadow: "0 0 5px rgba(34, 197, 94, 0.9)",
|
|
269
266
|
textAlign: "left",
|
|
270
267
|
arrowSize: "7px",
|
|
271
268
|
arrowWidth: "13px",
|
|
272
|
-
animation: animations.
|
|
269
|
+
animation: animations.soft
|
|
273
270
|
}),
|
|
274
271
|
crt: createTheme({
|
|
275
|
-
background: "
|
|
272
|
+
background: "linear-gradient(180deg, #07150b, #020804)",
|
|
276
273
|
color: "#86efac",
|
|
277
274
|
fontFamily: "Lucida Console, Monaco, monospace",
|
|
278
275
|
fontSize: "12px",
|
|
279
276
|
fontWeight: 600,
|
|
280
277
|
border: "2px solid #166534",
|
|
281
|
-
borderRadius: "
|
|
282
|
-
filter: "drop-shadow(0 0 8px rgba(34, 197, 94, 0.5)) drop-shadow(0 0 18px rgba(34, 197, 94, 0.18))",
|
|
278
|
+
borderRadius: "12px",
|
|
283
279
|
padding: "10px 15px",
|
|
284
|
-
textShadow: "0 0 6px rgba(134, 239, 172, 0.85)",
|
|
285
280
|
arrowSize: "8px",
|
|
286
281
|
arrowWidth: "18px",
|
|
287
|
-
animation: animations.
|
|
282
|
+
animation: animations.soft
|
|
288
283
|
}),
|
|
289
284
|
pixel: createTheme({
|
|
290
|
-
background: "linear-gradient(135deg, #4c1d95
|
|
285
|
+
background: "linear-gradient(135deg, #4c1d95, #581c87)",
|
|
291
286
|
color: "#fef08a",
|
|
292
|
-
fontFamily: "
|
|
287
|
+
fontFamily: "Courier New, monospace",
|
|
293
288
|
fontSize: "10px",
|
|
294
289
|
fontWeight: 700,
|
|
295
290
|
lineHeight: 1.7,
|
|
296
291
|
border: "4px solid #fef08a",
|
|
297
292
|
borderRadius: "0px",
|
|
298
|
-
filter: "drop-shadow(6px 6px 0 #18181b)",
|
|
299
293
|
padding: "10px 14px",
|
|
300
294
|
letterSpacing: "0.03em",
|
|
301
|
-
textShadow: "2px 2px 0 #18181b",
|
|
302
295
|
textTransform: "uppercase",
|
|
303
296
|
arrowSize: "10px",
|
|
304
297
|
arrowWidth: "18px",
|
|
305
|
-
animation: animations.
|
|
298
|
+
animation: animations.pop
|
|
306
299
|
}),
|
|
307
300
|
arcade: createTheme({
|
|
308
301
|
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",
|
|
@@ -516,20 +509,19 @@ var presets = {
|
|
|
516
509
|
animation: animations.blur
|
|
517
510
|
}),
|
|
518
511
|
toxic: createTheme({
|
|
519
|
-
background: "
|
|
512
|
+
background: "linear-gradient(135deg, #bef264, #84cc16)",
|
|
520
513
|
color: "#1a2e05",
|
|
521
514
|
fontFamily: "Arial Black, Impact, sans-serif",
|
|
522
515
|
fontSize: "12px",
|
|
523
516
|
fontWeight: 900,
|
|
524
517
|
border: "3px solid #1a2e05",
|
|
525
|
-
borderRadius: "
|
|
526
|
-
filter: "drop-shadow(4px 5px 0 #365314)",
|
|
518
|
+
borderRadius: "3px 10px 3px 10px",
|
|
527
519
|
padding: "9px 14px",
|
|
528
520
|
letterSpacing: "0.08em",
|
|
529
521
|
textTransform: "uppercase",
|
|
530
522
|
arrowSize: "10px",
|
|
531
523
|
arrowWidth: "20px",
|
|
532
|
-
animation: animations.
|
|
524
|
+
animation: animations.pop
|
|
533
525
|
}),
|
|
534
526
|
radioactive: createTheme({
|
|
535
527
|
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%)",
|
|
@@ -549,20 +541,18 @@ var presets = {
|
|
|
549
541
|
animation: animations.zoom
|
|
550
542
|
}),
|
|
551
543
|
hazard: createTheme({
|
|
552
|
-
background: "
|
|
544
|
+
background: "linear-gradient(135deg, #fb923c, #ea580c)",
|
|
553
545
|
color: "#ffffff",
|
|
554
546
|
fontFamily: "Arial Black, Impact, sans-serif",
|
|
555
547
|
fontSize: "12px",
|
|
556
548
|
fontWeight: 900,
|
|
557
549
|
border: "3px solid #18181b",
|
|
558
550
|
borderRadius: "4px",
|
|
559
|
-
filter: "drop-shadow(5px 5px 0 rgba(24, 24, 27, 0.6))",
|
|
560
551
|
padding: "9px 15px",
|
|
561
|
-
textShadow: "2px 2px 0 #18181b, -1px -1px 0 #18181b",
|
|
562
552
|
textTransform: "uppercase",
|
|
563
553
|
arrowSize: "10px",
|
|
564
554
|
arrowWidth: "20px",
|
|
565
|
-
animation: animations.
|
|
555
|
+
animation: animations.pop
|
|
566
556
|
}),
|
|
567
557
|
policeTape: createTheme({
|
|
568
558
|
background: "repeating-linear-gradient(135deg, #f8fafc 0, #f8fafc 11px, #2563eb 11px, #2563eb 22px)",
|
|
@@ -680,21 +670,20 @@ var presets = {
|
|
|
680
670
|
animation: animations.slide
|
|
681
671
|
}),
|
|
682
672
|
dossier: createTheme({
|
|
683
|
-
background: "linear-gradient(
|
|
673
|
+
background: "linear-gradient(180deg, #f2e5c8, #dfc99f)",
|
|
684
674
|
color: "#3f2d1d",
|
|
685
675
|
fontFamily: "Courier New, monospace",
|
|
686
676
|
fontSize: "11px",
|
|
687
677
|
fontWeight: 800,
|
|
688
678
|
border: "2px solid #92400e",
|
|
689
|
-
borderRadius: "
|
|
690
|
-
filter: "drop-shadow(5px 7px 0 rgba(120, 53, 15, 0.35))",
|
|
679
|
+
borderRadius: "2px 7px 2px 7px",
|
|
691
680
|
padding: "11px 16px",
|
|
692
681
|
letterSpacing: "0.08em",
|
|
693
682
|
textTransform: "uppercase",
|
|
694
683
|
textAlign: "left",
|
|
695
684
|
arrowSize: "8px",
|
|
696
685
|
arrowWidth: "17px",
|
|
697
|
-
animation: animations.
|
|
686
|
+
animation: animations.soft
|
|
698
687
|
}),
|
|
699
688
|
medical: createTheme({
|
|
700
689
|
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",
|
|
@@ -730,20 +719,18 @@ var presets = {
|
|
|
730
719
|
}
|
|
731
720
|
}),
|
|
732
721
|
circuit: createTheme({
|
|
733
|
-
background: "linear-gradient(
|
|
722
|
+
background: "linear-gradient(135deg, #052e16, #022c22)",
|
|
734
723
|
color: "#bbf7d0",
|
|
735
724
|
fontFamily: "Consolas, monospace",
|
|
736
725
|
fontSize: "11px",
|
|
737
726
|
fontWeight: 700,
|
|
738
727
|
border: "2px solid #22c55e",
|
|
739
728
|
borderRadius: "5px",
|
|
740
|
-
filter: "drop-shadow(0 0 7px rgba(34, 197, 94, 0.55))",
|
|
741
729
|
padding: "9px 14px",
|
|
742
730
|
letterSpacing: "0.05em",
|
|
743
|
-
textShadow: "0 0 4px rgba(34, 197, 94, 0.75)",
|
|
744
731
|
arrowSize: "8px",
|
|
745
732
|
arrowWidth: "16px",
|
|
746
|
-
animation: animations.
|
|
733
|
+
animation: animations.soft
|
|
747
734
|
}),
|
|
748
735
|
galaxy: createTheme({
|
|
749
736
|
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",
|
|
@@ -919,27 +906,24 @@ var presets = {
|
|
|
919
906
|
fontWeight: 900,
|
|
920
907
|
border: "4px solid #000000",
|
|
921
908
|
borderRadius: "0px",
|
|
922
|
-
filter: "drop-shadow(7px 7px 0 #ef4444)",
|
|
923
909
|
padding: "10px 16px",
|
|
924
910
|
letterSpacing: "-0.03em",
|
|
925
911
|
textTransform: "uppercase",
|
|
926
912
|
textAlign: "left",
|
|
927
913
|
arrowSize: "11px",
|
|
928
914
|
arrowWidth: "19px",
|
|
929
|
-
animation: animations.
|
|
915
|
+
animation: animations.pop
|
|
930
916
|
}),
|
|
931
917
|
chalkboard: createTheme({
|
|
932
|
-
background: "
|
|
918
|
+
background: "linear-gradient(145deg, #183f30, #102a21)",
|
|
933
919
|
color: "#f5f5dc",
|
|
934
920
|
fontFamily: "Comic Sans MS, Chalkboard, cursive",
|
|
935
921
|
fontSize: "13px",
|
|
936
922
|
fontWeight: 600,
|
|
937
923
|
border: "3px solid #8b5e3c",
|
|
938
924
|
borderRadius: "2px",
|
|
939
|
-
filter: "drop-shadow(4px 6px 0 rgba(66, 32, 6, 0.45))",
|
|
940
925
|
padding: "10px 16px",
|
|
941
926
|
letterSpacing: "0.025em",
|
|
942
|
-
textShadow: "0 0 2px rgba(255, 255, 255, 0.55)",
|
|
943
927
|
textAlign: "left",
|
|
944
928
|
arrowSize: "9px",
|
|
945
929
|
arrowWidth: "18px",
|
|
@@ -963,6 +947,63 @@ var INTERACTIVE_RECHECK_INTERVAL = 50;
|
|
|
963
947
|
var TOUCH_MOVE_THRESHOLD = 10;
|
|
964
948
|
var TOUCH_MAX_TAP_DURATION = 600;
|
|
965
949
|
var TOUCH_FOCUS_SUPPRESSION = 700;
|
|
950
|
+
var activeTooltipSession = null;
|
|
951
|
+
var inputModality = "pointer";
|
|
952
|
+
var inputModalitySubscribers = 0;
|
|
953
|
+
var handleGlobalPointerDown = () => {
|
|
954
|
+
inputModality = "pointer";
|
|
955
|
+
};
|
|
956
|
+
var keyboardFocusKeys = /* @__PURE__ */ new Set([
|
|
957
|
+
"Tab",
|
|
958
|
+
"Enter",
|
|
959
|
+
" ",
|
|
960
|
+
"ArrowUp",
|
|
961
|
+
"ArrowDown",
|
|
962
|
+
"ArrowLeft",
|
|
963
|
+
"ArrowRight",
|
|
964
|
+
"Home",
|
|
965
|
+
"End",
|
|
966
|
+
"PageUp",
|
|
967
|
+
"PageDown"
|
|
968
|
+
]);
|
|
969
|
+
var handleGlobalKeyDown = (event) => {
|
|
970
|
+
if (event.metaKey || event.ctrlKey || event.altKey || !keyboardFocusKeys.has(event.key)) {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
inputModality = "keyboard";
|
|
974
|
+
};
|
|
975
|
+
var subscribeInputModality = () => {
|
|
976
|
+
inputModalitySubscribers += 1;
|
|
977
|
+
if (inputModalitySubscribers !== 1) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
document.addEventListener("pointerdown", handleGlobalPointerDown, true);
|
|
981
|
+
document.addEventListener("keydown", handleGlobalKeyDown, true);
|
|
982
|
+
};
|
|
983
|
+
var unsubscribeInputModality = () => {
|
|
984
|
+
inputModalitySubscribers = Math.max(0, inputModalitySubscribers - 1);
|
|
985
|
+
if (inputModalitySubscribers !== 0) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
document.removeEventListener("pointerdown", handleGlobalPointerDown, true);
|
|
989
|
+
document.removeEventListener("keydown", handleGlobalKeyDown, true);
|
|
990
|
+
};
|
|
991
|
+
var requestTooltipActivation = (session, point) => {
|
|
992
|
+
const currentSession = activeTooltipSession;
|
|
993
|
+
if (currentSession && currentSession.owner !== session.owner) {
|
|
994
|
+
if (point && currentSession.interactive && currentSession.protectsPoint(point)) {
|
|
995
|
+
return false;
|
|
996
|
+
}
|
|
997
|
+
currentSession.close();
|
|
998
|
+
}
|
|
999
|
+
activeTooltipSession = session;
|
|
1000
|
+
return true;
|
|
1001
|
+
};
|
|
1002
|
+
var clearTooltipActivation = (owner) => {
|
|
1003
|
+
if (activeTooltipSession?.owner === owner) {
|
|
1004
|
+
activeTooltipSession = null;
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
966
1007
|
var oppositePlacement = {
|
|
967
1008
|
top: "bottom",
|
|
968
1009
|
bottom: "top",
|
|
@@ -1088,6 +1129,7 @@ var useTooltip = ({
|
|
|
1088
1129
|
}) => {
|
|
1089
1130
|
const tooltipRef = (0, import_react.useRef)(null);
|
|
1090
1131
|
const bodyRef = (0, import_react.useRef)(null);
|
|
1132
|
+
const ownerRef = (0, import_react.useRef)(/* @__PURE__ */ Symbol("tooltip"));
|
|
1091
1133
|
const hideTimerRef = (0, import_react.useRef)(null);
|
|
1092
1134
|
const firstFrameRef = (0, import_react.useRef)(null);
|
|
1093
1135
|
const secondFrameRef = (0, import_react.useRef)(null);
|
|
@@ -1100,6 +1142,7 @@ var useTooltip = ({
|
|
|
1100
1142
|
y: Number.NaN,
|
|
1101
1143
|
pointerType: ""
|
|
1102
1144
|
});
|
|
1145
|
+
const interactiveAreaAtPointRef = (0, import_react.useRef)(() => "outside");
|
|
1103
1146
|
const touchGestureRef = (0, import_react.useRef)(null);
|
|
1104
1147
|
const suppressFocusUntilRef = (0, import_react.useRef)(0);
|
|
1105
1148
|
const [mounted, setMounted] = (0, import_react.useState)(false);
|
|
@@ -1238,7 +1281,7 @@ var useTooltip = ({
|
|
|
1238
1281
|
});
|
|
1239
1282
|
}, [anchor, getAvailableSpace, preferredPlacement]);
|
|
1240
1283
|
const isFocusInsideTooltipRegion = (0, import_react.useCallback)(() => {
|
|
1241
|
-
if (!anchor || typeof document === "undefined") {
|
|
1284
|
+
if (!anchor || typeof document === "undefined" || inputModality !== "keyboard") {
|
|
1242
1285
|
return false;
|
|
1243
1286
|
}
|
|
1244
1287
|
const activeElement = document.activeElement;
|
|
@@ -1246,50 +1289,60 @@ var useTooltip = ({
|
|
|
1246
1289
|
if (!(activeElement instanceof Node)) {
|
|
1247
1290
|
return false;
|
|
1248
1291
|
}
|
|
1249
|
-
|
|
1250
|
-
return true;
|
|
1251
|
-
}
|
|
1252
|
-
return anchor.contains(activeElement) && activeElement instanceof Element && activeElement.matches(":focus-visible");
|
|
1292
|
+
return anchor.contains(activeElement) || Boolean(interactive && tooltip?.contains(activeElement));
|
|
1253
1293
|
}, [anchor, interactive]);
|
|
1294
|
+
const getInteractivePointerAreaAtPoint = (0, import_react.useCallback)(
|
|
1295
|
+
(point) => {
|
|
1296
|
+
if (!interactive || !anchor) {
|
|
1297
|
+
return "outside";
|
|
1298
|
+
}
|
|
1299
|
+
const tooltip = tooltipRef.current;
|
|
1300
|
+
if (!tooltip || !Number.isFinite(point.x) || !Number.isFinite(point.y)) {
|
|
1301
|
+
return "outside";
|
|
1302
|
+
}
|
|
1303
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
1304
|
+
const tooltipRect = tooltip.getBoundingClientRect();
|
|
1305
|
+
if (isPointInsideRect(
|
|
1306
|
+
point,
|
|
1307
|
+
anchorRect,
|
|
1308
|
+
INTERACTIVE_DIRECT_PADDING
|
|
1309
|
+
) || isPointInsideRect(
|
|
1310
|
+
point,
|
|
1311
|
+
tooltipRect,
|
|
1312
|
+
INTERACTIVE_DIRECT_PADDING
|
|
1313
|
+
)) {
|
|
1314
|
+
return "direct";
|
|
1315
|
+
}
|
|
1316
|
+
const bridge = createInteractiveBridge(
|
|
1317
|
+
anchorRect,
|
|
1318
|
+
tooltipRect,
|
|
1319
|
+
placement
|
|
1320
|
+
);
|
|
1321
|
+
return isPointInsidePolygon(point, bridge) ? "bridge" : "outside";
|
|
1322
|
+
},
|
|
1323
|
+
[anchor, interactive, placement]
|
|
1324
|
+
);
|
|
1325
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
1326
|
+
interactiveAreaAtPointRef.current = getInteractivePointerAreaAtPoint;
|
|
1327
|
+
}, [getInteractivePointerAreaAtPoint]);
|
|
1254
1328
|
const getInteractivePointerArea = (0, import_react.useCallback)(() => {
|
|
1255
|
-
if (!interactive || !anchor) {
|
|
1256
|
-
return "outside";
|
|
1257
|
-
}
|
|
1258
1329
|
const pointer = pointerRef.current;
|
|
1259
|
-
|
|
1260
|
-
if (!tooltip || pointer.pointerType !== "mouse" && pointer.pointerType !== "pen" || !Number.isFinite(pointer.x) || !Number.isFinite(pointer.y)) {
|
|
1330
|
+
if (pointer.pointerType !== "mouse" && pointer.pointerType !== "pen" || !Number.isFinite(pointer.x) || !Number.isFinite(pointer.y)) {
|
|
1261
1331
|
return "outside";
|
|
1262
1332
|
}
|
|
1263
|
-
|
|
1333
|
+
return getInteractivePointerAreaAtPoint({
|
|
1264
1334
|
x: pointer.x,
|
|
1265
1335
|
y: pointer.y
|
|
1266
|
-
};
|
|
1267
|
-
|
|
1268
|
-
const tooltipRect = tooltip.getBoundingClientRect();
|
|
1269
|
-
if (isPointInsideRect(
|
|
1270
|
-
point,
|
|
1271
|
-
anchorRect,
|
|
1272
|
-
INTERACTIVE_DIRECT_PADDING
|
|
1273
|
-
) || isPointInsideRect(
|
|
1274
|
-
point,
|
|
1275
|
-
tooltipRect,
|
|
1276
|
-
INTERACTIVE_DIRECT_PADDING
|
|
1277
|
-
)) {
|
|
1278
|
-
return "direct";
|
|
1279
|
-
}
|
|
1280
|
-
const bridge = createInteractiveBridge(
|
|
1281
|
-
anchorRect,
|
|
1282
|
-
tooltipRect,
|
|
1283
|
-
placement
|
|
1284
|
-
);
|
|
1285
|
-
return isPointInsidePolygon(point, bridge) ? "bridge" : "outside";
|
|
1286
|
-
}, [anchor, interactive, placement]);
|
|
1336
|
+
});
|
|
1337
|
+
}, [getInteractivePointerAreaAtPoint]);
|
|
1287
1338
|
const removeTooltip = (0, import_react.useCallback)(() => {
|
|
1288
1339
|
clearHideTimer();
|
|
1289
1340
|
clearEnterFrames();
|
|
1290
1341
|
clearInteractiveFrame();
|
|
1291
1342
|
pendingHideRef.current = false;
|
|
1292
1343
|
interactiveBridgeDeadlineRef.current = 0;
|
|
1344
|
+
clearTooltipActivation(ownerRef.current);
|
|
1345
|
+
setMounted(false);
|
|
1293
1346
|
updatePhase("hidden");
|
|
1294
1347
|
}, [clearEnterFrames, clearHideTimer, clearInteractiveFrame, updatePhase]);
|
|
1295
1348
|
const runHide = (0, import_react.useCallback)(() => {
|
|
@@ -1365,21 +1418,51 @@ var useTooltip = ({
|
|
|
1365
1418
|
runHide
|
|
1366
1419
|
]
|
|
1367
1420
|
);
|
|
1368
|
-
const showTooltip = (0, import_react.useCallback)(
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1421
|
+
const showTooltip = (0, import_react.useCallback)(
|
|
1422
|
+
(activationPoint) => {
|
|
1423
|
+
if (!anchor || disabled) {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
const activated = requestTooltipActivation(
|
|
1427
|
+
{
|
|
1428
|
+
owner: ownerRef.current,
|
|
1429
|
+
interactive,
|
|
1430
|
+
protectsPoint: (point) => {
|
|
1431
|
+
if (phaseRef.current === "hidden") {
|
|
1432
|
+
return false;
|
|
1433
|
+
}
|
|
1434
|
+
return interactiveAreaAtPointRef.current(point) !== "outside";
|
|
1435
|
+
},
|
|
1436
|
+
close: () => {
|
|
1437
|
+
hideTooltip(true);
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
activationPoint
|
|
1441
|
+
);
|
|
1442
|
+
if (!activated) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
clearHideTimer();
|
|
1446
|
+
clearEnterFrames();
|
|
1447
|
+
interactiveBridgeDeadlineRef.current = 0;
|
|
1448
|
+
pendingHideRef.current = false;
|
|
1449
|
+
setMounted(true);
|
|
1450
|
+
if (phaseRef.current === "entering" || phaseRef.current === "visible") {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
updatePhase("preparing");
|
|
1454
|
+
setShowVersion((value) => value + 1);
|
|
1455
|
+
},
|
|
1456
|
+
[
|
|
1457
|
+
anchor,
|
|
1458
|
+
clearEnterFrames,
|
|
1459
|
+
clearHideTimer,
|
|
1460
|
+
disabled,
|
|
1461
|
+
hideTooltip,
|
|
1462
|
+
interactive,
|
|
1463
|
+
updatePhase
|
|
1464
|
+
]
|
|
1465
|
+
);
|
|
1383
1466
|
const keepTooltipOpen = (0, import_react.useCallback)(() => {
|
|
1384
1467
|
if (!interactive || disabled) {
|
|
1385
1468
|
return;
|
|
@@ -1469,6 +1552,13 @@ var useTooltip = ({
|
|
|
1469
1552
|
showVersion,
|
|
1470
1553
|
updatePhase
|
|
1471
1554
|
]);
|
|
1555
|
+
(0, import_react.useEffect)(() => {
|
|
1556
|
+
subscribeInputModality();
|
|
1557
|
+
return () => {
|
|
1558
|
+
unsubscribeInputModality();
|
|
1559
|
+
clearTooltipActivation(ownerRef.current);
|
|
1560
|
+
};
|
|
1561
|
+
}, []);
|
|
1472
1562
|
(0, import_react.useEffect)(() => {
|
|
1473
1563
|
if (!anchor) {
|
|
1474
1564
|
removeTooltip();
|
|
@@ -1486,7 +1576,10 @@ var useTooltip = ({
|
|
|
1486
1576
|
if (event.pointerType === "touch") {
|
|
1487
1577
|
return;
|
|
1488
1578
|
}
|
|
1489
|
-
showTooltip(
|
|
1579
|
+
showTooltip({
|
|
1580
|
+
x: event.clientX,
|
|
1581
|
+
y: event.clientY
|
|
1582
|
+
});
|
|
1490
1583
|
};
|
|
1491
1584
|
const onPointerLeave = (event) => {
|
|
1492
1585
|
updatePointer(event);
|
|
@@ -1558,7 +1651,10 @@ var useTooltip = ({
|
|
|
1558
1651
|
return;
|
|
1559
1652
|
}
|
|
1560
1653
|
if (phaseRef.current === "hidden" || phaseRef.current === "leaving") {
|
|
1561
|
-
showTooltip(
|
|
1654
|
+
showTooltip({
|
|
1655
|
+
x: event.clientX,
|
|
1656
|
+
y: event.clientY
|
|
1657
|
+
});
|
|
1562
1658
|
} else {
|
|
1563
1659
|
hideTooltip(true);
|
|
1564
1660
|
}
|
|
@@ -1655,7 +1751,9 @@ var useTooltip = ({
|
|
|
1655
1751
|
scheduleInteractivePointerProcessing();
|
|
1656
1752
|
};
|
|
1657
1753
|
const onFocusIn = () => {
|
|
1658
|
-
|
|
1754
|
+
if (inputModality === "keyboard") {
|
|
1755
|
+
keepTooltipOpen();
|
|
1756
|
+
}
|
|
1659
1757
|
};
|
|
1660
1758
|
const onFocusOut = (event) => {
|
|
1661
1759
|
const relatedTarget = event.relatedTarget;
|