@tent-official/react-walkthrough 1.1.93 → 1.1.94
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 +41 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ Lightweight React walkthrough/tour component with auto-positioning, dependency c
|
|
|
7
7
|
- SVG-based spotlight overlay with smooth animated transitions
|
|
8
8
|
- Auto-positioning popover (top/bottom/left/right) with viewport detection
|
|
9
9
|
- Dependency chains — start a walkthrough only after another completes
|
|
10
|
+
- Conditional start — `startWhenCondition` prop to gate walkthrough on custom logic (e.g. data loaded)
|
|
11
|
+
- Auto-cleanup on navigation — highlight is automatically removed when the component unmounts (e.g. browser back/forward)
|
|
10
12
|
- Customizable labels, colors, and layout
|
|
11
13
|
- Reset and replay walkthroughs without page refresh
|
|
12
14
|
- Portal-based rendering (works inside modals)
|
|
@@ -74,6 +76,7 @@ Hook to register a walkthrough tour.
|
|
|
74
76
|
| `steps` | `IWalkthroughStep[]` | **required** | Array of steps |
|
|
75
77
|
| `storageSuffix` | `string` | `""` | Storage suffix for localStorage |
|
|
76
78
|
| `dependsOn` | `string[]` | `[]` | Walkthrough names that must complete first |
|
|
79
|
+
| `startWhenCondition` | `boolean \| () => boolean` | `undefined` | Additional condition that must be true for the walkthrough to start. Both `dependsOn` **AND** `startWhenCondition` must be satisfied. Example: `startWhenCondition: list.length > 0` |
|
|
77
80
|
| `onWalkthroughComplete` | `(name: string) => void` | — | Callback when walkthrough completes (both finish and skip) |
|
|
78
81
|
| `handleWhenLastStep` | `() => void` | — | Callback fired only when the user clicks "Done" on the last step (not on skip). Useful for triggering navigation (e.g. `router.push`) |
|
|
79
82
|
| `isShowSkip` | `boolean` | `true` | Show skip button |
|
|
@@ -173,6 +176,44 @@ useWalkthrough({
|
|
|
173
176
|
});
|
|
174
177
|
```
|
|
175
178
|
|
|
179
|
+
## Conditional Start
|
|
180
|
+
|
|
181
|
+
Use `startWhenCondition` to gate a walkthrough on custom logic. The walkthrough will only start when **both** `dependsOn` (if any) **and** `startWhenCondition` are satisfied:
|
|
182
|
+
|
|
183
|
+
```jsx
|
|
184
|
+
function Dashboard({ items }) {
|
|
185
|
+
// Won't start until items are loaded AND intro-tour is done
|
|
186
|
+
useWalkthrough({
|
|
187
|
+
name: "items-tour",
|
|
188
|
+
storageSuffix: "my-app",
|
|
189
|
+
dependsOn: ["intro-tour"],
|
|
190
|
+
startWhenCondition: items.length > 0,
|
|
191
|
+
steps: [/* ... */],
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Also accepts a function
|
|
195
|
+
useWalkthrough({
|
|
196
|
+
name: "profile-tour",
|
|
197
|
+
startWhenCondition: () => document.getElementById("profile-btn") !== null,
|
|
198
|
+
steps: [/* ... */],
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
return <div>...</div>;
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
> When `startWhenCondition` is `undefined` (default), only `dependsOn` is checked — backward compatible.
|
|
206
|
+
|
|
207
|
+
## Auto-Cleanup on Navigation
|
|
208
|
+
|
|
209
|
+
The walkthrough highlight is **automatically removed** when the component that registered it unmounts. This means:
|
|
210
|
+
|
|
211
|
+
- Pressing **browser back/forward** properly clears the overlay
|
|
212
|
+
- **Route changes** (e.g. React Router, Next.js) clean up automatically
|
|
213
|
+
- No stale highlights left on screen after navigation
|
|
214
|
+
|
|
215
|
+
No extra configuration needed — this works out of the box.
|
|
216
|
+
|
|
176
217
|
## Keyboard Blocking
|
|
177
218
|
|
|
178
219
|
While a walkthrough is active, the following keyboard keys are **automatically blocked** to prevent users from accidentally interacting with highlighted elements behind the overlay:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tent-official/react-walkthrough",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.94",
|
|
4
4
|
"description": "Lightweight React walkthrough/tour component with auto-positioning, dependency chains, and smooth animations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|