@robertlinde/react-tour-kit 0.5.9 → 0.6.0
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 +130 -15
- package/dist/react-native-platform/tour-provider.js +32 -14
- package/dist/react-native-platform/tour-provider.js.map +1 -1
- package/dist/react-native-platform/types/tour-provider.props.type.d.ts +2 -2
- package/dist/react-native.d.ts +1 -1
- package/dist/react-native.js.map +1 -1
- package/dist/react-platform/tour-provider.js +32 -14
- package/dist/react-platform/tour-provider.js.map +1 -1
- package/dist/react-platform/types/tour-provider.props.type.d.ts +2 -2
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/types/index.d.ts +1 -0
- package/dist/shared/types/tour-context.type.d.ts +2 -1
- package/dist/shared/types/tour-end-info.type.d.ts +12 -0
- package/dist/shared/types/tour-end-info.type.js +2 -0
- package/dist/shared/types/tour-end-info.type.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Cross-platform guided tour library for React and React Native. Build interactive
|
|
|
11
11
|
- **Smart Positioning**: Automatic tooltip positioning with viewport boundary detection
|
|
12
12
|
- **Keyboard Navigation**: Arrow keys and Escape (web) or hardware back button (Android)
|
|
13
13
|
- **Async Step Actions**: Run async code before each step (e.g., navigate, switch tabs, open dialogs)
|
|
14
|
+
- **Rich End Callbacks**: Know _why_ a tour ended (`completed`, `closed`, `blur`, `escape`, `target-missing`) with global and per-tour handlers
|
|
14
15
|
- **TypeScript First**: Full TypeScript support
|
|
15
16
|
|
|
16
17
|
## Installation
|
|
@@ -396,9 +397,10 @@ import {TourProvider} from '@robertlinde/react-tour-kit/react';
|
|
|
396
397
|
TooltipComponent={CustomTooltip} // Optional: custom tooltip component
|
|
397
398
|
OverlayComponent={CustomOverlay} // Optional: custom overlay component
|
|
398
399
|
theme={theme} // Optional: theme configuration
|
|
399
|
-
onTourEnd={(tourId) => {
|
|
400
|
+
onTourEnd={(tourId, info) => {
|
|
400
401
|
// Optional: callback when tour ends
|
|
401
|
-
|
|
402
|
+
// info.reason is one of: 'completed' | 'closed' | 'blur' | 'escape' | 'target-missing'
|
|
403
|
+
console.log(`Tour ${tourId} ended: ${info.reason} at step ${info.stepIndex + 1}/${info.totalSteps}`);
|
|
402
404
|
}}
|
|
403
405
|
>
|
|
404
406
|
{children}
|
|
@@ -407,14 +409,14 @@ import {TourProvider} from '@robertlinde/react-tour-kit/react';
|
|
|
407
409
|
|
|
408
410
|
#### Props
|
|
409
411
|
|
|
410
|
-
| Prop | Type | Description
|
|
411
|
-
| ------------------ | --------------------------------------------- |
|
|
412
|
-
| `children` | `ReactNode` | Your application content
|
|
413
|
-
| `theme` | `TourTheme` | Theme configuration for colors (see Theming section)
|
|
414
|
-
| `i18n` | `TourI18n` | Internationalization options for labels (see i18n section)
|
|
415
|
-
| `TooltipComponent` | `ForwardRefExoticComponent<TourTooltipProps>` | Custom tooltip component (must use forwardRef)
|
|
416
|
-
| `OverlayComponent` | `ComponentType<TourOverlayProps>` | Custom overlay component
|
|
417
|
-
| `onTourEnd` | `
|
|
412
|
+
| Prop | Type | Description |
|
|
413
|
+
| ------------------ | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
414
|
+
| `children` | `ReactNode` | Your application content |
|
|
415
|
+
| `theme` | `TourTheme` | Theme configuration for colors (see Theming section) |
|
|
416
|
+
| `i18n` | `TourI18n` | Internationalization options for labels (see i18n section) |
|
|
417
|
+
| `TooltipComponent` | `ForwardRefExoticComponent<TourTooltipProps>` | Custom tooltip component (must use forwardRef) |
|
|
418
|
+
| `OverlayComponent` | `ComponentType<TourOverlayProps>` | Custom overlay component |
|
|
419
|
+
| `onTourEnd` | `TourEndCallback` | Callback fired when any tour ends. Receives `(tourId, info)` with the reason and step context (see [Tour End Callbacks](#tour-end-callbacks)) |
|
|
418
420
|
|
|
419
421
|
### useTour Hook
|
|
420
422
|
|
|
@@ -429,7 +431,7 @@ function MyComponent() {
|
|
|
429
431
|
currentStep, // number: current step index (0-based)
|
|
430
432
|
steps, // TourStep[]: all steps in current tour
|
|
431
433
|
currentTourId, // string | null: ID of current tour
|
|
432
|
-
startTour, // (steps: TourStep[], tourId?: string) => void
|
|
434
|
+
startTour, // (steps: TourStep[], tourId?: string, options?: StartTourOptions) => void
|
|
433
435
|
endTour, // () => void
|
|
434
436
|
nextStep, // () => void
|
|
435
437
|
prevStep, // () => void
|
|
@@ -457,6 +459,113 @@ type TourStep = {
|
|
|
457
459
|
type TourTarget = string | RefObject<unknown>;
|
|
458
460
|
```
|
|
459
461
|
|
|
462
|
+
### Tour End Callbacks
|
|
463
|
+
|
|
464
|
+
Tours can end in several ways, and callbacks receive context about **why** and **where**. You can register an end handler at two levels: globally on the provider, or per-tour via `startTour`.
|
|
465
|
+
|
|
466
|
+
#### Callback signature
|
|
467
|
+
|
|
468
|
+
```tsx
|
|
469
|
+
type TourEndReason =
|
|
470
|
+
| 'completed' // User clicked Finish on the last step
|
|
471
|
+
| 'closed' // User clicked the close (✕) button, or `endTour()` was called programmatically
|
|
472
|
+
| 'blur' // User clicked/tapped the overlay outside the highlighted element
|
|
473
|
+
| 'escape' // User pressed Escape (web only)
|
|
474
|
+
| 'target-missing'; // The step's target element could not be found and the tour had to end
|
|
475
|
+
|
|
476
|
+
type TourEndInfo = {
|
|
477
|
+
reason: TourEndReason;
|
|
478
|
+
stepIndex: number; // Zero-based index of the step the user was on
|
|
479
|
+
step: TourStep; // The step object the user was on
|
|
480
|
+
totalSteps: number; // Total number of steps in the tour
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
type TourEndCallback = (tourId: string | undefined, info: TourEndInfo) => void;
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
> **Note (React Native):** the `'escape'` reason only fires on web. On Android, the hardware back button is reported as `'closed'`.
|
|
487
|
+
|
|
488
|
+
#### Provider-level callback
|
|
489
|
+
|
|
490
|
+
Use the provider-level `onTourEnd` for cross-cutting concerns that should run for every tour — analytics, logging, etc.
|
|
491
|
+
|
|
492
|
+
```tsx
|
|
493
|
+
<TourProvider
|
|
494
|
+
onTourEnd={(tourId, info) => {
|
|
495
|
+
analytics.track('tour_ended', {
|
|
496
|
+
tourId,
|
|
497
|
+
reason: info.reason,
|
|
498
|
+
lastStep: info.stepIndex + 1,
|
|
499
|
+
totalSteps: info.totalSteps,
|
|
500
|
+
});
|
|
501
|
+
}}
|
|
502
|
+
>
|
|
503
|
+
<App />
|
|
504
|
+
</TourProvider>
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
#### Per-tour callback
|
|
508
|
+
|
|
509
|
+
Pass an `onTourEnd` in the options argument to `startTour` when you need tour-specific end logic. This keeps the logic colocated with the tour that owns it, instead of dispatching on `tourId` in the provider callback.
|
|
510
|
+
|
|
511
|
+
```tsx
|
|
512
|
+
function WelcomeButton() {
|
|
513
|
+
const {startTour} = useTour();
|
|
514
|
+
|
|
515
|
+
const handleStart = () => {
|
|
516
|
+
startTour(onboardingSteps, 'onboarding', {
|
|
517
|
+
onTourEnd: (tourId, info) => {
|
|
518
|
+
if (info.reason === 'completed') {
|
|
519
|
+
markOnboardingComplete();
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
return <button onClick={handleStart}>Start Onboarding</button>;
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
#### Precedence
|
|
530
|
+
|
|
531
|
+
When both a provider-level and a per-tour callback are defined, **the per-tour callback fires first**, then the provider-level callback. Both always run on every end — the per-tour callback does not suppress the provider-level one.
|
|
532
|
+
|
|
533
|
+
```tsx
|
|
534
|
+
// Provider:
|
|
535
|
+
onTourEnd = (id, info) => console.log('provider', id, info.reason);
|
|
536
|
+
|
|
537
|
+
// Tour:
|
|
538
|
+
startTour(steps, 'onboarding', {
|
|
539
|
+
onTourEnd: (id, info) => console.log('tour', id, info.reason),
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// On end, logs in order:
|
|
543
|
+
// 'tour' 'onboarding' 'completed'
|
|
544
|
+
// 'provider' 'onboarding' 'completed'
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
#### Reacting to specific reasons
|
|
548
|
+
|
|
549
|
+
Branch on `info.reason` to distinguish outcomes:
|
|
550
|
+
|
|
551
|
+
```tsx
|
|
552
|
+
onTourEnd={(tourId, info) => {
|
|
553
|
+
switch (info.reason) {
|
|
554
|
+
case 'completed':
|
|
555
|
+
markComplete(tourId);
|
|
556
|
+
break;
|
|
557
|
+
case 'blur':
|
|
558
|
+
case 'closed':
|
|
559
|
+
case 'escape':
|
|
560
|
+
trackDismissal(tourId, info.reason, info.stepIndex);
|
|
561
|
+
break;
|
|
562
|
+
case 'target-missing':
|
|
563
|
+
reportBug(`Tour ${tourId} broke at step ${info.stepIndex}: ${info.step.target}`);
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
}}
|
|
567
|
+
```
|
|
568
|
+
|
|
460
569
|
## Theming
|
|
461
570
|
|
|
462
571
|
Customize the look of the default tooltip and overlay without building custom components.
|
|
@@ -821,14 +930,14 @@ function App() {
|
|
|
821
930
|
|
|
822
931
|
### Persisting Tour Completion
|
|
823
932
|
|
|
824
|
-
Track which tours users have completed
|
|
933
|
+
Track which tours users have fully completed. Only persist on `'completed'` so dismissed or interrupted tours aren't marked done.
|
|
825
934
|
|
|
826
935
|
```tsx
|
|
827
|
-
import {TourProvider} from '@robertlinde/react-tour-kit/react';
|
|
936
|
+
import {TourProvider, type TourEndCallback} from '@robertlinde/react-tour-kit/react';
|
|
828
937
|
|
|
829
938
|
function App() {
|
|
830
|
-
const handleTourEnd = async (tourId
|
|
831
|
-
if (tourId) {
|
|
939
|
+
const handleTourEnd: TourEndCallback = async (tourId, info) => {
|
|
940
|
+
if (tourId && info.reason === 'completed') {
|
|
832
941
|
// Save to your backend
|
|
833
942
|
await fetch('/api/users/me/completed-tours/' + tourId, {
|
|
834
943
|
method: 'POST',
|
|
@@ -844,6 +953,8 @@ function App() {
|
|
|
844
953
|
}
|
|
845
954
|
```
|
|
846
955
|
|
|
956
|
+
See [Tour End Callbacks](#tour-end-callbacks) for the full list of end reasons and how to register per-tour end handlers.
|
|
957
|
+
|
|
847
958
|
### Conditional Tour Start
|
|
848
959
|
|
|
849
960
|
Start tours based on user state:
|
|
@@ -899,6 +1010,10 @@ import type {
|
|
|
899
1010
|
TourOverlayProps,
|
|
900
1011
|
TourTheme,
|
|
901
1012
|
TourI18n,
|
|
1013
|
+
TourEndCallback,
|
|
1014
|
+
TourEndInfo,
|
|
1015
|
+
TourEndReason,
|
|
1016
|
+
StartTourOptions,
|
|
902
1017
|
} from '@robertlinde/react-tour-kit/react';
|
|
903
1018
|
```
|
|
904
1019
|
|
|
@@ -21,20 +21,31 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
21
21
|
const [highlightRect, setHighlightRect] = useState(undefined);
|
|
22
22
|
const tooltipRef = useRef(null);
|
|
23
23
|
const [positionKey, setPositionKey] = useState(0);
|
|
24
|
+
const tourOnEndRef = useRef(undefined);
|
|
24
25
|
const Tooltip = TooltipComponent ?? DefaultTourTooltip;
|
|
25
26
|
const Overlay = OverlayComponent ?? DefaultTourOverlay;
|
|
26
|
-
const startTour = useCallback((tourSteps, tourId) => {
|
|
27
|
+
const startTour = useCallback((tourSteps, tourId, options) => {
|
|
27
28
|
if (tourSteps.length > 0) {
|
|
28
29
|
setSteps(tourSteps);
|
|
29
30
|
setCurrentStep(0);
|
|
30
31
|
setCurrentTourId(tourId);
|
|
32
|
+
tourOnEndRef.current = options?.onTourEnd;
|
|
31
33
|
setIsActive(true);
|
|
32
34
|
}
|
|
33
35
|
}, []);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const finishTour = useCallback((reason) => {
|
|
37
|
+
const stepAtEnd = steps[currentStep] ?? steps.at(-1);
|
|
38
|
+
if (stepAtEnd) {
|
|
39
|
+
const info = {
|
|
40
|
+
reason,
|
|
41
|
+
stepIndex: currentStep,
|
|
42
|
+
step: stepAtEnd,
|
|
43
|
+
totalSteps: steps.length,
|
|
44
|
+
};
|
|
45
|
+
tourOnEndRef.current?.(currentTourId, info);
|
|
46
|
+
onTourEnd?.(currentTourId, info);
|
|
37
47
|
}
|
|
48
|
+
tourOnEndRef.current = undefined;
|
|
38
49
|
setIsActive(false);
|
|
39
50
|
setCurrentStep(0);
|
|
40
51
|
setSteps([]);
|
|
@@ -42,15 +53,18 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
42
53
|
setHighlightRect(undefined);
|
|
43
54
|
setTooltipPosition({ top: 0, left: 0 });
|
|
44
55
|
setIsPositioned(false);
|
|
45
|
-
}, [currentTourId, onTourEnd]);
|
|
56
|
+
}, [currentTourId, currentStep, steps, onTourEnd]);
|
|
57
|
+
const endTour = useCallback(() => {
|
|
58
|
+
finishTour('closed');
|
|
59
|
+
}, [finishTour]);
|
|
46
60
|
const nextStep = useCallback(() => {
|
|
47
61
|
if (currentStep < steps.length - 1) {
|
|
48
62
|
setCurrentStep((previous) => previous + 1);
|
|
49
63
|
}
|
|
50
64
|
else {
|
|
51
|
-
|
|
65
|
+
finishTour('completed');
|
|
52
66
|
}
|
|
53
|
-
}, [currentStep, steps.length,
|
|
67
|
+
}, [currentStep, steps.length, finishTour]);
|
|
54
68
|
const previousStep = useCallback(() => {
|
|
55
69
|
if (currentStep > 0) {
|
|
56
70
|
setCurrentStep((previous) => previous - 1);
|
|
@@ -76,7 +90,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
76
90
|
setCurrentStep((previous) => previous + 1);
|
|
77
91
|
}
|
|
78
92
|
else {
|
|
79
|
-
|
|
93
|
+
finishTour('target-missing');
|
|
80
94
|
}
|
|
81
95
|
return;
|
|
82
96
|
}
|
|
@@ -88,7 +102,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
88
102
|
setTooltipPosition(position);
|
|
89
103
|
setIsPositioned(true);
|
|
90
104
|
})();
|
|
91
|
-
}, [isActive, currentStep, steps,
|
|
105
|
+
}, [isActive, currentStep, steps, finishTour, platform]);
|
|
92
106
|
useEffect(() => {
|
|
93
107
|
if (!isActive || steps.length === 0) {
|
|
94
108
|
return;
|
|
@@ -110,7 +124,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
110
124
|
setCurrentStep((previous) => previous + 1);
|
|
111
125
|
}
|
|
112
126
|
else {
|
|
113
|
-
|
|
127
|
+
finishTour('target-missing');
|
|
114
128
|
}
|
|
115
129
|
return;
|
|
116
130
|
}
|
|
@@ -121,7 +135,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
121
135
|
}, initialPositionDelayMs);
|
|
122
136
|
};
|
|
123
137
|
void runStep();
|
|
124
|
-
}, [isActive, currentStep, steps,
|
|
138
|
+
}, [isActive, currentStep, steps, finishTour, platform]);
|
|
125
139
|
useEffect(() => {
|
|
126
140
|
if (!isActive || !highlightRect || steps.length === 0) {
|
|
127
141
|
return;
|
|
@@ -168,11 +182,13 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
168
182
|
return;
|
|
169
183
|
}
|
|
170
184
|
return platform.subscribeToKeyboard({
|
|
171
|
-
onEscape
|
|
185
|
+
onEscape() {
|
|
186
|
+
finishTour('closed');
|
|
187
|
+
},
|
|
172
188
|
onNext: nextStep,
|
|
173
189
|
onPrev: previousStep,
|
|
174
190
|
});
|
|
175
|
-
}, [isActive,
|
|
191
|
+
}, [isActive, finishTour, nextStep, previousStep, platform]);
|
|
176
192
|
useEffect(() => {
|
|
177
193
|
if (!isActive) {
|
|
178
194
|
return;
|
|
@@ -191,6 +207,8 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
191
207
|
prevStep: previousStep,
|
|
192
208
|
goToStep,
|
|
193
209
|
}), [isActive, currentStep, steps, currentTourId, startTour, endTour, nextStep, previousStep, goToStep]);
|
|
194
|
-
return (_jsxs(TourContext, { value: contextValue, children: [children, _jsx(Modal, { transparent: true, visible: Boolean(isActive && highlightRect), animationType: "fade", children: highlightRect ? (_jsxs(_Fragment, { children: [_jsx(Overlay, { highlightRect: highlightRect, theme: resolvedTheme, onClose:
|
|
210
|
+
return (_jsxs(TourContext, { value: contextValue, children: [children, _jsx(Modal, { transparent: true, visible: Boolean(isActive && highlightRect), animationType: "fade", children: highlightRect ? (_jsxs(_Fragment, { children: [_jsx(Overlay, { highlightRect: highlightRect, theme: resolvedTheme, onClose: () => {
|
|
211
|
+
finishTour('blur');
|
|
212
|
+
} }), currentTourStep ? (_jsx(Tooltip, { ref: tooltipRef, content: currentTourStep.content, currentStep: currentStep, i18n: i18n, isPositioned: isPositioned, position: tooltipPosition, theme: resolvedTheme, title: currentTourStep.title, totalSteps: steps.length, onClose: endTour, onGoToStep: goToStep, onNext: nextStep, onPrev: previousStep })) : null] })) : null })] }));
|
|
195
213
|
}
|
|
196
214
|
//# sourceMappingURL=tour-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tour-provider.js","sourceRoot":"","sources":["../../src/react-native-platform/tour-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"tour-provider.js","sourceRoot":"","sources":["../../src/react-native-platform/tour-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAElF,OAAO,EAQL,WAAW,EACX,wBAAwB,EACxB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,WAAW,IAAI,kBAAkB,EAAC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J,CAAC,CAAC,CAAC,IAAI,GACF,IACI,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from 'react';
|
|
2
|
-
import { type PlatformAdapter, type TourI18n, type TourOverlayProps, type TourTheme, type TourTooltipProps } from '../../shared';
|
|
2
|
+
import { type PlatformAdapter, type TourEndCallback, type TourI18n, type TourOverlayProps, type TourTheme, type TourTooltipProps } from '../../shared';
|
|
3
3
|
export type TourProviderProps = {
|
|
4
4
|
readonly children: ReactNode;
|
|
5
5
|
readonly TooltipComponent?: ComponentType<TourTooltipProps>;
|
|
6
6
|
readonly OverlayComponent?: ComponentType<TourOverlayProps>;
|
|
7
|
-
readonly onTourEnd?:
|
|
7
|
+
readonly onTourEnd?: TourEndCallback;
|
|
8
8
|
readonly theme?: TourTheme;
|
|
9
9
|
readonly platform?: PlatformAdapter;
|
|
10
10
|
readonly i18n?: TourI18n;
|
package/dist/react-native.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { TourProvider, type TourProviderProps } from './react-native-platform';
|
|
|
2
2
|
export { TourContext, useTour } from './shared';
|
|
3
3
|
export { useTourTarget } from './react-native-platform';
|
|
4
4
|
export { TourOverlay, TourTooltip } from './react-native-platform';
|
|
5
|
-
export type { TourStep, TourContextType, TourTooltipProps, TourOverlayProps, TourTheme, TourI18n } from './shared';
|
|
5
|
+
export type { TourStep, TourContextType, TourTooltipProps, TourOverlayProps, TourTheme, TourI18n, TourEndReason, TourEndInfo, TourEndCallback, StartTourOptions, } from './shared';
|
|
6
6
|
export type { Rect, TourTarget } from './shared';
|
|
7
7
|
export { calculateTooltipPosition } from './shared';
|
|
8
8
|
export { nativePlatformAdapter, targetRegistry } from './react-native-platform';
|
package/dist/react-native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../src/react-native.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAyB,MAAM,yBAAyB,CAAC;AAE7E,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAItD,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../src/react-native.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAyB,MAAM,yBAAyB,CAAC;AAE7E,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAItD,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAqBjE,OAAO,EAAC,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAIlD,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAC,MAAM,yBAAyB,CAAC"}
|
|
@@ -23,23 +23,34 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
23
23
|
const tooltipRef = useRef(null);
|
|
24
24
|
const [positionKey, setPositionKey] = useState(0);
|
|
25
25
|
const [isMounted, setIsMounted] = useState(false);
|
|
26
|
+
const tourOnEndRef = useRef(undefined);
|
|
26
27
|
const Tooltip = TooltipComponent ?? DefaultTourTooltip;
|
|
27
28
|
const Overlay = OverlayComponent ?? DefaultTourOverlay;
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
setIsMounted(true);
|
|
30
31
|
}, []);
|
|
31
|
-
const startTour = useCallback((tourSteps, tourId) => {
|
|
32
|
+
const startTour = useCallback((tourSteps, tourId, options) => {
|
|
32
33
|
if (tourSteps.length > 0) {
|
|
33
34
|
setSteps(tourSteps);
|
|
34
35
|
setCurrentStep(0);
|
|
35
36
|
setCurrentTourId(tourId);
|
|
37
|
+
tourOnEndRef.current = options?.onTourEnd;
|
|
36
38
|
setIsActive(true);
|
|
37
39
|
}
|
|
38
40
|
}, []);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const finishTour = useCallback((reason) => {
|
|
42
|
+
const stepAtEnd = steps[currentStep] ?? steps.at(-1);
|
|
43
|
+
if (stepAtEnd) {
|
|
44
|
+
const info = {
|
|
45
|
+
reason,
|
|
46
|
+
stepIndex: currentStep,
|
|
47
|
+
step: stepAtEnd,
|
|
48
|
+
totalSteps: steps.length,
|
|
49
|
+
};
|
|
50
|
+
tourOnEndRef.current?.(currentTourId, info);
|
|
51
|
+
onTourEnd?.(currentTourId, info);
|
|
42
52
|
}
|
|
53
|
+
tourOnEndRef.current = undefined;
|
|
43
54
|
setIsActive(false);
|
|
44
55
|
setCurrentStep(0);
|
|
45
56
|
setSteps([]);
|
|
@@ -47,15 +58,18 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
47
58
|
setHighlightRect(undefined);
|
|
48
59
|
setTooltipPosition({ top: 0, left: 0 });
|
|
49
60
|
setIsPositioned(false);
|
|
50
|
-
}, [currentTourId, onTourEnd]);
|
|
61
|
+
}, [currentTourId, currentStep, steps, onTourEnd]);
|
|
62
|
+
const endTour = useCallback(() => {
|
|
63
|
+
finishTour('closed');
|
|
64
|
+
}, [finishTour]);
|
|
51
65
|
const nextStep = useCallback(() => {
|
|
52
66
|
if (currentStep < steps.length - 1) {
|
|
53
67
|
setCurrentStep((previous) => previous + 1);
|
|
54
68
|
}
|
|
55
69
|
else {
|
|
56
|
-
|
|
70
|
+
finishTour('completed');
|
|
57
71
|
}
|
|
58
|
-
}, [currentStep, steps.length,
|
|
72
|
+
}, [currentStep, steps.length, finishTour]);
|
|
59
73
|
const previousStep = useCallback(() => {
|
|
60
74
|
if (currentStep > 0) {
|
|
61
75
|
setCurrentStep((previous) => previous - 1);
|
|
@@ -81,7 +95,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
81
95
|
setCurrentStep((previous) => previous + 1);
|
|
82
96
|
}
|
|
83
97
|
else {
|
|
84
|
-
|
|
98
|
+
finishTour('target-missing');
|
|
85
99
|
}
|
|
86
100
|
return;
|
|
87
101
|
}
|
|
@@ -93,7 +107,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
93
107
|
setTooltipPosition(position);
|
|
94
108
|
setIsPositioned(true);
|
|
95
109
|
})();
|
|
96
|
-
}, [isActive, currentStep, steps,
|
|
110
|
+
}, [isActive, currentStep, steps, finishTour, platform]);
|
|
97
111
|
useEffect(() => {
|
|
98
112
|
if (!isActive || steps.length === 0) {
|
|
99
113
|
return;
|
|
@@ -115,7 +129,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
115
129
|
setCurrentStep((previous) => previous + 1);
|
|
116
130
|
}
|
|
117
131
|
else {
|
|
118
|
-
|
|
132
|
+
finishTour('target-missing');
|
|
119
133
|
}
|
|
120
134
|
return;
|
|
121
135
|
}
|
|
@@ -126,7 +140,7 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
126
140
|
}, initialPositionDelayMs);
|
|
127
141
|
};
|
|
128
142
|
void runStep();
|
|
129
|
-
}, [isActive, currentStep, steps,
|
|
143
|
+
}, [isActive, currentStep, steps, finishTour, platform]);
|
|
130
144
|
useEffect(() => {
|
|
131
145
|
if (!isActive || !highlightRect || steps.length === 0) {
|
|
132
146
|
return;
|
|
@@ -173,11 +187,13 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
173
187
|
return;
|
|
174
188
|
}
|
|
175
189
|
return platform.subscribeToKeyboard({
|
|
176
|
-
onEscape
|
|
190
|
+
onEscape() {
|
|
191
|
+
finishTour('escape');
|
|
192
|
+
},
|
|
177
193
|
onNext: nextStep,
|
|
178
194
|
onPrev: previousStep,
|
|
179
195
|
});
|
|
180
|
-
}, [isActive,
|
|
196
|
+
}, [isActive, finishTour, nextStep, previousStep, platform]);
|
|
181
197
|
useEffect(() => {
|
|
182
198
|
if (!isActive) {
|
|
183
199
|
return;
|
|
@@ -197,7 +213,9 @@ export function TourProvider({ children, TooltipComponent, OverlayComponent, onT
|
|
|
197
213
|
goToStep,
|
|
198
214
|
}), [isActive, currentStep, steps, currentTourId, startTour, endTour, nextStep, previousStep, goToStep]);
|
|
199
215
|
return (_jsxs(TourContext, { value: contextValue, children: [children, isActive && highlightRect && isMounted
|
|
200
|
-
? createPortal(_jsxs(_Fragment, { children: [_jsx(Overlay, { highlightRect: highlightRect, theme: resolvedTheme, onClose:
|
|
216
|
+
? createPortal(_jsxs(_Fragment, { children: [_jsx(Overlay, { highlightRect: highlightRect, theme: resolvedTheme, onClose: () => {
|
|
217
|
+
finishTour('blur');
|
|
218
|
+
} }), currentTourStep ? (_jsx(Tooltip, { ref: tooltipRef, content: currentTourStep.content, currentStep: currentStep, i18n: i18n, isPositioned: isPositioned, position: tooltipPosition, theme: resolvedTheme, title: currentTourStep.title, totalSteps: steps.length, onClose: endTour, onGoToStep: goToStep, onNext: nextStep, onPrev: previousStep })) : null] }), document.body)
|
|
201
219
|
: null] }));
|
|
202
220
|
}
|
|
203
221
|
//# sourceMappingURL=tour-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tour-provider.js","sourceRoot":"","sources":["../../src/react-platform/tour-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClF,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"tour-provider.js","sourceRoot":"","sources":["../../src/react-platform/tour-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClF,OAAO,E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,KAAK,EAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,EACxB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,QAAQ,EACpB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,YAAY,GACpB,CACH,CAAC,CAAC,CAAC,IAAI,IACP,EACH,QAAQ,CAAC,IAAI,CACd;gBACH,CAAC,CAAC,IAAI,IACI,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ComponentType, type ForwardRefExoticComponent, type ReactNode, type RefAttributes } from 'react';
|
|
2
|
-
import { type PlatformAdapter, type TourI18n, type TourOverlayProps, type TourTheme, type TourTooltipProps } from '../../shared';
|
|
2
|
+
import { type PlatformAdapter, type TourEndCallback, type TourI18n, type TourOverlayProps, type TourTheme, type TourTooltipProps } from '../../shared';
|
|
3
3
|
export type TourProviderProps = {
|
|
4
4
|
readonly children: ReactNode;
|
|
5
5
|
readonly TooltipComponent?: ForwardRefExoticComponent<TourTooltipProps & RefAttributes<HTMLDivElement>>;
|
|
6
6
|
readonly OverlayComponent?: ComponentType<TourOverlayProps>;
|
|
7
|
-
readonly onTourEnd?:
|
|
7
|
+
readonly onTourEnd?: TourEndCallback;
|
|
8
8
|
readonly theme?: TourTheme;
|
|
9
9
|
readonly platform?: PlatformAdapter;
|
|
10
10
|
readonly i18n?: TourI18n;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { TourProvider, type TourProviderProps } from './react-platform';
|
|
2
2
|
export { TourContext, useTour } from './shared';
|
|
3
3
|
export { TourOverlay, TourTooltip } from './react-platform';
|
|
4
|
-
export type { TourStep, TourContextType, TourTooltipProps, TourOverlayProps, TourTheme, TourI18n } from './shared';
|
|
4
|
+
export type { TourStep, TourContextType, TourTooltipProps, TourOverlayProps, TourTheme, TourI18n, TourEndReason, TourEndInfo, TourEndCallback, StartTourOptions, } from './shared';
|
|
5
5
|
export type { Rect, TourTarget } from './shared';
|
|
6
6
|
export { calculateTooltipPosition } from './shared';
|
|
7
7
|
export { findVisibleElement } from './react-platform';
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAyB,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAI9C,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAyB,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAI9C,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAqB1D,OAAO,EAAC,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAElD,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAIpD,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Rect, TourTarget, Placement, PlatformAdapter, KeyboardHandlers, TourTheme, TourStep, TourContextType, TourOverlayProps, TourTooltipProps, TourI18n, } from './types';
|
|
1
|
+
export type { Rect, TourTarget, Placement, PlatformAdapter, KeyboardHandlers, TourTheme, TourStep, TourContextType, TourOverlayProps, TourTooltipProps, TourI18n, TourEndReason, TourEndInfo, TourEndCallback, StartTourOptions, } from './types';
|
|
2
2
|
export { defaultTheme, resolveTheme } from './types';
|
|
3
3
|
export { TourContext, defaultTourContext } from './context';
|
|
4
4
|
export { useTour } from './hooks';
|
package/dist/shared/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAInD,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAIhC,OAAO,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAC"}
|
|
@@ -7,3 +7,4 @@ export type { TourContextType } from './tour-context.type';
|
|
|
7
7
|
export type { TourOverlayProps } from './tour-overlay-props.type';
|
|
8
8
|
export type { TourTooltipProps } from './tour-tooltip-props.type';
|
|
9
9
|
export type { TourI18n } from './tour-i18n.type';
|
|
10
|
+
export type { TourEndReason, TourEndInfo, TourEndCallback, StartTourOptions } from './tour-end-info.type';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type StartTourOptions } from './tour-end-info.type';
|
|
1
2
|
import { type TourStep } from './tour-step.type';
|
|
2
3
|
export type TourContextType = {
|
|
3
4
|
isActive: boolean;
|
|
4
5
|
currentStep: number;
|
|
5
6
|
steps: TourStep[];
|
|
6
7
|
currentTourId: string | undefined;
|
|
7
|
-
startTour: (steps: TourStep[], tourId?: string) => void;
|
|
8
|
+
startTour: (steps: TourStep[], tourId?: string, options?: StartTourOptions) => void;
|
|
8
9
|
endTour: () => void;
|
|
9
10
|
nextStep: () => void;
|
|
10
11
|
prevStep: () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TourStep } from './tour-step.type';
|
|
2
|
+
export type TourEndReason = 'completed' | 'closed' | 'blur' | 'escape' | 'target-missing';
|
|
3
|
+
export type TourEndInfo = {
|
|
4
|
+
readonly reason: TourEndReason;
|
|
5
|
+
readonly stepIndex: number;
|
|
6
|
+
readonly step: TourStep;
|
|
7
|
+
readonly totalSteps: number;
|
|
8
|
+
};
|
|
9
|
+
export type TourEndCallback = (tourId: string | undefined, info: TourEndInfo) => void;
|
|
10
|
+
export type StartTourOptions = {
|
|
11
|
+
readonly onTourEnd?: TourEndCallback;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tour-end-info.type.js","sourceRoot":"","sources":["../../../src/shared/types/tour-end-info.type.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robertlinde/react-tour-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Cross-platform guided tour library for React and React Native. Build interactive onboarding experiences with customizable tooltips, smart positioning, cross-page navigation, and async step actions. Fully themeable with TypeScript support.",
|
|
6
6
|
"author": "Robert Linde",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"husky": "9.1.7",
|
|
71
71
|
"lint-staged": "16.4.0",
|
|
72
72
|
"prettier": "3.8.1",
|
|
73
|
-
"react": "19.2.
|
|
74
|
-
"react-dom": "19.2.
|
|
73
|
+
"react": "19.2.5",
|
|
74
|
+
"react-dom": "19.2.5",
|
|
75
75
|
"typescript": "6.0.2",
|
|
76
76
|
"xo": "2.0.2"
|
|
77
77
|
},
|