rn-smart-tour 1.0.7 → 1.1.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/LICENSE +21 -0
- package/README.md +71 -6
- package/lib/commonjs/DapContext.js +9 -0
- package/lib/commonjs/DapContext.js.map +1 -0
- package/lib/commonjs/DapOverlay.js +223 -0
- package/lib/commonjs/DapOverlay.js.map +1 -0
- package/lib/commonjs/DapProvider.js +350 -0
- package/lib/commonjs/DapProvider.js.map +1 -0
- package/lib/commonjs/DapScrollView.js +44 -0
- package/lib/commonjs/DapScrollView.js.map +1 -0
- package/lib/commonjs/DapTarget.js +116 -0
- package/lib/commonjs/DapTarget.js.map +1 -0
- package/lib/commonjs/index.js +72 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useDap.js +17 -0
- package/lib/commonjs/useDap.js.map +1 -0
- package/lib/module/DapContext.js +5 -0
- package/lib/module/DapContext.js.map +1 -0
- package/lib/module/DapOverlay.js +220 -0
- package/lib/module/DapOverlay.js.map +1 -0
- package/lib/module/DapProvider.js +343 -0
- package/lib/module/DapProvider.js.map +1 -0
- package/lib/module/DapScrollView.js +41 -0
- package/lib/module/DapScrollView.js.map +1 -0
- package/lib/module/DapTarget.js +109 -0
- package/lib/module/DapTarget.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useDap.js +12 -0
- package/lib/module/useDap.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/DapContext.d.ts +3 -0
- package/lib/typescript/commonjs/src/DapContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DapOverlay.d.ts +2 -0
- package/lib/typescript/commonjs/src/DapOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DapProvider.d.ts +15 -0
- package/lib/typescript/commonjs/src/DapProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DapScrollView.d.ts +9 -0
- package/lib/typescript/commonjs/src/DapScrollView.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs/src}/DapTarget.d.ts +4 -2
- package/lib/typescript/commonjs/src/DapTarget.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +7 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs/src}/types.d.ts +12 -1
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs/src}/useDap.d.ts +1 -0
- package/lib/typescript/commonjs/src/useDap.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/DapContext.d.ts +3 -0
- package/lib/typescript/module/src/DapContext.d.ts.map +1 -0
- package/lib/typescript/module/src/DapOverlay.d.ts +2 -0
- package/lib/typescript/module/src/DapOverlay.d.ts.map +1 -0
- package/lib/typescript/module/src/DapProvider.d.ts +15 -0
- package/lib/typescript/module/src/DapProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/DapScrollView.d.ts +9 -0
- package/lib/typescript/module/src/DapScrollView.d.ts.map +1 -0
- package/lib/typescript/module/src/DapTarget.d.ts +10 -0
- package/lib/typescript/module/src/DapTarget.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +7 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +48 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/lib/typescript/module/src/useDap.d.ts +2 -0
- package/lib/typescript/module/src/useDap.d.ts.map +1 -0
- package/package.json +91 -10
- package/src/DapContext.ts +4 -0
- package/src/DapOverlay.tsx +190 -0
- package/src/DapProvider.tsx +417 -0
- package/src/DapScrollView.tsx +43 -0
- package/src/DapTarget.tsx +124 -0
- package/src/types.ts +52 -0
- package/src/useDap.ts +10 -0
- package/dist/DapContext.d.ts +0 -2
- package/dist/DapContext.js +0 -5
- package/dist/DapOverlay.d.ts +0 -2
- package/dist/DapOverlay.js +0 -195
- package/dist/DapProvider.d.ts +0 -8
- package/dist/DapProvider.js +0 -227
- package/dist/DapScrollView.d.ts +0 -8
- package/dist/DapScrollView.js +0 -62
- package/dist/DapTarget.js +0 -137
- package/dist/index.js +0 -22
- package/dist/types.js +0 -2
- package/dist/useDap.js +0 -13
- /package/{dist/index.d.ts → src/index.ts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vishwas Gaur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# rn-smart-tour
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<b>
|
|
4
|
+
<b>Digital Adoption Platform (DAP) for React Native</b><br>
|
|
5
5
|
Easily add product tours, guided walkthroughs, and onboarding overlays without intrusive code changes.
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
- ⚡ **Auto-Start Engine**: Trigger tours instantly on mount with a smart debounce for layout stability.
|
|
15
15
|
- 💾 **Seen State Caching**: Persistent "only-once" logic with pluggable storage (AsyncStorage, MMKV, etc.).
|
|
16
16
|
- 🎨 **Smart Overlays**: Dynamic cutouts with Back/Next/Skip navigation and step indicators.
|
|
17
|
-
- 📜 **Auto-Scroll Support**:
|
|
17
|
+
- 📜 **Auto-Scroll Support**: Bring tour targets into view with `DapScrollView`; the highlight is re-measured after scrolling.
|
|
18
|
+
- 🛟 **Never Gets Stuck**: If a step's target isn't on screen, the tour ends cleanly instead of leaving an invisible, active tour.
|
|
19
|
+
- 🔁 **Replay on Demand**: `startTour(id, { force: true })`, `resetTour(id)` and `resetAll()` for Help buttons and settings screens.
|
|
18
20
|
|
|
19
21
|
---
|
|
20
22
|
|
|
@@ -24,6 +26,10 @@
|
|
|
24
26
|
npm install rn-smart-tour
|
|
25
27
|
```
|
|
26
28
|
|
|
29
|
+
Requires React 17+ and React Native 0.65+. No native code, so no `pod install` or rebuild is needed.
|
|
30
|
+
|
|
31
|
+
Unit-tested against React Native 0.73 (React 18), and checked in the example app on React Native 0.88 (React 19, New Architecture) on iOS.
|
|
32
|
+
|
|
27
33
|
---
|
|
28
34
|
|
|
29
35
|
## 🚀 Quick Start
|
|
@@ -68,14 +74,15 @@ const MyButton = () => (
|
|
|
68
74
|
```
|
|
69
75
|
|
|
70
76
|
### 3. Start the Tour
|
|
71
|
-
|
|
77
|
+
Set `autoStart: true` on a tour to show it the first time its first target appears, or start it yourself with the `useDap` hook.
|
|
72
78
|
|
|
73
79
|
```tsx
|
|
74
80
|
import { useDap } from 'rn-smart-tour';
|
|
75
81
|
|
|
76
82
|
const { startTour } = useDap();
|
|
77
83
|
// ...
|
|
78
|
-
|
|
84
|
+
// A tour is shown only once. `force: true` replays it, e.g. from a Help button.
|
|
85
|
+
<Button title="Help" onPress={() => startTour('welcome-tour', { force: true })} />
|
|
79
86
|
```
|
|
80
87
|
|
|
81
88
|
### 4. Enable Auto-Scroll (Optional)
|
|
@@ -92,6 +99,29 @@ import { DapScrollView } from 'rn-smart-tour';
|
|
|
92
99
|
</DapScrollView>
|
|
93
100
|
```
|
|
94
101
|
|
|
102
|
+
### 5. Remember Seen Tours (Optional)
|
|
103
|
+
Without a `storageAdapter`, "seen" state lasts until the app restarts. Pass any storage with `getItem` / `setItem`:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
107
|
+
|
|
108
|
+
<DapProvider tours={TOURS} storageAdapter={AsyncStorage}>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { MMKV } from 'react-native-mmkv';
|
|
113
|
+
|
|
114
|
+
const mmkv = new MMKV();
|
|
115
|
+
const mmkvAdapter = {
|
|
116
|
+
getItem: (key: string) => mmkv.getString(key) ?? null,
|
|
117
|
+
setItem: (key: string, value: string) => mmkv.set(key, value),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
<DapProvider tours={TOURS} storageAdapter={mmkvAdapter}>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Storage is read once on mount. Calls to `startTour`, `resetTour` and `resetAll` made before it has loaded are queued and run once it has, so an already-seen tour is never shown by mistake.
|
|
124
|
+
|
|
95
125
|
---
|
|
96
126
|
|
|
97
127
|
## 🧠 Technical Architecture
|
|
@@ -114,12 +144,30 @@ Measurements only trigger a re-render if the position changes by more than **1pt
|
|
|
114
144
|
|
|
115
145
|
When `autoStart: true` is enabled, the overlay waits **300ms** after registration. This allows the multi-pass system to settle on the final coordinates before the hole is cut into the backdrop.
|
|
116
146
|
|
|
147
|
+
A tour that is stopped (finished, skipped, or ended because a target was missing) is not auto-started again in the same app session. `startTour` still works, and `resetTour` makes it eligible again.
|
|
148
|
+
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary><b>Tour Lifecycle Rules</b></summary>
|
|
153
|
+
|
|
154
|
+
- **Skip**, **Finish** and the **Android back button** end the tour and mark it as seen.
|
|
155
|
+
- If a step's target is not on screen within `missingTargetTimeoutMs` (default **3000ms**), the tour ends **without** being marked as seen, and a warning is logged in development.
|
|
156
|
+
- When a step becomes active, its target is scrolled into view (inside a `DapScrollView`) and measured again, so the highlight matches where it is now.
|
|
157
|
+
|
|
117
158
|
</details>
|
|
118
159
|
|
|
119
160
|
---
|
|
120
161
|
|
|
121
162
|
## 🛠 API Reference
|
|
122
163
|
|
|
164
|
+
### DapProvider
|
|
165
|
+
| Property | Type | Default | Description |
|
|
166
|
+
|:---|:---|:---|:---|
|
|
167
|
+
| `tours` | `Record<string, Tour>` | — | All tours, keyed by id. |
|
|
168
|
+
| `storageAdapter` | `StorageAdapter` | — | Persists seen tours (AsyncStorage, MMKV, …). Read once on mount. |
|
|
169
|
+
| `missingTargetTimeoutMs` | `number` | `3000` | How long a step waits for its target before the tour ends. |
|
|
170
|
+
|
|
123
171
|
### Tour Configuration
|
|
124
172
|
| Property | Type | Description |
|
|
125
173
|
|:---|:---|:---|
|
|
@@ -128,7 +176,7 @@ When `autoStart: true` is enabled, the overlay waits **300ms** after registratio
|
|
|
128
176
|
| `steps` | `TourStep[]` | Sequence of highlight steps. |
|
|
129
177
|
|
|
130
178
|
### DapScrollView
|
|
131
|
-
A direct drop-in replacement for the React Native `ScrollView`. Supports all standard props
|
|
179
|
+
A direct drop-in replacement for the React Native `ScrollView`. Supports all standard props, and a `ref` is forwarded to the inner `ScrollView`.
|
|
132
180
|
| Property | Type | Description |
|
|
133
181
|
|:---|:---|:---|
|
|
134
182
|
| `children` | `React.Node` | Components to scroll. |
|
|
@@ -152,11 +200,14 @@ A direct drop-in replacement for the React Native `ScrollView`. Supports all sta
|
|
|
152
200
|
### `useDap()` Hook
|
|
153
201
|
| Method | Description |
|
|
154
202
|
|:---|:---|
|
|
155
|
-
| `startTour(id)` | Start a tour by ID. |
|
|
203
|
+
| `startTour(id, options?)` | Start a tour by ID. Does nothing if it was already seen, unless `{ force: true }`. |
|
|
156
204
|
| `stopTour(markAsSeen?)`| End tour. Pass `false` to keep it unread. |
|
|
157
205
|
| `nextStep()` / `prevStep()` | Manual step navigation. |
|
|
206
|
+
| `resetTour(id)` | Mark a tour as unseen so it can show (and auto-start) again. |
|
|
207
|
+
| `resetAll()` | Mark every tour as unseen. |
|
|
158
208
|
| `activeTour` | Current active tour object. |
|
|
159
209
|
| `currentStepIndex` | Current step number (0-indexed). |
|
|
210
|
+
| `seenTours` | `Record<string, boolean>` of tours already seen. |
|
|
160
211
|
|
|
161
212
|
---
|
|
162
213
|
|
|
@@ -164,6 +215,20 @@ A direct drop-in replacement for the React Native `ScrollView`. Supports all sta
|
|
|
164
215
|
|
|
165
216
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
166
217
|
|
|
218
|
+
```sh
|
|
219
|
+
npm install
|
|
220
|
+
npm run typecheck && npm run lint && npm test # what CI runs
|
|
221
|
+
npm run build # outputs lib/ (CommonJS, ES modules, types)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The `example/` app loads the library straight from `src/`, so changes show up without a build:
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
cd example && npm install
|
|
228
|
+
cd ios && pod install && cd ..
|
|
229
|
+
npm run ios # or: npm run android
|
|
230
|
+
```
|
|
231
|
+
|
|
167
232
|
---
|
|
168
233
|
|
|
169
234
|
<p align="center">
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DapContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const DapContext = exports.DapContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
9
|
+
//# sourceMappingURL=DapContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","DapContext","exports","createContext"],"sourceRoot":"../../src","sources":["DapContext.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,gBAAG,IAAAE,oBAAa,EAAwB,IAAI,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DapOverlay = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _DapContext = require("./DapContext.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/** Gap (pts) between the target highlight and the tooltip card. */const TOOLTIP_GAP = 10;
|
|
12
|
+
/** Max width of the tooltip card. */
|
|
13
|
+
const TOOLTIP_WIDTH = 280;
|
|
14
|
+
/** General padding from screen edges. */
|
|
15
|
+
const EDGE_PADDING = 16;
|
|
16
|
+
/** Rough estimated tooltip height — used for bottom-overflow checks. */
|
|
17
|
+
const ESTIMATED_TOOLTIP_HEIGHT = 150;
|
|
18
|
+
/** Rough vertical offset for left/right centering. */
|
|
19
|
+
const VERTICAL_CENTER_OFFSET = 60;
|
|
20
|
+
/** Min screen space reserved at the bottom when centering vertically. */
|
|
21
|
+
const VERTICAL_SAFE_BOTTOM = 120;
|
|
22
|
+
const DapOverlay = () => {
|
|
23
|
+
const context = (0, _react.useContext)(_DapContext.DapContext);
|
|
24
|
+
const {
|
|
25
|
+
width: screenWidth,
|
|
26
|
+
height: screenHeight
|
|
27
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
28
|
+
if (!context || !context.activeTour) return null;
|
|
29
|
+
const {
|
|
30
|
+
activeTour,
|
|
31
|
+
currentStepIndex,
|
|
32
|
+
targets,
|
|
33
|
+
nextStep,
|
|
34
|
+
prevStep,
|
|
35
|
+
stopTour
|
|
36
|
+
} = context;
|
|
37
|
+
const currentStep = activeTour.steps[currentStepIndex];
|
|
38
|
+
if (!currentStep) return null;
|
|
39
|
+
const targetId = currentStep.targetId;
|
|
40
|
+
const measurement = targets[targetId];
|
|
41
|
+
|
|
42
|
+
// If the target hasn't been measured yet, silently wait — don't show debug text in production.
|
|
43
|
+
if (!measurement) return null;
|
|
44
|
+
const {
|
|
45
|
+
x,
|
|
46
|
+
y,
|
|
47
|
+
width,
|
|
48
|
+
height
|
|
49
|
+
} = measurement;
|
|
50
|
+
const pos = currentStep.position || 'bottom';
|
|
51
|
+
const tooltipStyle = {
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
width: TOOLTIP_WIDTH,
|
|
54
|
+
backgroundColor: 'white',
|
|
55
|
+
padding: EDGE_PADDING,
|
|
56
|
+
borderRadius: 8,
|
|
57
|
+
shadowColor: '#000',
|
|
58
|
+
shadowOffset: {
|
|
59
|
+
width: 0,
|
|
60
|
+
height: 2
|
|
61
|
+
},
|
|
62
|
+
shadowOpacity: 0.25,
|
|
63
|
+
shadowRadius: 3.84,
|
|
64
|
+
elevation: 5,
|
|
65
|
+
// Horizontal centering by default
|
|
66
|
+
left: Math.max(EDGE_PADDING, Math.min(x + width / 2 - TOOLTIP_WIDTH / 2, screenWidth - TOOLTIP_WIDTH - EDGE_PADDING))
|
|
67
|
+
};
|
|
68
|
+
if (pos === 'top') {
|
|
69
|
+
tooltipStyle.bottom = screenHeight - y + TOOLTIP_GAP;
|
|
70
|
+
} else if (pos === 'left') {
|
|
71
|
+
tooltipStyle.right = screenWidth - x + TOOLTIP_GAP;
|
|
72
|
+
tooltipStyle.left = undefined; // Clear the default left
|
|
73
|
+
tooltipStyle.width = Math.min(TOOLTIP_WIDTH, x - EDGE_PADDING * 2);
|
|
74
|
+
tooltipStyle.top = Math.max(EDGE_PADDING, Math.min(y + height / 2 - VERTICAL_CENTER_OFFSET, screenHeight - VERTICAL_SAFE_BOTTOM));
|
|
75
|
+
} else if (pos === 'right') {
|
|
76
|
+
tooltipStyle.left = x + width + TOOLTIP_GAP;
|
|
77
|
+
tooltipStyle.width = Math.min(TOOLTIP_WIDTH, screenWidth - (x + width) - EDGE_PADDING * 2);
|
|
78
|
+
tooltipStyle.top = Math.max(EDGE_PADDING, Math.min(y + height / 2 - VERTICAL_CENTER_OFFSET, screenHeight - VERTICAL_SAFE_BOTTOM));
|
|
79
|
+
} else {
|
|
80
|
+
// bottom (default)
|
|
81
|
+
tooltipStyle.top = y + height + TOOLTIP_GAP;
|
|
82
|
+
// Check if it spills off bottom of screen
|
|
83
|
+
if (tooltipStyle.top + ESTIMATED_TOOLTIP_HEIGHT > screenHeight) {
|
|
84
|
+
tooltipStyle.top = undefined;
|
|
85
|
+
tooltipStyle.bottom = EDGE_PADDING; // Pin to bottom if it overflows
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const isFirstStep = currentStepIndex === 0;
|
|
89
|
+
const isLastStep = currentStepIndex === activeTour.steps.length - 1;
|
|
90
|
+
return (
|
|
91
|
+
/*#__PURE__*/
|
|
92
|
+
// onRequestClose: the Android back button dismisses the tour, like "Skip".
|
|
93
|
+
(0, _jsxRuntime.jsx)(_reactNative.Modal, {
|
|
94
|
+
transparent: true,
|
|
95
|
+
visible: true,
|
|
96
|
+
animationType: "fade",
|
|
97
|
+
onRequestClose: () => stopTour(),
|
|
98
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
99
|
+
style: [styles.fullscreen, {
|
|
100
|
+
width: screenWidth,
|
|
101
|
+
height: screenHeight
|
|
102
|
+
}],
|
|
103
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
104
|
+
style: [styles.backdrop, {
|
|
105
|
+
top: 0,
|
|
106
|
+
left: 0,
|
|
107
|
+
right: 0,
|
|
108
|
+
height: Math.max(0, y)
|
|
109
|
+
}]
|
|
110
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
111
|
+
style: [styles.backdrop, {
|
|
112
|
+
top: y + height,
|
|
113
|
+
left: 0,
|
|
114
|
+
right: 0,
|
|
115
|
+
bottom: 0
|
|
116
|
+
}]
|
|
117
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
118
|
+
style: [styles.backdrop, {
|
|
119
|
+
top: y,
|
|
120
|
+
left: 0,
|
|
121
|
+
width: Math.max(0, x),
|
|
122
|
+
height
|
|
123
|
+
}]
|
|
124
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
125
|
+
style: [styles.backdrop, {
|
|
126
|
+
top: y,
|
|
127
|
+
left: x + width,
|
|
128
|
+
right: 0,
|
|
129
|
+
height
|
|
130
|
+
}]
|
|
131
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
132
|
+
style: tooltipStyle,
|
|
133
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
134
|
+
style: styles.title,
|
|
135
|
+
children: currentStep.title
|
|
136
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
137
|
+
style: styles.description,
|
|
138
|
+
children: currentStep.description
|
|
139
|
+
}), activeTour.steps.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
140
|
+
style: styles.stepIndicator,
|
|
141
|
+
children: [currentStepIndex + 1, " / ", activeTour.steps.length]
|
|
142
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
143
|
+
style: styles.actions,
|
|
144
|
+
children: [!isLastStep && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
145
|
+
onPress: () => stopTour(),
|
|
146
|
+
style: styles.actionBtn,
|
|
147
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
148
|
+
style: styles.actionText,
|
|
149
|
+
children: "Skip"
|
|
150
|
+
})
|
|
151
|
+
}), !isFirstStep && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
152
|
+
onPress: prevStep,
|
|
153
|
+
style: styles.actionBtn,
|
|
154
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
155
|
+
style: styles.actionText,
|
|
156
|
+
children: "Back"
|
|
157
|
+
})
|
|
158
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
159
|
+
onPress: nextStep,
|
|
160
|
+
style: [styles.actionBtn, styles.primaryBtn],
|
|
161
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
162
|
+
style: [styles.actionText, styles.primaryText],
|
|
163
|
+
children: isLastStep ? 'Finish' : 'Next'
|
|
164
|
+
})
|
|
165
|
+
})]
|
|
166
|
+
})]
|
|
167
|
+
})]
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
exports.DapOverlay = DapOverlay;
|
|
173
|
+
const styles = _reactNative.StyleSheet.create({
|
|
174
|
+
fullscreen: {
|
|
175
|
+
position: 'absolute',
|
|
176
|
+
top: 0,
|
|
177
|
+
left: 0
|
|
178
|
+
},
|
|
179
|
+
backdrop: {
|
|
180
|
+
position: 'absolute',
|
|
181
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)'
|
|
182
|
+
},
|
|
183
|
+
title: {
|
|
184
|
+
fontSize: 16,
|
|
185
|
+
fontWeight: 'bold',
|
|
186
|
+
marginBottom: 8,
|
|
187
|
+
color: '#333'
|
|
188
|
+
},
|
|
189
|
+
description: {
|
|
190
|
+
fontSize: 14,
|
|
191
|
+
color: '#666',
|
|
192
|
+
marginBottom: 8
|
|
193
|
+
},
|
|
194
|
+
stepIndicator: {
|
|
195
|
+
fontSize: 12,
|
|
196
|
+
color: '#999',
|
|
197
|
+
textAlign: 'right',
|
|
198
|
+
marginBottom: 8
|
|
199
|
+
},
|
|
200
|
+
actions: {
|
|
201
|
+
flexDirection: 'row',
|
|
202
|
+
justifyContent: 'flex-end',
|
|
203
|
+
marginTop: 10
|
|
204
|
+
},
|
|
205
|
+
actionBtn: {
|
|
206
|
+
paddingHorizontal: 15,
|
|
207
|
+
paddingVertical: 8,
|
|
208
|
+
marginLeft: 10,
|
|
209
|
+
borderRadius: 4
|
|
210
|
+
},
|
|
211
|
+
primaryBtn: {
|
|
212
|
+
backgroundColor: '#007AFF'
|
|
213
|
+
},
|
|
214
|
+
actionText: {
|
|
215
|
+
color: '#666',
|
|
216
|
+
fontWeight: '600'
|
|
217
|
+
},
|
|
218
|
+
primaryText: {
|
|
219
|
+
color: 'white',
|
|
220
|
+
fontWeight: '600'
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
//# sourceMappingURL=DapOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_DapContext","_jsxRuntime","TOOLTIP_GAP","TOOLTIP_WIDTH","EDGE_PADDING","ESTIMATED_TOOLTIP_HEIGHT","VERTICAL_CENTER_OFFSET","VERTICAL_SAFE_BOTTOM","DapOverlay","context","useContext","DapContext","width","screenWidth","height","screenHeight","useWindowDimensions","activeTour","currentStepIndex","targets","nextStep","prevStep","stopTour","currentStep","steps","targetId","measurement","x","y","pos","position","tooltipStyle","backgroundColor","padding","borderRadius","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","left","Math","max","min","bottom","right","undefined","top","isFirstStep","isLastStep","length","jsx","Modal","transparent","visible","animationType","onRequestClose","children","jsxs","View","style","styles","fullscreen","backdrop","Text","title","description","stepIndicator","actions","TouchableOpacity","onPress","actionBtn","actionText","primaryBtn","primaryText","exports","StyleSheet","create","fontSize","fontWeight","marginBottom","color","textAlign","flexDirection","justifyContent","marginTop","paddingHorizontal","paddingVertical","marginLeft"],"sourceRoot":"../../src","sources":["DapOverlay.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAA0C,IAAAG,WAAA,GAAAH,OAAA;AAE1C,mEACA,MAAMI,WAAW,GAAG,EAAE;AACtB;AACA,MAAMC,aAAa,GAAG,GAAG;AACzB;AACA,MAAMC,YAAY,GAAG,EAAE;AACvB;AACA,MAAMC,wBAAwB,GAAG,GAAG;AACpC;AACA,MAAMC,sBAAsB,GAAG,EAAE;AACjC;AACA,MAAMC,oBAAoB,GAAG,GAAG;AAEzB,MAAMC,UAAU,GAAGA,CAAA,KAAM;EAC9B,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACC,sBAAU,CAAC;EACtC,MAAM;IAAEC,KAAK,EAAEC,WAAW;IAAEC,MAAM,EAAEC;EAAa,CAAC,GAAG,IAAAC,gCAAmB,EAAC,CAAC;EAE1E,IAAI,CAACP,OAAO,IAAI,CAACA,OAAO,CAACQ,UAAU,EAAE,OAAO,IAAI;EAEhD,MAAM;IAAEA,UAAU;IAAEC,gBAAgB;IAAEC,OAAO;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGb,OAAO;EACvF,MAAMc,WAAW,GAAGN,UAAU,CAACO,KAAK,CAACN,gBAAgB,CAAC;EAEtD,IAAI,CAACK,WAAW,EAAE,OAAO,IAAI;EAE7B,MAAME,QAAQ,GAAGF,WAAW,CAACE,QAAQ;EACrC,MAAM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