@tent-official/react-walkthrough 1.3.5 → 1.4.1
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 +18 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -529,7 +529,11 @@ var clampSize = (value, max) => {
|
|
|
529
529
|
return clamped;
|
|
530
530
|
};
|
|
531
531
|
var EDGE_MARGIN = 8;
|
|
532
|
+
var INNER_INSET = 12;
|
|
532
533
|
var choosePopoverDir = (rect, popoverW, popoverH, gap, preferred) => {
|
|
534
|
+
if (preferred && preferred.startsWith("inner-")) {
|
|
535
|
+
return { dir: preferred, align: "start", offsetX: 0, offsetY: 0 };
|
|
536
|
+
}
|
|
533
537
|
const vw = window.innerWidth;
|
|
534
538
|
const vh = window.innerHeight;
|
|
535
539
|
const space = {
|
|
@@ -1005,13 +1009,21 @@ var WalkthroughOverlay = ({
|
|
|
1005
1009
|
}
|
|
1006
1010
|
};
|
|
1007
1011
|
const next = () => {
|
|
1008
|
-
var _a2;
|
|
1012
|
+
var _a2, _b2;
|
|
1009
1013
|
const currentOrigIdx = validSteps[currentValidPos]._originalIdx;
|
|
1010
1014
|
const stepNextCb = (_a2 = activeTour.onStepNext) == null ? void 0 : _a2[currentOrigIdx];
|
|
1011
1015
|
if (typeof stepNextCb === "function") {
|
|
1012
1016
|
stepNextCb();
|
|
1013
1017
|
}
|
|
1014
1018
|
const hasTrigger = !!step.triggerElOnNext;
|
|
1019
|
+
const afterNextDelay = (_b2 = step.delayAfterNext) != null ? _b2 : 0;
|
|
1020
|
+
const withDelay = (fn) => {
|
|
1021
|
+
if (afterNextDelay > 0) {
|
|
1022
|
+
setTimeout(fn, afterNextDelay);
|
|
1023
|
+
} else {
|
|
1024
|
+
fn();
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1015
1027
|
if (hasTrigger) {
|
|
1016
1028
|
setPopoverHidden(true);
|
|
1017
1029
|
setPopoverPos(null);
|
|
@@ -1044,7 +1056,7 @@ var WalkthroughOverlay = ({
|
|
|
1044
1056
|
const SETTLE_DELAY = 150;
|
|
1045
1057
|
const alreadyExists = document.getElementById(nextElId);
|
|
1046
1058
|
if (alreadyExists) {
|
|
1047
|
-
setTimeout(() => injectAndAdvance(), SETTLE_DELAY);
|
|
1059
|
+
withDelay(() => setTimeout(() => injectAndAdvance(), SETTLE_DELAY));
|
|
1048
1060
|
} else {
|
|
1049
1061
|
waitingForElsRef.current = true;
|
|
1050
1062
|
const observer = new MutationObserver(() => {
|
|
@@ -1052,7 +1064,7 @@ var WalkthroughOverlay = ({
|
|
|
1052
1064
|
if (found) {
|
|
1053
1065
|
observer.disconnect();
|
|
1054
1066
|
waitingForElsRef.current = false;
|
|
1055
|
-
setTimeout(() => injectAndAdvance(), SETTLE_DELAY);
|
|
1067
|
+
withDelay(() => setTimeout(() => injectAndAdvance(), SETTLE_DELAY));
|
|
1056
1068
|
}
|
|
1057
1069
|
});
|
|
1058
1070
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
@@ -1060,7 +1072,7 @@ var WalkthroughOverlay = ({
|
|
|
1060
1072
|
observer.disconnect();
|
|
1061
1073
|
if (waitingForElsRef.current) {
|
|
1062
1074
|
waitingForElsRef.current = false;
|
|
1063
|
-
advanceStep(hasTrigger);
|
|
1075
|
+
withDelay(() => advanceStep(hasTrigger));
|
|
1064
1076
|
}
|
|
1065
1077
|
}, 3e3);
|
|
1066
1078
|
}
|
|
@@ -1071,7 +1083,13 @@ var WalkthroughOverlay = ({
|
|
|
1071
1083
|
setTimeout(() => completeTour(), 300);
|
|
1072
1084
|
return;
|
|
1073
1085
|
}
|
|
1074
|
-
|
|
1086
|
+
if (afterNextDelay > 0) {
|
|
1087
|
+
setPopoverHidden(true);
|
|
1088
|
+
setPopoverPos(null);
|
|
1089
|
+
withDelay(() => advanceStep(hasTrigger));
|
|
1090
|
+
} else {
|
|
1091
|
+
advanceStep(hasTrigger);
|
|
1092
|
+
}
|
|
1075
1093
|
};
|
|
1076
1094
|
const prev = () => {
|
|
1077
1095
|
var _a2;
|
|
@@ -1141,7 +1159,12 @@ var WalkthroughOverlay = ({
|
|
|
1141
1159
|
bottom: { top: `calc(100% + ${$popoverGap}px)`, ...hAlign },
|
|
1142
1160
|
top: { bottom: `calc(100% + ${$popoverGap}px)`, ...hAlign },
|
|
1143
1161
|
right: { left: `calc(100% + ${$popoverGap}px)`, ...vAlign },
|
|
1144
|
-
left: { right: `calc(100% + ${$popoverGap}px)`, ...vAlign }
|
|
1162
|
+
left: { right: `calc(100% + ${$popoverGap}px)`, ...vAlign },
|
|
1163
|
+
// inner-* : popover sits INSIDE the highlight rect, inset 12px from the edge
|
|
1164
|
+
"inner-bottom": { bottom: INNER_INSET, right: INNER_INSET },
|
|
1165
|
+
"inner-top": { top: INNER_INSET, right: INNER_INSET },
|
|
1166
|
+
"inner-left": { left: INNER_INSET, bottom: INNER_INSET },
|
|
1167
|
+
"inner-right": { right: INNER_INSET, bottom: INNER_INSET }
|
|
1145
1168
|
};
|
|
1146
1169
|
const maxHeightStyle = (popoverPos == null ? void 0 : popoverPos.maxHeight) != null ? { maxHeight: popoverPos.maxHeight, overflowY: "auto" } : {};
|
|
1147
1170
|
const popoverStyle = popoverReady ? {
|