@tent-official/react-walkthrough 1.1.79 → 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 +70 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -72
- 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,100 +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
|
-
const elReadyRef = useRef(false);
|
|
618
|
-
useEffect(() => {
|
|
619
|
-
var _a2, _b2, _c2;
|
|
620
|
-
if (!activeTour || isDelaying) {
|
|
621
599
|
setValidSteps([]);
|
|
600
|
+
setIsDelaying(false);
|
|
622
601
|
waitingForElsRef.current = false;
|
|
623
|
-
|
|
602
|
+
delayDoneForRef.current = null;
|
|
624
603
|
return;
|
|
625
604
|
}
|
|
626
|
-
|
|
605
|
+
let cancelled = false;
|
|
627
606
|
const abortController = new AbortController();
|
|
628
607
|
const compute = () => activeTour.steps.map((s, i) => ({ ...s, _originalIdx: i })).filter((s) => document.getElementById(resolveElId(s.el)));
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
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
|
+
}
|
|
634
621
|
setValidSteps(found);
|
|
635
|
-
|
|
636
|
-
|
|
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
|
+
});
|
|
637
633
|
return;
|
|
638
634
|
}
|
|
639
|
-
setValidSteps(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if (!currentStepEl) {
|
|
635
|
+
setValidSteps([]);
|
|
636
|
+
const firstStepEl = (_c2 = activeTour.steps[0]) == null ? void 0 : _c2.el;
|
|
637
|
+
if (!firstStepEl) {
|
|
643
638
|
waitingForElsRef.current = false;
|
|
644
639
|
return;
|
|
645
640
|
}
|
|
646
|
-
readElement(
|
|
647
|
-
if (el && !
|
|
648
|
-
|
|
649
|
-
|
|
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
|
+
}
|
|
650
648
|
}
|
|
651
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);
|
|
652
662
|
return () => {
|
|
663
|
+
cancelled = true;
|
|
664
|
+
clearTimeout(timer);
|
|
653
665
|
abortController.abort();
|
|
654
666
|
waitingForElsRef.current = false;
|
|
655
667
|
};
|
|
656
668
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
waitingForElsRef.current = false;
|
|
661
|
-
elReadyRef.current = true;
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
readElement(firstStepEl, { signal: abortController.signal }).then((el) => {
|
|
665
|
-
if (el && !abortController.signal.aborted) {
|
|
666
|
-
const updated = compute();
|
|
667
|
-
if (updated.length > 0) {
|
|
668
|
-
waitingForElsRef.current = false;
|
|
669
|
-
elReadyRef.current = true;
|
|
670
|
-
setValidSteps(updated);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
});
|
|
669
|
+
delayDoneForRef.current = activeTour.name;
|
|
670
|
+
setIsDelaying(false);
|
|
671
|
+
readElements();
|
|
674
672
|
return () => {
|
|
673
|
+
cancelled = true;
|
|
675
674
|
abortController.abort();
|
|
676
675
|
waitingForElsRef.current = false;
|
|
677
676
|
};
|
|
678
|
-
}, [activeTour
|
|
679
|
-
const currentOriginalIdx = (
|
|
677
|
+
}, [activeTour]);
|
|
678
|
+
const currentOriginalIdx = (_a = activeTour == null ? void 0 : activeTour.currentStep) != null ? _a : 0;
|
|
680
679
|
const currentValidPos = validSteps.findIndex(
|
|
681
680
|
(s) => s._originalIdx === currentOriginalIdx
|
|
682
681
|
);
|
|
683
682
|
const rawStep = currentValidPos !== -1 ? validSteps[currentValidPos] : null;
|
|
684
683
|
const step = isDelaying ? null : rawStep;
|
|
685
|
-
const tourAnimationSpeed = (
|
|
684
|
+
const tourAnimationSpeed = (_b = activeTour == null ? void 0 : activeTour.animationSpeed) != null ? _b : 350;
|
|
686
685
|
const { rect, isAnimating } = useAnimatedRect(step, tourAnimationSpeed, activeTour == null ? void 0 : activeTour.containerElement, !!activeTour, activeTour == null ? void 0 : activeTour.name);
|
|
687
686
|
const completeTour = useCallback(() => {
|
|
688
687
|
if (!activeTour) return;
|
|
@@ -694,7 +693,6 @@ var WalkthroughOverlay = ({
|
|
|
694
693
|
useEffect(() => {
|
|
695
694
|
if (!activeTour) return;
|
|
696
695
|
if (isDelaying) return;
|
|
697
|
-
if (!elReadyRef.current) return;
|
|
698
696
|
if (currentValidPos !== -1) return;
|
|
699
697
|
if (waitingForElsRef.current) return;
|
|
700
698
|
if (validSteps.length === 0) {
|
|
@@ -851,10 +849,10 @@ var WalkthroughOverlay = ({
|
|
|
851
849
|
}
|
|
852
850
|
const totalSteps = validSteps.length;
|
|
853
851
|
const isLast = currentValidPos === totalSteps - 1;
|
|
854
|
-
const stepOffset = (
|
|
852
|
+
const stepOffset = (_c = activeTour.displayStepOffset) != null ? _c : 0;
|
|
855
853
|
const displayCurrentStep = currentValidPos + 1 + stepOffset;
|
|
856
|
-
const displayTotalSteps = (
|
|
857
|
-
const borderRadius = (
|
|
854
|
+
const displayTotalSteps = (_d = activeTour.displayTotal) != null ? _d : totalSteps;
|
|
855
|
+
const borderRadius = (_e = step.borderRadius) != null ? _e : 10;
|
|
858
856
|
const {
|
|
859
857
|
isShowSkip = true,
|
|
860
858
|
isShowPrev = true,
|
|
@@ -864,9 +862,9 @@ var WalkthroughOverlay = ({
|
|
|
864
862
|
skipLabel: tourSkipLabel = "Skip",
|
|
865
863
|
doneLabel = "Done"
|
|
866
864
|
} = activeTour;
|
|
867
|
-
const nextLabel = (
|
|
868
|
-
const prevLabel = (
|
|
869
|
-
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;
|
|
870
868
|
const next = () => {
|
|
871
869
|
var _a2;
|
|
872
870
|
const hasTrigger = !!step.triggerElOnNext;
|
|
@@ -997,7 +995,7 @@ var WalkthroughOverlay = ({
|
|
|
997
995
|
/* @__PURE__ */ jsxs(PopoverBody, { children: [
|
|
998
996
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "row", justifyContent: "space-between" }, children: [
|
|
999
997
|
pStep.title ? /* @__PURE__ */ jsx(PopoverTitle, { children: pStep.title }) : "",
|
|
1000
|
-
((
|
|
998
|
+
((_i = pStep.isShowStep) != null ? _i : pIsShowStep) && /* @__PURE__ */ jsxs("span", { style: { color: "#a1a1aa", fontSize: "12px", fontWeight: "400" }, children: [
|
|
1001
999
|
pDisplayCurrentStep,
|
|
1002
1000
|
"/",
|
|
1003
1001
|
pDisplayTotalSteps
|
|
@@ -1022,7 +1020,7 @@ var WalkthroughOverlay = ({
|
|
|
1022
1020
|
}
|
|
1023
1021
|
) }),
|
|
1024
1022
|
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
1025
|
-
((
|
|
1023
|
+
((_j = pStep.isShowPrev) != null ? _j : pIsShowPrev) && pCurrentValidPos > 0 && /* @__PURE__ */ jsx(
|
|
1026
1024
|
"button",
|
|
1027
1025
|
{
|
|
1028
1026
|
className: "wt-btn",
|