@tent-official/react-walkthrough 1.1.102 → 1.2.0
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.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +53 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -607,7 +607,7 @@ var WalkthroughOverlay = ({
|
|
|
607
607
|
prevColor,
|
|
608
608
|
skipColor
|
|
609
609
|
} = {}) => {
|
|
610
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
610
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
611
611
|
injectKeyframes();
|
|
612
612
|
const { activeTour } = useGlobalState();
|
|
613
613
|
const instanceIdRef = useRef(null);
|
|
@@ -909,9 +909,9 @@ var WalkthroughOverlay = ({
|
|
|
909
909
|
const totalSteps = validSteps.length;
|
|
910
910
|
const isLast = currentValidPos === totalSteps - 1;
|
|
911
911
|
const stepOffset = (_c = activeTour.displayStepOffset) != null ? _c : 0;
|
|
912
|
-
const displayCurrentStep = currentValidPos + 1 + stepOffset;
|
|
913
|
-
const displayTotalSteps = (
|
|
914
|
-
const borderRadius = (
|
|
912
|
+
const displayCurrentStep = (_d = step.displayStep) != null ? _d : currentValidPos + 1 + stepOffset;
|
|
913
|
+
const displayTotalSteps = (_f = (_e = step.displayTotal) != null ? _e : activeTour.displayTotal) != null ? _f : totalSteps;
|
|
914
|
+
const borderRadius = (_g = step.borderRadius) != null ? _g : 10;
|
|
915
915
|
const {
|
|
916
916
|
isShowSkip = true,
|
|
917
917
|
isShowPrev = true,
|
|
@@ -921,9 +921,9 @@ var WalkthroughOverlay = ({
|
|
|
921
921
|
skipLabel: tourSkipLabel = "Skip",
|
|
922
922
|
doneLabel = "Done"
|
|
923
923
|
} = activeTour;
|
|
924
|
-
const nextLabel = (
|
|
925
|
-
const prevLabel = (
|
|
926
|
-
const skipLabel = (
|
|
924
|
+
const nextLabel = (_h = step.nextLabel) != null ? _h : tourNextLabel;
|
|
925
|
+
const prevLabel = (_i = step.prevLabel) != null ? _i : tourPrevLabel;
|
|
926
|
+
const skipLabel = (_j = step.skipLabel) != null ? _j : tourSkipLabel;
|
|
927
927
|
const advanceStep = (hasTrigger) => {
|
|
928
928
|
var _a2;
|
|
929
929
|
const currentOrigIdx = validSteps[currentValidPos]._originalIdx;
|
|
@@ -937,6 +937,43 @@ var WalkthroughOverlay = ({
|
|
|
937
937
|
setPopoverPos(null);
|
|
938
938
|
const nextValidStep = validSteps[currentValidPos + 1];
|
|
939
939
|
const nextOrigIdx = hasTrigger && !nextValidStep ? currentOrigIdx + 1 : (_a2 = nextValidStep == null ? void 0 : nextValidStep._originalIdx) != null ? _a2 : currentOrigIdx + 1;
|
|
940
|
+
const shouldForceRecompute = !!step.forceRecompute;
|
|
941
|
+
if (shouldForceRecompute) {
|
|
942
|
+
const nextStepDef = activeTour.steps[nextOrigIdx];
|
|
943
|
+
if (nextStepDef) {
|
|
944
|
+
const nextElId = resolveElId(nextStepDef.el);
|
|
945
|
+
const SETTLE_DELAY = 150;
|
|
946
|
+
const doAdvance = () => {
|
|
947
|
+
setGlobalState((s) => ({
|
|
948
|
+
...s,
|
|
949
|
+
activeTour: { ...s.activeTour, currentStep: nextOrigIdx }
|
|
950
|
+
}));
|
|
951
|
+
};
|
|
952
|
+
const alreadyExists = document.getElementById(nextElId);
|
|
953
|
+
if (alreadyExists) {
|
|
954
|
+
setTimeout(() => doAdvance(), SETTLE_DELAY);
|
|
955
|
+
} else {
|
|
956
|
+
waitingForElsRef.current = true;
|
|
957
|
+
const observer = new MutationObserver(() => {
|
|
958
|
+
const found = document.getElementById(nextElId);
|
|
959
|
+
if (found) {
|
|
960
|
+
observer.disconnect();
|
|
961
|
+
waitingForElsRef.current = false;
|
|
962
|
+
setTimeout(() => doAdvance(), SETTLE_DELAY);
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
966
|
+
setTimeout(() => {
|
|
967
|
+
observer.disconnect();
|
|
968
|
+
if (waitingForElsRef.current) {
|
|
969
|
+
waitingForElsRef.current = false;
|
|
970
|
+
doAdvance();
|
|
971
|
+
}
|
|
972
|
+
}, 3e3);
|
|
973
|
+
}
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
940
977
|
setGlobalState((s) => ({
|
|
941
978
|
...s,
|
|
942
979
|
activeTour: { ...s.activeTour, currentStep: nextOrigIdx }
|
|
@@ -966,7 +1003,9 @@ var WalkthroughOverlay = ({
|
|
|
966
1003
|
const alreadyInValid = validSteps.some((s) => s._originalIdx === nextOrigIdx);
|
|
967
1004
|
const newValidSteps = alreadyInValid ? validSteps : [...validSteps, nextStepWithIdx].sort((a, b) => a._originalIdx - b._originalIdx);
|
|
968
1005
|
setValidSteps(newValidSteps);
|
|
969
|
-
|
|
1006
|
+
if (!step.forceRecompute) {
|
|
1007
|
+
skipNextRecomputeRef.current = true;
|
|
1008
|
+
}
|
|
970
1009
|
setGlobalState((s) => ({
|
|
971
1010
|
...s,
|
|
972
1011
|
activeTour: { ...s.activeTour, currentStep: nextOrigIdx }
|
|
@@ -1041,10 +1080,10 @@ var WalkthroughOverlay = ({
|
|
|
1041
1080
|
displayPosRef.current = currentValidPos;
|
|
1042
1081
|
}
|
|
1043
1082
|
const ds = displayStepRef.current;
|
|
1044
|
-
const dir = (
|
|
1045
|
-
const align = (
|
|
1046
|
-
const offsetX = (
|
|
1047
|
-
const offsetY = (
|
|
1083
|
+
const dir = (_k = popoverPos == null ? void 0 : popoverPos.dir) != null ? _k : "bottom";
|
|
1084
|
+
const align = (_l = popoverPos == null ? void 0 : popoverPos.align) != null ? _l : "start";
|
|
1085
|
+
const offsetX = (_m = popoverPos == null ? void 0 : popoverPos.offsetX) != null ? _m : 0;
|
|
1086
|
+
const offsetY = (_n = popoverPos == null ? void 0 : popoverPos.offsetY) != null ? _n : 0;
|
|
1048
1087
|
const anchorStyle = popoverReady ? {
|
|
1049
1088
|
position: "fixed",
|
|
1050
1089
|
top: rect.top,
|
|
@@ -1138,7 +1177,7 @@ var WalkthroughOverlay = ({
|
|
|
1138
1177
|
/* @__PURE__ */ jsxs(PopoverBody, { children: [
|
|
1139
1178
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "row", justifyContent: "space-between" }, children: [
|
|
1140
1179
|
pStep.title ? /* @__PURE__ */ jsx(PopoverTitle, { children: pStep.title }) : "",
|
|
1141
|
-
((
|
|
1180
|
+
((_o = pStep.isShowStep) != null ? _o : pIsShowStep) && /* @__PURE__ */ jsxs("span", { style: { color: "#a1a1aa", fontSize: "12px", fontWeight: "400" }, children: [
|
|
1142
1181
|
pDisplayCurrentStep,
|
|
1143
1182
|
"/",
|
|
1144
1183
|
pDisplayTotalSteps
|
|
@@ -1163,7 +1202,7 @@ var WalkthroughOverlay = ({
|
|
|
1163
1202
|
}
|
|
1164
1203
|
) }),
|
|
1165
1204
|
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
1166
|
-
((
|
|
1205
|
+
((_p = pStep.isShowPrev) != null ? _p : pIsShowPrev) && pCurrentValidPos > 0 && /* @__PURE__ */ jsx(
|
|
1167
1206
|
"button",
|
|
1168
1207
|
{
|
|
1169
1208
|
className: "wt-btn",
|