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