@tent-official/react-walkthrough 1.1.78 → 1.1.80
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 +72 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -565,7 +565,7 @@ var WalkthroughOverlay = ({
|
|
|
565
565
|
prevColor,
|
|
566
566
|
skipColor
|
|
567
567
|
} = {}) => {
|
|
568
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
568
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
569
569
|
injectKeyframes();
|
|
570
570
|
const { activeTour } = useGlobalState();
|
|
571
571
|
const instanceIdRef = useRef(null);
|
|
@@ -589,94 +589,99 @@ var WalkthroughOverlay = ({
|
|
|
589
589
|
const [popoverHidden, setPopoverHidden] = useState(false);
|
|
590
590
|
const displayStepRef = useRef(null);
|
|
591
591
|
const displayPosRef = useRef(null);
|
|
592
|
-
const
|
|
592
|
+
const [validSteps, setValidSteps] = useState([]);
|
|
593
593
|
const [isDelaying, setIsDelaying] = useState(false);
|
|
594
|
-
const
|
|
594
|
+
const waitingForElsRef = useRef(false);
|
|
595
|
+
const delayDoneForRef = useRef(null);
|
|
595
596
|
useEffect(() => {
|
|
596
597
|
var _a2;
|
|
597
598
|
if (!activeTour) {
|
|
598
|
-
delayDoneForRef.current = null;
|
|
599
|
-
setIsDelaying(false);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
if (delayDoneForRef.current === activeTour.name) return;
|
|
603
|
-
const ms = (_a2 = activeTour.delay) != null ? _a2 : 0;
|
|
604
|
-
if (ms <= 0) {
|
|
605
|
-
delayDoneForRef.current = activeTour.name;
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
setIsDelaying(true);
|
|
609
|
-
const timer = setTimeout(() => {
|
|
610
|
-
delayDoneForRef.current = activeTour.name;
|
|
611
|
-
setIsDelaying(false);
|
|
612
|
-
}, ms);
|
|
613
|
-
return () => clearTimeout(timer);
|
|
614
|
-
}, [currentTourName, activeTour]);
|
|
615
|
-
const [validSteps, setValidSteps] = useState([]);
|
|
616
|
-
const waitingForElsRef = useRef(false);
|
|
617
|
-
useEffect(() => {
|
|
618
|
-
var _a2, _b2, _c2;
|
|
619
|
-
if (!activeTour || isDelaying) {
|
|
620
599
|
setValidSteps([]);
|
|
600
|
+
setIsDelaying(false);
|
|
621
601
|
waitingForElsRef.current = false;
|
|
602
|
+
delayDoneForRef.current = null;
|
|
622
603
|
return;
|
|
623
604
|
}
|
|
624
|
-
|
|
605
|
+
let cancelled = false;
|
|
625
606
|
const abortController = new AbortController();
|
|
626
607
|
const compute = () => activeTour.steps.map((s, i) => ({ ...s, _originalIdx: i })).filter((s) => document.getElementById(resolveElId(s.el)));
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
608
|
+
const readElements = () => {
|
|
609
|
+
var _a3, _b2, _c2;
|
|
610
|
+
if (cancelled) return;
|
|
611
|
+
waitingForElsRef.current = true;
|
|
612
|
+
const found = compute();
|
|
613
|
+
if (found.length > 0) {
|
|
614
|
+
const currentStepIdx = (_a3 = activeTour.currentStep) != null ? _a3 : 0;
|
|
615
|
+
const currentStepInFound = found.some((s) => s._originalIdx === currentStepIdx);
|
|
616
|
+
if (currentStepInFound) {
|
|
617
|
+
setValidSteps(found);
|
|
618
|
+
waitingForElsRef.current = false;
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
632
621
|
setValidSteps(found);
|
|
633
|
-
|
|
622
|
+
const currentStepEl = (_b2 = activeTour.steps[currentStepIdx]) == null ? void 0 : _b2.el;
|
|
623
|
+
if (!currentStepEl) {
|
|
624
|
+
waitingForElsRef.current = false;
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
readElement(currentStepEl, { signal: abortController.signal }).then((el) => {
|
|
628
|
+
if (el && !cancelled) {
|
|
629
|
+
waitingForElsRef.current = false;
|
|
630
|
+
setValidSteps(compute());
|
|
631
|
+
}
|
|
632
|
+
});
|
|
634
633
|
return;
|
|
635
634
|
}
|
|
636
|
-
setValidSteps(
|
|
637
|
-
const
|
|
638
|
-
if (!
|
|
635
|
+
setValidSteps([]);
|
|
636
|
+
const firstStepEl = (_c2 = activeTour.steps[0]) == null ? void 0 : _c2.el;
|
|
637
|
+
if (!firstStepEl) {
|
|
639
638
|
waitingForElsRef.current = false;
|
|
640
639
|
return;
|
|
641
640
|
}
|
|
642
|
-
readElement(
|
|
643
|
-
if (el && !
|
|
644
|
-
|
|
645
|
-
|
|
641
|
+
readElement(firstStepEl, { signal: abortController.signal }).then((el) => {
|
|
642
|
+
if (el && !cancelled) {
|
|
643
|
+
const updated = compute();
|
|
644
|
+
if (updated.length > 0) {
|
|
645
|
+
waitingForElsRef.current = false;
|
|
646
|
+
setValidSteps(updated);
|
|
647
|
+
}
|
|
646
648
|
}
|
|
647
649
|
});
|
|
650
|
+
};
|
|
651
|
+
const needsDelay = delayDoneForRef.current !== activeTour.name && ((_a2 = activeTour.delay) != null ? _a2 : 0) > 0;
|
|
652
|
+
if (needsDelay) {
|
|
653
|
+
setIsDelaying(true);
|
|
654
|
+
setValidSteps([]);
|
|
655
|
+
waitingForElsRef.current = true;
|
|
656
|
+
const timer = setTimeout(() => {
|
|
657
|
+
if (cancelled) return;
|
|
658
|
+
delayDoneForRef.current = activeTour.name;
|
|
659
|
+
setIsDelaying(false);
|
|
660
|
+
readElements();
|
|
661
|
+
}, activeTour.delay);
|
|
648
662
|
return () => {
|
|
663
|
+
cancelled = true;
|
|
664
|
+
clearTimeout(timer);
|
|
649
665
|
abortController.abort();
|
|
650
666
|
waitingForElsRef.current = false;
|
|
651
667
|
};
|
|
652
668
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
waitingForElsRef.current = false;
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
readElement(firstStepEl, { signal: abortController.signal }).then((el) => {
|
|
660
|
-
if (el && !abortController.signal.aborted) {
|
|
661
|
-
const updated = compute();
|
|
662
|
-
if (updated.length > 0) {
|
|
663
|
-
waitingForElsRef.current = false;
|
|
664
|
-
setValidSteps(updated);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
});
|
|
669
|
+
delayDoneForRef.current = activeTour.name;
|
|
670
|
+
setIsDelaying(false);
|
|
671
|
+
readElements();
|
|
668
672
|
return () => {
|
|
673
|
+
cancelled = true;
|
|
669
674
|
abortController.abort();
|
|
670
675
|
waitingForElsRef.current = false;
|
|
671
676
|
};
|
|
672
|
-
}, [activeTour
|
|
673
|
-
const currentOriginalIdx = (
|
|
677
|
+
}, [activeTour]);
|
|
678
|
+
const currentOriginalIdx = (_a = activeTour == null ? void 0 : activeTour.currentStep) != null ? _a : 0;
|
|
674
679
|
const currentValidPos = validSteps.findIndex(
|
|
675
680
|
(s) => s._originalIdx === currentOriginalIdx
|
|
676
681
|
);
|
|
677
682
|
const rawStep = currentValidPos !== -1 ? validSteps[currentValidPos] : null;
|
|
678
683
|
const step = isDelaying ? null : rawStep;
|
|
679
|
-
const tourAnimationSpeed = (
|
|
684
|
+
const tourAnimationSpeed = (_b = activeTour == null ? void 0 : activeTour.animationSpeed) != null ? _b : 350;
|
|
680
685
|
const { rect, isAnimating } = useAnimatedRect(step, tourAnimationSpeed, activeTour == null ? void 0 : activeTour.containerElement, !!activeTour, activeTour == null ? void 0 : activeTour.name);
|
|
681
686
|
const completeTour = useCallback(() => {
|
|
682
687
|
if (!activeTour) return;
|
|
@@ -687,6 +692,7 @@ var WalkthroughOverlay = ({
|
|
|
687
692
|
}, [activeTour, rect]);
|
|
688
693
|
useEffect(() => {
|
|
689
694
|
if (!activeTour) return;
|
|
695
|
+
if (isDelaying) return;
|
|
690
696
|
if (currentValidPos !== -1) return;
|
|
691
697
|
if (waitingForElsRef.current) return;
|
|
692
698
|
if (validSteps.length === 0) {
|
|
@@ -706,6 +712,7 @@ var WalkthroughOverlay = ({
|
|
|
706
712
|
}
|
|
707
713
|
}, [
|
|
708
714
|
activeTour,
|
|
715
|
+
isDelaying,
|
|
709
716
|
currentValidPos,
|
|
710
717
|
currentOriginalIdx,
|
|
711
718
|
validSteps,
|
|
@@ -842,10 +849,10 @@ var WalkthroughOverlay = ({
|
|
|
842
849
|
}
|
|
843
850
|
const totalSteps = validSteps.length;
|
|
844
851
|
const isLast = currentValidPos === totalSteps - 1;
|
|
845
|
-
const stepOffset = (
|
|
852
|
+
const stepOffset = (_c = activeTour.displayStepOffset) != null ? _c : 0;
|
|
846
853
|
const displayCurrentStep = currentValidPos + 1 + stepOffset;
|
|
847
|
-
const displayTotalSteps = (
|
|
848
|
-
const borderRadius = (
|
|
854
|
+
const displayTotalSteps = (_d = activeTour.displayTotal) != null ? _d : totalSteps;
|
|
855
|
+
const borderRadius = (_e = step.borderRadius) != null ? _e : 10;
|
|
849
856
|
const {
|
|
850
857
|
isShowSkip = true,
|
|
851
858
|
isShowPrev = true,
|
|
@@ -855,9 +862,9 @@ var WalkthroughOverlay = ({
|
|
|
855
862
|
skipLabel: tourSkipLabel = "Skip",
|
|
856
863
|
doneLabel = "Done"
|
|
857
864
|
} = activeTour;
|
|
858
|
-
const nextLabel = (
|
|
859
|
-
const prevLabel = (
|
|
860
|
-
const skipLabel = (
|
|
865
|
+
const nextLabel = (_f = step.nextLabel) != null ? _f : tourNextLabel;
|
|
866
|
+
const prevLabel = (_g = step.prevLabel) != null ? _g : tourPrevLabel;
|
|
867
|
+
const skipLabel = (_h = step.skipLabel) != null ? _h : tourSkipLabel;
|
|
861
868
|
const next = () => {
|
|
862
869
|
var _a2;
|
|
863
870
|
const hasTrigger = !!step.triggerElOnNext;
|
|
@@ -988,7 +995,7 @@ var WalkthroughOverlay = ({
|
|
|
988
995
|
/* @__PURE__ */ jsxs(PopoverBody, { children: [
|
|
989
996
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "row", justifyContent: "space-between" }, children: [
|
|
990
997
|
pStep.title ? /* @__PURE__ */ jsx(PopoverTitle, { children: pStep.title }) : "",
|
|
991
|
-
((
|
|
998
|
+
((_i = pStep.isShowStep) != null ? _i : pIsShowStep) && /* @__PURE__ */ jsxs("span", { style: { color: "#a1a1aa", fontSize: "12px", fontWeight: "400" }, children: [
|
|
992
999
|
pDisplayCurrentStep,
|
|
993
1000
|
"/",
|
|
994
1001
|
pDisplayTotalSteps
|
|
@@ -1013,7 +1020,7 @@ var WalkthroughOverlay = ({
|
|
|
1013
1020
|
}
|
|
1014
1021
|
) }),
|
|
1015
1022
|
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
1016
|
-
((
|
|
1023
|
+
((_j = pStep.isShowPrev) != null ? _j : pIsShowPrev) && pCurrentValidPos > 0 && /* @__PURE__ */ jsx(
|
|
1017
1024
|
"button",
|
|
1018
1025
|
{
|
|
1019
1026
|
className: "wt-btn",
|