@tent-official/react-walkthrough 1.4.0 → 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 CHANGED
@@ -119,6 +119,7 @@ Hook to register a walkthrough tour.
119
119
  | `displayStep` | `number` | — | Override the displayed step number for this step (display-only) |
120
120
  | `displayTotal` | `number` | — | Override the displayed total for this step (display-only) |
121
121
  | `forceRecompute` | `boolean` | — | When `true`, forces a DOM re-read before advancing to the next step. Useful when the next element is conditionally rendered and needs a layout update to appear |
122
+ | `delayAfterNext` | `number` | `0` | Delay in ms after clicking "Next" (after `onStepNext` and `triggerElOnNext` have fired) before advancing to the next step. The overlay stays visible with the popover hidden during the delay |
122
123
 
123
124
  ### `IStepDescription`
124
125
 
package/dist/index.d.mts CHANGED
@@ -61,6 +61,8 @@ interface IWalkthroughStep {
61
61
  displayTotal?: number;
62
62
  /** When true, forces a recompute of valid steps after advancing from this step. Useful when the next step's element is hidden/conditional and needs DOM changes to become visible. Default: false */
63
63
  forceRecompute?: boolean;
64
+ /** Delay in milliseconds after clicking "Next" (after onStepNext and triggerElOnNext have fired) before advancing to the next step. The overlay stays visible with the popover hidden during the delay. Default: 0 (no delay) */
65
+ delayAfterNext?: number;
64
66
  }
65
67
  /**
66
68
  * Options for the useWalkthrough hook.
package/dist/index.d.ts CHANGED
@@ -61,6 +61,8 @@ interface IWalkthroughStep {
61
61
  displayTotal?: number;
62
62
  /** When true, forces a recompute of valid steps after advancing from this step. Useful when the next step's element is hidden/conditional and needs DOM changes to become visible. Default: false */
63
63
  forceRecompute?: boolean;
64
+ /** Delay in milliseconds after clicking "Next" (after onStepNext and triggerElOnNext have fired) before advancing to the next step. The overlay stays visible with the popover hidden during the delay. Default: 0 (no delay) */
65
+ delayAfterNext?: number;
64
66
  }
65
67
  /**
66
68
  * Options for the useWalkthrough hook.
package/dist/index.js CHANGED
@@ -1011,13 +1011,21 @@ var WalkthroughOverlay = ({
1011
1011
  }
1012
1012
  };
1013
1013
  const next = () => {
1014
- var _a2;
1014
+ var _a2, _b2;
1015
1015
  const currentOrigIdx = validSteps[currentValidPos]._originalIdx;
1016
1016
  const stepNextCb = (_a2 = activeTour.onStepNext) == null ? void 0 : _a2[currentOrigIdx];
1017
1017
  if (typeof stepNextCb === "function") {
1018
1018
  stepNextCb();
1019
1019
  }
1020
1020
  const hasTrigger = !!step.triggerElOnNext;
1021
+ const afterNextDelay = (_b2 = step.delayAfterNext) != null ? _b2 : 0;
1022
+ const withDelay = (fn) => {
1023
+ if (afterNextDelay > 0) {
1024
+ setTimeout(fn, afterNextDelay);
1025
+ } else {
1026
+ fn();
1027
+ }
1028
+ };
1021
1029
  if (hasTrigger) {
1022
1030
  setPopoverHidden(true);
1023
1031
  setPopoverPos(null);
@@ -1050,7 +1058,7 @@ var WalkthroughOverlay = ({
1050
1058
  const SETTLE_DELAY = 150;
1051
1059
  const alreadyExists = document.getElementById(nextElId);
1052
1060
  if (alreadyExists) {
1053
- setTimeout(() => injectAndAdvance(), SETTLE_DELAY);
1061
+ withDelay(() => setTimeout(() => injectAndAdvance(), SETTLE_DELAY));
1054
1062
  } else {
1055
1063
  waitingForElsRef.current = true;
1056
1064
  const observer = new MutationObserver(() => {
@@ -1058,7 +1066,7 @@ var WalkthroughOverlay = ({
1058
1066
  if (found) {
1059
1067
  observer.disconnect();
1060
1068
  waitingForElsRef.current = false;
1061
- setTimeout(() => injectAndAdvance(), SETTLE_DELAY);
1069
+ withDelay(() => setTimeout(() => injectAndAdvance(), SETTLE_DELAY));
1062
1070
  }
1063
1071
  });
1064
1072
  observer.observe(document.body, { childList: true, subtree: true });
@@ -1066,7 +1074,7 @@ var WalkthroughOverlay = ({
1066
1074
  observer.disconnect();
1067
1075
  if (waitingForElsRef.current) {
1068
1076
  waitingForElsRef.current = false;
1069
- advanceStep(hasTrigger);
1077
+ withDelay(() => advanceStep(hasTrigger));
1070
1078
  }
1071
1079
  }, 3e3);
1072
1080
  }
@@ -1077,7 +1085,13 @@ var WalkthroughOverlay = ({
1077
1085
  setTimeout(() => completeTour(), 300);
1078
1086
  return;
1079
1087
  }
1080
- advanceStep(hasTrigger);
1088
+ if (afterNextDelay > 0) {
1089
+ setPopoverHidden(true);
1090
+ setPopoverPos(null);
1091
+ withDelay(() => advanceStep(hasTrigger));
1092
+ } else {
1093
+ advanceStep(hasTrigger);
1094
+ }
1081
1095
  };
1082
1096
  const prev = () => {
1083
1097
  var _a2;