rn-smart-tour 2.0.0-beta.4 → 2.0.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 +70 -8
- package/lib/commonjs/core/TourEngine.js +134 -15
- package/lib/commonjs/core/TourEngine.js.map +1 -1
- package/lib/commonjs/core/controller.js +4 -2
- package/lib/commonjs/core/controller.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/react/TourOverlay.js +47 -20
- package/lib/commonjs/react/TourOverlay.js.map +1 -1
- package/lib/commonjs/react/TourOverlayHost.js +46 -0
- package/lib/commonjs/react/TourOverlayHost.js.map +1 -0
- package/lib/commonjs/react/TourProvider.js +26 -13
- package/lib/commonjs/react/TourProvider.js.map +1 -1
- package/lib/commonjs/react/TourTarget.js +4 -2
- package/lib/commonjs/react/TourTarget.js.map +1 -1
- package/lib/commonjs/react/context.js +7 -1
- package/lib/commonjs/react/context.js.map +1 -1
- package/lib/module/core/TourEngine.js +134 -15
- package/lib/module/core/TourEngine.js.map +1 -1
- package/lib/module/core/controller.js +4 -2
- package/lib/module/core/controller.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/react/TourOverlay.js +48 -21
- package/lib/module/react/TourOverlay.js.map +1 -1
- package/lib/module/react/TourOverlayHost.js +39 -0
- package/lib/module/react/TourOverlayHost.js.map +1 -0
- package/lib/module/react/TourProvider.js +28 -15
- package/lib/module/react/TourProvider.js.map +1 -1
- package/lib/module/react/TourTarget.js +5 -3
- package/lib/module/react/TourTarget.js.map +1 -1
- package/lib/module/react/context.js +6 -0
- package/lib/module/react/context.js.map +1 -1
- package/lib/typescript/commonjs/src/core/TourEngine.d.ts +22 -2
- package/lib/typescript/commonjs/src/core/TourEngine.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/core/controller.d.ts +4 -2
- package/lib/typescript/commonjs/src/core/controller.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/react/TourOverlay.d.ts +9 -2
- package/lib/typescript/commonjs/src/react/TourOverlay.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/react/TourOverlayHost.d.ts +23 -0
- package/lib/typescript/commonjs/src/react/TourOverlayHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/react/TourProvider.d.ts +7 -1
- package/lib/typescript/commonjs/src/react/TourProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/react/TourTarget.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/react/context.d.ts +6 -1
- package/lib/typescript/commonjs/src/react/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +80 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/core/TourEngine.d.ts +22 -2
- package/lib/typescript/module/src/core/TourEngine.d.ts.map +1 -1
- package/lib/typescript/module/src/core/controller.d.ts +4 -2
- package/lib/typescript/module/src/core/controller.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/react/TourOverlay.d.ts +9 -2
- package/lib/typescript/module/src/react/TourOverlay.d.ts.map +1 -1
- package/lib/typescript/module/src/react/TourOverlayHost.d.ts +23 -0
- package/lib/typescript/module/src/react/TourOverlayHost.d.ts.map +1 -0
- package/lib/typescript/module/src/react/TourProvider.d.ts +7 -1
- package/lib/typescript/module/src/react/TourProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/react/TourTarget.d.ts.map +1 -1
- package/lib/typescript/module/src/react/context.d.ts +6 -1
- package/lib/typescript/module/src/react/context.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +80 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/TourEngine.ts +129 -16
- package/src/core/controller.ts +12 -2
- package/src/index.ts +2 -0
- package/src/react/TourOverlay.tsx +35 -17
- package/src/react/TourOverlayHost.tsx +39 -0
- package/src/react/TourProvider.tsx +45 -15
- package/src/react/TourTarget.tsx +4 -3
- package/src/react/context.ts +8 -1
- package/src/types.ts +92 -0
package/src/types.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface TourStep {
|
|
|
26
26
|
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
27
27
|
/** Default: 'next'. */
|
|
28
28
|
advanceOn?: StepAdvance;
|
|
29
|
+
/**
|
|
30
|
+
* Keep the highlighted element usable during the step (e.g. a form field the user
|
|
31
|
+
* fills in), while the step still moves on with Next (or its `advanceOn` event).
|
|
32
|
+
* Implied by `advanceOn: 'press'`.
|
|
33
|
+
*/
|
|
34
|
+
interactive?: boolean;
|
|
29
35
|
/** Show the step only when this returns true (checked as the step is reached). */
|
|
30
36
|
when?: (context: TourContext) => boolean;
|
|
31
37
|
/**
|
|
@@ -92,6 +98,8 @@ export interface TourTooltipProps {
|
|
|
92
98
|
* reports an event): don't show a Next button, tell the user what to do instead.
|
|
93
99
|
*/
|
|
94
100
|
isActionStep: boolean;
|
|
101
|
+
/** The highlighted element can be used during the step (e.g. a field to fill in). */
|
|
102
|
+
isInteractive: boolean;
|
|
95
103
|
/** The step has no target and is drawn in the middle of the screen. */
|
|
96
104
|
isCentered: boolean;
|
|
97
105
|
/** Next step, or finish (and mark seen) on the last one. */
|
|
@@ -118,6 +126,90 @@ export interface TourCatalogEntry {
|
|
|
118
126
|
kind: 'tour' | 'walkthrough';
|
|
119
127
|
}
|
|
120
128
|
|
|
129
|
+
/** Why a tour ended without being completed. */
|
|
130
|
+
export type TourExitReason =
|
|
131
|
+
/** Skip / Exit on the card, or ✕ on the resume chip. */
|
|
132
|
+
| 'user'
|
|
133
|
+
/** The Android back button. */
|
|
134
|
+
| 'back_button'
|
|
135
|
+
/** The app called `stopTour`. */
|
|
136
|
+
| 'app'
|
|
137
|
+
/** A step's element wasn't found in time (`onMissingTarget: 'end'`). */
|
|
138
|
+
| 'target_missing'
|
|
139
|
+
/** Another tour was started while this one was running. */
|
|
140
|
+
| 'replaced'
|
|
141
|
+
/** The tour was removed from `tours`. */
|
|
142
|
+
| 'removed';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Something that happened in a tour, for analytics (`onEvent`). Events of one
|
|
146
|
+
* run of a tour share a `runId`, so a backend can build funnels: started →
|
|
147
|
+
* step_shown (each step) → completed or exited (and where).
|
|
148
|
+
*/
|
|
149
|
+
export type TourEvent = {
|
|
150
|
+
/** Same for every event of one run of a tour (start to end). */
|
|
151
|
+
runId: string;
|
|
152
|
+
tourId: string;
|
|
153
|
+
tourKind: 'tour' | 'walkthrough';
|
|
154
|
+
/** When it happened (ms since epoch). */
|
|
155
|
+
timestamp: number;
|
|
156
|
+
} & (
|
|
157
|
+
| {
|
|
158
|
+
type: 'tour_started';
|
|
159
|
+
/** Started on its own (`autoStart`) or by the app (`startTour`). */
|
|
160
|
+
trigger: 'auto' | 'manual';
|
|
161
|
+
/** Number of steps shown in this run (steps whose `when` is false don't count). */
|
|
162
|
+
stepCount: number;
|
|
163
|
+
}
|
|
164
|
+
| {
|
|
165
|
+
type: 'step_shown';
|
|
166
|
+
/** Index in `tour.steps`. */
|
|
167
|
+
stepIndex: number;
|
|
168
|
+
/** 1-based position among the steps shown, out of `stepCount`. */
|
|
169
|
+
stepNumber: number;
|
|
170
|
+
stepCount: number;
|
|
171
|
+
/** Absent for a centred step. */
|
|
172
|
+
targetId?: string;
|
|
173
|
+
}
|
|
174
|
+
| {
|
|
175
|
+
type: 'tour_completed';
|
|
176
|
+
/** From start to end of the run. */
|
|
177
|
+
durationMs: number;
|
|
178
|
+
}
|
|
179
|
+
| {
|
|
180
|
+
type: 'tour_exited';
|
|
181
|
+
reason: TourExitReason;
|
|
182
|
+
/** The step the user was on. */
|
|
183
|
+
stepIndex: number;
|
|
184
|
+
durationMs: number;
|
|
185
|
+
}
|
|
186
|
+
| {
|
|
187
|
+
/** `startTour` was refused by the tour's `canStart`. */
|
|
188
|
+
type: 'tour_blocked';
|
|
189
|
+
reason: string;
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
type: 'tour_paused';
|
|
193
|
+
/** `pauseTour` was called, or the step's element went missing (`onMissingTarget: 'pause'`). */
|
|
194
|
+
reason: 'app' | 'target_missing';
|
|
195
|
+
stepIndex: number;
|
|
196
|
+
}
|
|
197
|
+
| {
|
|
198
|
+
type: 'tour_resumed';
|
|
199
|
+
/** The step it continues from. */
|
|
200
|
+
stepIndex: number;
|
|
201
|
+
}
|
|
202
|
+
| {
|
|
203
|
+
/** A step's element wasn't found in time; `outcome` is what the tour did about it. */
|
|
204
|
+
type: 'target_missing';
|
|
205
|
+
stepIndex: number;
|
|
206
|
+
targetId: string;
|
|
207
|
+
outcome: 'skip' | 'pause' | 'end';
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
export type TourEventType = TourEvent['type'];
|
|
212
|
+
|
|
121
213
|
export interface TourApi {
|
|
122
214
|
startTour: (tourId: string, options?: StartTourOptions) => void;
|
|
123
215
|
stopTour: (markAsSeen?: boolean) => void;
|