@korsolutions/guidon 1.0.0 → 1.0.2

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.
Files changed (144) hide show
  1. package/README.md +11 -11
  2. package/dist/commonjs/babel.config.js +15 -0
  3. package/dist/commonjs/babel.config.js.map +1 -0
  4. package/dist/commonjs/bob.config.js +11 -0
  5. package/dist/commonjs/bob.config.js.map +1 -0
  6. package/dist/commonjs/components/GuidonOverlay.js +206 -0
  7. package/dist/commonjs/components/GuidonOverlay.js.map +1 -0
  8. package/dist/commonjs/components/GuidonProvider.js +157 -0
  9. package/dist/commonjs/components/GuidonProvider.js.map +1 -0
  10. package/dist/commonjs/components/GuidonTarget.js +108 -0
  11. package/dist/commonjs/components/GuidonTarget.js.map +1 -0
  12. package/dist/commonjs/components/GuidonTooltip.js +422 -0
  13. package/dist/commonjs/components/GuidonTooltip.js.map +1 -0
  14. package/dist/commonjs/components/index.js +40 -0
  15. package/dist/commonjs/components/index.js.map +1 -0
  16. package/dist/commonjs/hooks/index.js +13 -0
  17. package/dist/commonjs/hooks/index.js.map +1 -0
  18. package/dist/commonjs/hooks/useGuidonRef.js +132 -0
  19. package/dist/commonjs/hooks/useGuidonRef.js.map +1 -0
  20. package/dist/commonjs/index.js +143 -0
  21. package/dist/commonjs/index.js.map +1 -0
  22. package/dist/commonjs/package.json +1 -0
  23. package/dist/commonjs/persistence/adapters.js +213 -0
  24. package/dist/commonjs/persistence/adapters.js.map +1 -0
  25. package/dist/commonjs/persistence/hooks.js +153 -0
  26. package/dist/commonjs/persistence/hooks.js.map +1 -0
  27. package/dist/commonjs/persistence/index.js +28 -0
  28. package/dist/commonjs/persistence/index.js.map +1 -0
  29. package/dist/commonjs/store.js +305 -0
  30. package/dist/commonjs/store.js.map +1 -0
  31. package/dist/commonjs/tsconfig.json +32 -0
  32. package/dist/commonjs/types.js +6 -0
  33. package/dist/commonjs/types.js.map +1 -0
  34. package/dist/module/babel.config.js +15 -0
  35. package/dist/module/babel.config.js.map +1 -0
  36. package/dist/module/bob.config.js +11 -0
  37. package/dist/module/bob.config.js.map +1 -0
  38. package/dist/module/components/GuidonOverlay.js +201 -0
  39. package/dist/module/components/GuidonOverlay.js.map +1 -0
  40. package/dist/module/components/GuidonProvider.js +152 -0
  41. package/dist/module/components/GuidonProvider.js.map +1 -0
  42. package/dist/module/components/GuidonTarget.js +104 -0
  43. package/dist/module/components/GuidonTarget.js.map +1 -0
  44. package/dist/module/components/GuidonTooltip.js +417 -0
  45. package/dist/module/components/GuidonTooltip.js.map +1 -0
  46. package/dist/module/components/index.js +7 -0
  47. package/dist/module/components/index.js.map +1 -0
  48. package/dist/module/hooks/index.js +4 -0
  49. package/dist/module/hooks/index.js.map +1 -0
  50. package/dist/module/hooks/useGuidonRef.js +129 -0
  51. package/dist/module/hooks/useGuidonRef.js.map +1 -0
  52. package/dist/module/index.js +17 -0
  53. package/dist/module/index.js.map +1 -0
  54. package/dist/module/package.json +1 -0
  55. package/dist/module/persistence/adapters.js +203 -0
  56. package/dist/module/persistence/adapters.js.map +1 -0
  57. package/dist/module/persistence/hooks.js +148 -0
  58. package/dist/module/persistence/hooks.js.map +1 -0
  59. package/dist/module/persistence/index.js +5 -0
  60. package/dist/module/persistence/index.js.map +1 -0
  61. package/dist/module/store.js +295 -0
  62. package/dist/module/store.js.map +1 -0
  63. package/dist/module/tsconfig.json +32 -0
  64. package/dist/module/types.js +4 -0
  65. package/dist/module/types.js.map +1 -0
  66. package/dist/typescript/commonjs/components/GuidonOverlay.d.ts +9 -0
  67. package/dist/typescript/commonjs/components/GuidonOverlay.d.ts.map +1 -0
  68. package/dist/typescript/commonjs/components/GuidonProvider.d.ts +14 -0
  69. package/dist/typescript/commonjs/components/GuidonProvider.d.ts.map +1 -0
  70. package/dist/typescript/commonjs/components/GuidonTarget.d.ts +7 -0
  71. package/dist/typescript/commonjs/components/GuidonTarget.d.ts.map +1 -0
  72. package/dist/typescript/commonjs/components/GuidonTooltip.d.ts +24 -0
  73. package/dist/typescript/commonjs/components/GuidonTooltip.d.ts.map +1 -0
  74. package/dist/typescript/commonjs/components/index.d.ts +5 -0
  75. package/dist/typescript/commonjs/components/index.d.ts.map +1 -0
  76. package/dist/typescript/commonjs/hooks/index.d.ts +2 -0
  77. package/dist/typescript/commonjs/hooks/index.d.ts.map +1 -0
  78. package/dist/typescript/commonjs/hooks/useGuidonRef.d.ts +35 -0
  79. package/dist/typescript/commonjs/hooks/useGuidonRef.d.ts.map +1 -0
  80. package/dist/typescript/commonjs/index.d.ts +7 -0
  81. package/dist/typescript/commonjs/index.d.ts.map +1 -0
  82. package/dist/typescript/commonjs/package.json +1 -0
  83. package/dist/typescript/commonjs/persistence/adapters.d.ts +57 -0
  84. package/dist/typescript/commonjs/persistence/adapters.d.ts.map +1 -0
  85. package/dist/typescript/commonjs/persistence/hooks.d.ts +29 -0
  86. package/dist/typescript/commonjs/persistence/hooks.d.ts.map +1 -0
  87. package/dist/typescript/commonjs/persistence/index.d.ts +3 -0
  88. package/dist/typescript/commonjs/persistence/index.d.ts.map +1 -0
  89. package/dist/typescript/commonjs/store.d.ts +89 -0
  90. package/dist/typescript/commonjs/store.d.ts.map +1 -0
  91. package/dist/{index-D_JFvCIg.d.mts → typescript/commonjs/types.d.ts} +40 -104
  92. package/dist/typescript/commonjs/types.d.ts.map +1 -0
  93. package/dist/typescript/module/components/GuidonOverlay.d.ts +9 -0
  94. package/dist/typescript/module/components/GuidonOverlay.d.ts.map +1 -0
  95. package/dist/typescript/module/components/GuidonProvider.d.ts +14 -0
  96. package/dist/typescript/module/components/GuidonProvider.d.ts.map +1 -0
  97. package/dist/typescript/module/components/GuidonTarget.d.ts +7 -0
  98. package/dist/typescript/module/components/GuidonTarget.d.ts.map +1 -0
  99. package/dist/typescript/module/components/GuidonTooltip.d.ts +24 -0
  100. package/dist/typescript/module/components/GuidonTooltip.d.ts.map +1 -0
  101. package/dist/typescript/module/components/index.d.ts +5 -0
  102. package/dist/typescript/module/components/index.d.ts.map +1 -0
  103. package/dist/typescript/module/hooks/index.d.ts +2 -0
  104. package/dist/typescript/module/hooks/index.d.ts.map +1 -0
  105. package/dist/typescript/module/hooks/useGuidonRef.d.ts +35 -0
  106. package/dist/typescript/module/hooks/useGuidonRef.d.ts.map +1 -0
  107. package/dist/typescript/module/index.d.ts +7 -0
  108. package/dist/typescript/module/index.d.ts.map +1 -0
  109. package/dist/typescript/module/package.json +1 -0
  110. package/dist/typescript/module/persistence/adapters.d.ts +57 -0
  111. package/dist/typescript/module/persistence/adapters.d.ts.map +1 -0
  112. package/dist/typescript/module/persistence/hooks.d.ts +29 -0
  113. package/dist/typescript/module/persistence/hooks.d.ts.map +1 -0
  114. package/dist/typescript/module/persistence/index.d.ts +3 -0
  115. package/dist/typescript/module/persistence/index.d.ts.map +1 -0
  116. package/dist/typescript/module/store.d.ts +89 -0
  117. package/dist/typescript/module/store.d.ts.map +1 -0
  118. package/dist/{index-D_JFvCIg.d.ts → typescript/module/types.d.ts} +40 -104
  119. package/dist/typescript/module/types.d.ts.map +1 -0
  120. package/package.json +25 -13
  121. package/src/babel.config.js +18 -0
  122. package/src/bob.config.js +14 -0
  123. package/src/components/GuidonOverlay.tsx +60 -4
  124. package/src/components/GuidonProvider.tsx +29 -1
  125. package/src/components/GuidonTarget.tsx +26 -16
  126. package/src/components/GuidonTooltip.tsx +143 -9
  127. package/src/hooks/index.ts +1 -0
  128. package/src/hooks/useGuidonRef.ts +154 -0
  129. package/src/index.ts +6 -0
  130. package/src/store.ts +40 -0
  131. package/src/tsconfig.json +32 -0
  132. package/src/types.ts +32 -2
  133. package/dist/index.d.mts +0 -128
  134. package/dist/index.d.ts +0 -128
  135. package/dist/index.js +0 -1098
  136. package/dist/index.js.map +0 -1
  137. package/dist/index.mjs +0 -1073
  138. package/dist/index.mjs.map +0 -1
  139. package/dist/persistence/index.d.mts +0 -2
  140. package/dist/persistence/index.d.ts +0 -2
  141. package/dist/persistence/index.js +0 -300
  142. package/dist/persistence/index.js.map +0 -1
  143. package/dist/persistence/index.mjs +0 -291
  144. package/dist/persistence/index.mjs.map +0 -1
package/README.md CHANGED
@@ -5,9 +5,9 @@ A cross-platform walkthrough/onboarding component library for React Native with
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- yarn add @guidon
8
+ yarn add @korsolutions/guidon
9
9
  # or
10
- npm install @guidon
10
+ npm install @korsolutions/guidon
11
11
  ```
12
12
 
13
13
  ### Peer Dependencies
@@ -23,7 +23,7 @@ yarn add react react-native react-native-reanimated react-native-safe-area-conte
23
23
  ### 1. Define Your Guidon Steps
24
24
 
25
25
  ```tsx
26
- import type { GuidonConfig } from '@guidon';
26
+ import type { GuidonConfig } from '@korsolutions/guidon';
27
27
 
28
28
  const exploreGuidonConfig: GuidonConfig = {
29
29
  id: 'explore-guidon',
@@ -63,7 +63,7 @@ const exploreGuidonConfig: GuidonConfig = {
63
63
  ### 2. Wrap Your Screen with GuidonProvider
64
64
 
65
65
  ```tsx
66
- import { GuidonProvider } from 'guidon';
66
+ import { GuidonProvider } from '@korsolutions/guidon';
67
67
 
68
68
  function ExploreScreen() {
69
69
  return (
@@ -80,7 +80,7 @@ function ExploreScreen() {
80
80
  ### 3. Mark Target Elements with GuidonTarget
81
81
 
82
82
  ```tsx
83
- import { GuidonTarget } from 'guidon';
83
+ import { GuidonTarget } from '@korsolutions/guidon';
84
84
 
85
85
  function SearchButton() {
86
86
  return (
@@ -104,7 +104,7 @@ import {
104
104
  GuidonProvider,
105
105
  createLocalStorageAdapter,
106
106
  createAsyncStorageAdapter,
107
- } from 'guidon';
107
+ } from '@korsolutions/guidon';
108
108
  import AsyncStorage from '@react-native-async-storage/async-storage';
109
109
 
110
110
  // For web (localStorage)
@@ -128,7 +128,7 @@ function App() {
128
128
  ### Creating a Custom API Adapter
129
129
 
130
130
  ```tsx
131
- import { createApiAdapter } from 'guidon';
131
+ import { createApiAdapter } from '@korsolutions/guidon';
132
132
 
133
133
  const apiAdapter = createApiAdapter({
134
134
  loadProgress: async (guidonId) => {
@@ -154,7 +154,7 @@ const apiAdapter = createApiAdapter({
154
154
  ### Combining Multiple Adapters
155
155
 
156
156
  ```tsx
157
- import { createCompositeAdapter, createLocalStorageAdapter } from 'guidon';
157
+ import { createCompositeAdapter, createLocalStorageAdapter } from '@korsolutions/guidon';
158
158
 
159
159
  // Save to both local storage and API
160
160
  const compositeAdapter = createCompositeAdapter([
@@ -230,7 +230,7 @@ interface GuidonTheme {
230
230
  ### Using the Context Hook
231
231
 
232
232
  ```tsx
233
- import { useGuidonContext } from 'guidon';
233
+ import { useGuidonContext } from '@korsolutions/guidon';
234
234
 
235
235
  function ReplayButton() {
236
236
  const { replay, isCompleted } = useGuidonContext();
@@ -248,7 +248,7 @@ function ReplayButton() {
248
248
  ### Using the Guidon API (Outside React)
249
249
 
250
250
  ```tsx
251
- import { Guidon } from 'guidon';
251
+ import { Guidon } from '@korsolutions/guidon';
252
252
 
253
253
  // Start programmatically
254
254
  Guidon.start();
@@ -271,7 +271,7 @@ import {
271
271
  useGuidonActive,
272
272
  useGuidonStep,
273
273
  useGuidonProgress,
274
- } from 'guidon';
274
+ } from '@korsolutions/guidon';
275
275
 
276
276
  function GuidonStatus() {
277
277
  const isActive = useGuidonActive();
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ module.exports = function (api) {
4
+ api.cache(true);
5
+ return {
6
+ presets: ["module:react-native-builder-bob/babel-preset"],
7
+ plugins: [[require.resolve("babel-plugin-module-resolver"), {
8
+ root: ["./src"],
9
+ alias: {
10
+ "@": "./src"
11
+ }
12
+ }]]
13
+ };
14
+ };
15
+ //# sourceMappingURL=babel.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["module","exports","api","cache","presets","plugins","require","resolve","root","alias"],"sourceRoot":"../../src","sources":["babel.config.js"],"mappings":";;AAAAA,MAAM,CAACC,OAAO,GAAG,UAAUC,GAAG,EAAE;EAC9BA,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC;EAEf,OAAO;IACLC,OAAO,EAAE,CAAC,8CAA8C,CAAC;IACzDC,OAAO,EAAE,CACP,CACEC,OAAO,CAACC,OAAO,CAAC,8BAA8B,CAAC,EAC/C;MACEC,IAAI,EAAE,CAAC,OAAO,CAAC;MACfC,KAAK,EAAE;QACL,GAAG,EAAE;MACP;IACF,CAAC,CACF;EAEL,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ source: "src",
5
+ output: "dist",
6
+ targets: [["module", {
7
+ esm: true,
8
+ configFile: true
9
+ }], "typescript"]
10
+ };
11
+ //# sourceMappingURL=bob.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["module","exports","source","output","targets","esm","configFile"],"sourceRoot":"../../src","sources":["bob.config.js"],"mappings":";;AAAAA,MAAM,CAACC,OAAO,GAAG;EACfC,MAAM,EAAE,KAAK;EACbC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAE,CACP,CACE,QAAQ,EACR;IACEC,GAAG,EAAE,IAAI;IACTC,UAAU,EAAE;EACd,CAAC,CACF,EACD,YAAY;AAEhB,CAAC","ignoreList":[]}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GuidonOverlay = GuidonOverlay;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
11
+ var _store = require("../store.js");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ const AnimatedSvg = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.default);
15
+ const DEFAULT_THEME = {
16
+ backdropColor: '#000000',
17
+ backdropOpacity: 0.75,
18
+ spotlightBorderRadius: 8,
19
+ spotlightPadding: 8
20
+ };
21
+ function GuidonOverlay({
22
+ theme = {},
23
+ animationDuration = 300,
24
+ onBackdropPress
25
+ }) {
26
+ const isActive = (0, _store.useGuidonStore)(state => state.isActive);
27
+ const config = (0, _store.useGuidonStore)(state => state.config);
28
+ const currentStepIndex = (0, _store.useGuidonStore)(state => state.currentStepIndex);
29
+ const targetMeasurements = (0, _store.useGuidonStore)(state => state.targetMeasurements);
30
+
31
+ // Check for floating or waiting states
32
+ const isFloatingStep = (0, _store.useIsFloatingStep)();
33
+ const waitingState = (0, _store.useWaitingState)();
34
+ const isWaiting = waitingState?.isWaiting ?? false;
35
+ const mergedTheme = {
36
+ ...DEFAULT_THEME,
37
+ ...theme
38
+ };
39
+ const {
40
+ width: screenWidth,
41
+ height: screenHeight
42
+ } = _reactNative.Dimensions.get('window');
43
+
44
+ // Get current step's target measurements
45
+ const currentStep = config?.steps[currentStepIndex];
46
+ const currentTargetId = currentStep?.targetId;
47
+ const measurements = currentTargetId ? targetMeasurements[currentTargetId] : undefined;
48
+
49
+ // Determine if we should show full backdrop (no spotlight cutout)
50
+ const showFullBackdrop = isFloatingStep || isWaiting;
51
+
52
+ // Calculate spotlight dimensions with padding
53
+ const spotlight = (0, _react.useMemo)(() => {
54
+ if (!measurements) {
55
+ return {
56
+ x: 0,
57
+ y: 0,
58
+ width: 0,
59
+ height: 0
60
+ };
61
+ }
62
+ return {
63
+ x: measurements.x - mergedTheme.spotlightPadding,
64
+ y: measurements.y - mergedTheme.spotlightPadding,
65
+ width: measurements.width + mergedTheme.spotlightPadding * 2,
66
+ height: measurements.height + mergedTheme.spotlightPadding * 2
67
+ };
68
+ }, [measurements, mergedTheme.spotlightPadding]);
69
+
70
+ // Animated styles for fade in/out
71
+ // Show backdrop for: normal steps with measurements, floating steps, or waiting states
72
+ const shouldShow = isActive && (measurements || showFullBackdrop);
73
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
74
+ return {
75
+ opacity: (0, _reactNativeReanimated.withTiming)(shouldShow ? 1 : 0, {
76
+ duration: animationDuration,
77
+ easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
78
+ })
79
+ };
80
+ }, [shouldShow, animationDuration]);
81
+ if (!isActive) {
82
+ return null;
83
+ }
84
+
85
+ // Render full backdrop without spotlight for floating steps or waiting states
86
+ if (showFullBackdrop) {
87
+ if (_reactNative.Platform.OS === 'web') {
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
89
+ onPress: onBackdropPress,
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
91
+ style: [styles.container, animatedStyle],
92
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
93
+ style: {
94
+ position: 'absolute',
95
+ inset: 0,
96
+ backgroundColor: mergedTheme.backdropColor,
97
+ opacity: mergedTheme.backdropOpacity
98
+ }
99
+ })
100
+ })
101
+ });
102
+ }
103
+
104
+ // Native: full backdrop without cutout
105
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
106
+ onPress: onBackdropPress,
107
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedSvg, {
108
+ style: [styles.container, animatedStyle],
109
+ width: screenWidth,
110
+ height: screenHeight,
111
+ viewBox: `0 0 ${screenWidth} ${screenHeight}`,
112
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
113
+ x: "0",
114
+ y: "0",
115
+ width: "100%",
116
+ height: "100%",
117
+ fill: mergedTheme.backdropColor,
118
+ fillOpacity: mergedTheme.backdropOpacity
119
+ })
120
+ })
121
+ });
122
+ }
123
+
124
+ // If we have a target but no measurements yet, don't render anything
125
+ if (!measurements) {
126
+ return null;
127
+ }
128
+
129
+ // For web, use a different approach with CSS
130
+ if (_reactNative.Platform.OS === 'web') {
131
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
132
+ onPress: onBackdropPress,
133
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
134
+ style: [styles.container, animatedStyle],
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
136
+ style: {
137
+ position: 'absolute',
138
+ inset: 0,
139
+ backgroundColor: mergedTheme.backdropColor,
140
+ opacity: mergedTheme.backdropOpacity,
141
+ clipPath: `polygon(
142
+ 0% 0%,
143
+ 0% 100%,
144
+ ${spotlight.x}px 100%,
145
+ ${spotlight.x}px ${spotlight.y}px,
146
+ ${spotlight.x + spotlight.width}px ${spotlight.y}px,
147
+ ${spotlight.x + spotlight.width}px ${spotlight.y + spotlight.height}px,
148
+ ${spotlight.x}px ${spotlight.y + spotlight.height}px,
149
+ ${spotlight.x}px 100%,
150
+ 100% 100%,
151
+ 100% 0%
152
+ )`
153
+ }
154
+ })
155
+ })
156
+ });
157
+ }
158
+
159
+ // Native implementation using SVG mask
160
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
161
+ onPress: onBackdropPress,
162
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(AnimatedSvg, {
163
+ style: [styles.container, animatedStyle],
164
+ width: screenWidth,
165
+ height: screenHeight,
166
+ viewBox: `0 0 ${screenWidth} ${screenHeight}`,
167
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Defs, {
168
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.Mask, {
169
+ id: "spotlight-mask",
170
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
171
+ x: "0",
172
+ y: "0",
173
+ width: "100%",
174
+ height: "100%",
175
+ fill: "white"
176
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
177
+ x: spotlight.x,
178
+ y: spotlight.y,
179
+ width: spotlight.width,
180
+ height: spotlight.height,
181
+ rx: mergedTheme.spotlightBorderRadius,
182
+ ry: mergedTheme.spotlightBorderRadius,
183
+ fill: "black"
184
+ })]
185
+ })
186
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.G, {
187
+ mask: "url(#spotlight-mask)",
188
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
189
+ x: "0",
190
+ y: "0",
191
+ width: "100%",
192
+ height: "100%",
193
+ fill: mergedTheme.backdropColor,
194
+ fillOpacity: mergedTheme.backdropOpacity
195
+ })
196
+ })]
197
+ })
198
+ });
199
+ }
200
+ const styles = _reactNative.StyleSheet.create({
201
+ container: {
202
+ ..._reactNative.StyleSheet.absoluteFillObject,
203
+ zIndex: 999
204
+ }
205
+ });
206
+ //# sourceMappingURL=GuidonOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_reactNativeSvg","_store","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AnimatedSvg","Animated","createAnimatedComponent","Svg","DEFAULT_THEME","backdropColor","backdropOpacity","spotlightBorderRadius","spotlightPadding","GuidonOverlay","theme","animationDuration","onBackdropPress","isActive","useGuidonStore","state","config","currentStepIndex","targetMeasurements","isFloatingStep","useIsFloatingStep","waitingState","useWaitingState","isWaiting","mergedTheme","width","screenWidth","height","screenHeight","Dimensions","currentStep","steps","currentTargetId","targetId","measurements","undefined","showFullBackdrop","spotlight","useMemo","x","y","shouldShow","animatedStyle","useAnimatedStyle","opacity","withTiming","duration","easing","Easing","inOut","ease","Platform","OS","jsx","TouchableWithoutFeedback","onPress","children","View","style","styles","container","position","inset","backgroundColor","viewBox","Rect","fill","fillOpacity","clipPath","jsxs","Defs","Mask","id","rx","ry","G","mask","StyleSheet","create","absoluteFillObject","zIndex"],"sourceRoot":"../../../src","sources":["components/GuidonOverlay.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAMA,IAAAE,sBAAA,GAAAC,uBAAA,CAAAH,OAAA;AAKA,IAAAI,eAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA8E,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAG,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MA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AC3E,eAAA,CAAAuF,IAAI;UACH1B,CAAC,EAAC,GAAG;UACLC,CAAC,EAAC,GAAG;UACLf,KAAK,EAAC,MAAM;UACZE,MAAM,EAAC,MAAM;UACbuC,IAAI,EAAE1C,WAAW,CAACnB,aAAc;UAChC8D,WAAW,EAAE3C,WAAW,CAAClB;QAAgB,CAC1C;MAAC,CACD,CAAC;IAAA,CACO;EAAC,CACU,CAAC;AAE/B;AAEA,MAAMqD,MAAM,GAAGkB,uBAAU,CAACC,MAAM,CAAC;EAC/BlB,SAAS,EAAE;IACT,GAAGiB,uBAAU,CAACE,kBAAkB;IAChCC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GuidonProvider = GuidonProvider;
7
+ exports.useGuidonContext = useGuidonContext;
8
+ var _react = require("react");
9
+ var _store = require("../store.js");
10
+ var _hooks = require("../persistence/hooks.js");
11
+ var _GuidonOverlay = require("./GuidonOverlay.js");
12
+ var _GuidonTooltip = require("./GuidonTooltip.js");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ const GuidonContext = /*#__PURE__*/(0, _react.createContext)(null);
15
+ function useGuidonContext() {
16
+ const context = (0, _react.useContext)(GuidonContext);
17
+ if (!context) {
18
+ throw new Error('useGuidonContext must be used within a GuidonProvider');
19
+ }
20
+ return context;
21
+ }
22
+ function GuidonProvider({
23
+ children,
24
+ config,
25
+ autoStart = true,
26
+ shouldStart,
27
+ persistenceAdapter,
28
+ portalComponent: Portal,
29
+ renderTooltip,
30
+ tooltipLabels,
31
+ onBackdropPress
32
+ }) {
33
+ const hasInitialized = (0, _react.useRef)(false);
34
+ const isActive = (0, _store.useGuidonStore)(state => state.isActive);
35
+ const storeIsCompleted = (0, _store.useGuidonStore)(state => state.isCompleted);
36
+ const currentStepIndex = (0, _store.useGuidonStore)(state => state.currentStepIndex);
37
+ const configure = (0, _store.useGuidonStore)(state => state.configure);
38
+ const start = (0, _store.useGuidonStore)(state => state.start);
39
+ const next = (0, _store.useGuidonStore)(state => state.next);
40
+ const skip = (0, _store.useGuidonStore)(state => state.skip);
41
+ const reset = (0, _store.useGuidonStore)(state => state.reset);
42
+
43
+ // Check for waiting state (target element not mounted)
44
+ const waitingState = (0, _store.useWaitingState)();
45
+ const {
46
+ isLoading,
47
+ isCompleted: persistedCompleted,
48
+ markCompleted,
49
+ markStepViewed,
50
+ clearProgress
51
+ } = (0, _hooks.useGuidonPersistence)(persistenceAdapter, config.id);
52
+ const isCompleted = storeIsCompleted || persistedCompleted;
53
+ (0, _react.useEffect)(() => {
54
+ const enhancedConfig = {
55
+ ...config,
56
+ onComplete: async () => {
57
+ config.onComplete?.();
58
+ if (persistenceAdapter) {
59
+ await markCompleted();
60
+ }
61
+ },
62
+ onSkip: async () => {
63
+ config.onSkip?.();
64
+ if (persistenceAdapter) {
65
+ await markStepViewed(currentStepIndex);
66
+ }
67
+ },
68
+ onStepChange: async (stepIndex, step) => {
69
+ config.onStepChange?.(stepIndex, step);
70
+ if (persistenceAdapter) {
71
+ await markStepViewed(stepIndex);
72
+ }
73
+ }
74
+ };
75
+ configure(enhancedConfig);
76
+ }, [config, configure, persistenceAdapter, markCompleted, markStepViewed, currentStepIndex]);
77
+ (0, _react.useEffect)(() => {
78
+ if (!autoStart || hasInitialized.current || isLoading) return;
79
+ const checkAndStart = async () => {
80
+ hasInitialized.current = true;
81
+ if (persistedCompleted) return;
82
+ if (shouldStart) {
83
+ const should = await shouldStart();
84
+ if (!should) return;
85
+ }
86
+ setTimeout(() => {
87
+ start();
88
+ }, 500);
89
+ };
90
+ checkAndStart();
91
+ }, [autoStart, isLoading, persistedCompleted, shouldStart, start]);
92
+
93
+ // Handle wait timeout - auto-skip to next step if waiting too long
94
+ (0, _react.useEffect)(() => {
95
+ const currentStep = config.steps[currentStepIndex];
96
+ const waitTimeout = currentStep?.waitTimeout;
97
+
98
+ // Only set timeout if:
99
+ // - We have a timeout configured
100
+ // - The timeout is greater than 0
101
+ // - We are currently waiting for a target
102
+ if (!waitTimeout || waitTimeout <= 0 || !waitingState?.isWaiting) {
103
+ return;
104
+ }
105
+ const timer = setTimeout(() => {
106
+ // Check if we're still waiting when the timeout fires
107
+ const stillWaiting = _store.useGuidonStore.getState().targetMeasurements[currentStep.targetId] === undefined;
108
+ if (stillWaiting) {
109
+ next(); // Skip to next step
110
+ }
111
+ }, waitTimeout);
112
+ return () => clearTimeout(timer);
113
+ }, [currentStepIndex, config.steps, waitingState?.isWaiting, next]);
114
+ const replay = (0, _react.useCallback)(async () => {
115
+ if (persistenceAdapter) {
116
+ await clearProgress();
117
+ }
118
+ reset();
119
+ hasInitialized.current = false;
120
+ setTimeout(() => {
121
+ start();
122
+ }, 100);
123
+ }, [persistenceAdapter, clearProgress, reset, start]);
124
+ const manualStart = (0, _react.useCallback)(() => {
125
+ if (!isActive && !isLoading) {
126
+ start();
127
+ }
128
+ }, [isActive, isLoading, start]);
129
+ const contextValue = {
130
+ start: manualStart,
131
+ skip,
132
+ reset,
133
+ replay,
134
+ isActive,
135
+ isCompleted,
136
+ isLoading
137
+ };
138
+ const overlayContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
139
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GuidonOverlay.GuidonOverlay, {
140
+ theme: config.theme,
141
+ animationDuration: config.animationDuration,
142
+ onBackdropPress: onBackdropPress
143
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GuidonTooltip.GuidonTooltip, {
144
+ theme: config.theme,
145
+ animationDuration: config.animationDuration,
146
+ renderCustomTooltip: renderTooltip,
147
+ labels: tooltipLabels
148
+ })]
149
+ });
150
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(GuidonContext.Provider, {
151
+ value: contextValue,
152
+ children: [children, Portal ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Portal, {
153
+ children: overlayContent
154
+ }) : overlayContent]
155
+ });
156
+ }
157
+ //# sourceMappingURL=GuidonProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_store","_hooks","_GuidonOverlay","_GuidonTooltip","_jsxRuntime","GuidonContext","createContext","useGuidonContext","context","useContext","Error","GuidonProvider","children","config","autoStart","shouldStart","persistenceAdapter","portalComponent","Portal","renderTooltip","tooltipLabels","onBackdropPress","hasInitialized","useRef","isActive","useGuidonStore","state","storeIsCompleted","isCompleted","currentStepIndex","configure","start","next","skip","reset","waitingState","useWaitingState","isLoading","persistedCompleted","markCompleted","markStepViewed","clearProgress","useGuidonPersistence","id","useEffect","enhancedConfig","onComplete","onSkip","onStepChange","stepIndex","step","current","checkAndStart","should","setTimeout","currentStep","steps","waitTimeout","isWaiting","timer","stillWaiting","getState","targetMeasurements","targetId","undefined","clearTimeout","replay","useCallback","manualStart","contextValue","overlayContent","jsxs","Fragment","jsx","GuidonOverlay","theme","animationDuration","GuidonTooltip","renderCustomTooltip","labels","Provider","value"],"sourceRoot":"../../../src","sources":["components/GuidonProvider.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAAgD,IAAAK,WAAA,GAAAL,OAAA;AAiBhD,MAAMM,aAAa,gBAAG,IAAAC,oBAAa,EAA4B,IAAI,CAAC;AAE7D,SAASC,gBAAgBA,CAAA,EAAG;EACjC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACJ,aAAa,CAAC;EACzC,IAAI,CAACG,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,uDAAuD,CAAC;EAC1E;EACA,OAAOF,OAAO;AAChB;AAEO,SAASG,cAAcA,CAAC;EAC7BC,QAAQ;EACRC,MAAM;EACNC,SAAS,GAAG,IAAI;EAChBC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K,CAAC,CAAC;EAEhC,MAAMsC,YAAgC,GAAG;IACvCtC,KAAK,EAAEqC,WAAW;IAClBnC,IAAI;IACJC,KAAK;IACLgC,MAAM;IACN1C,QAAQ;IACRI,WAAW;IACXS;EACF,CAAC;EAED,MAAMiC,cAAc,gBAClB,IAAAlE,WAAA,CAAAmE,IAAA,EAAAnE,WAAA,CAAAoE,QAAA;IAAA5D,QAAA,gBACE,IAAAR,WAAA,CAAAqE,GAAA,EAACvE,cAAA,CAAAwE,aAAa;MACZC,KAAK,EAAE9D,MAAM,CAAC8D,KAAM;MACpBC,iBAAiB,EAAE/D,MAAM,CAAC+D,iBAAkB;MAC5CvD,eAAe,EAAEA;IAAgB,CAClC,CAAC,eACF,IAAAjB,WAAA,CAAAqE,GAAA,EAACtE,cAAA,CAAA0E,aAAa;MACZF,KAAK,EAAE9D,MAAM,CAAC8D,KAAM;MACpBC,iBAAiB,EAAE/D,MAAM,CAAC+D,iBAAkB;MAC5CE,mBAAmB,EAAE3D,aAAc;MACnC4D,MAAM,EAAE3D;IAAc,CACvB,CAAC;EAAA,CACF,CACH;EAED,oBACE,IAAAhB,WAAA,CAAAmE,IAAA,EAAClE,aAAa,CAAC2E,QAAQ;IAACC,KAAK,EAAEZ,YAAa;IAAAzD,QAAA,GACzCA,QAAQ,EACRM,MAAM,gBAAG,IAAAd,WAAA,CAAAqE,GAAA,EAACvD,MAAM;MAAAN,QAAA,EAAE0D;IAAc,CAAS,CAAC,GAAGA,cAAc;EAAA,CACtC,CAAC;AAE7B","ignoreList":[]}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GuidonTarget = GuidonTarget;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _store = require("../store.js");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ /**
12
+ * Wrapper component that marks an element as a walkthrough target
13
+ * Automatically measures and reports its position to the walkthrough store
14
+ */
15
+ function GuidonTarget({
16
+ children,
17
+ targetId,
18
+ active = true
19
+ }) {
20
+ const viewRef = (0, _react.useRef)(null);
21
+ const registerTarget = (0, _store.useGuidonStore)(state => state.registerTarget);
22
+ const unregisterTarget = (0, _store.useGuidonStore)(state => state.unregisterTarget);
23
+ const isActive = (0, _store.useGuidonStore)(state => state.isActive);
24
+ const config = (0, _store.useGuidonStore)(state => state.config);
25
+
26
+ // Check if this target is needed for the current walkthrough
27
+ const isTargetNeeded = isActive && config?.steps.some(step => step.targetId === targetId);
28
+ const measureElement = (0, _react.useCallback)(() => {
29
+ if (!viewRef.current || !active || !isTargetNeeded) return;
30
+ if (_reactNative.Platform.OS === "web") {
31
+ // Web measurement using getBoundingClientRect
32
+ const element = viewRef.current;
33
+ if (element && typeof element.getBoundingClientRect === "function") {
34
+ const rect = element.getBoundingClientRect();
35
+ const measurements = {
36
+ x: rect.left + window.scrollX,
37
+ y: rect.top + window.scrollY,
38
+ width: rect.width,
39
+ height: rect.height
40
+ };
41
+ registerTarget(targetId, measurements);
42
+ }
43
+ } else {
44
+ // Native measurement using measureInWindow
45
+ viewRef.current.measureInWindow((x, y, width, height) => {
46
+ if (width > 0 && height > 0) {
47
+ const measurements = {
48
+ x,
49
+ y,
50
+ width,
51
+ height
52
+ };
53
+ registerTarget(targetId, measurements);
54
+ }
55
+ });
56
+ }
57
+ }, [targetId, active, isTargetNeeded, registerTarget]);
58
+
59
+ // Measure on layout change
60
+ const handleLayout = (0, _react.useCallback)(_event => {
61
+ // Small delay to ensure layout is complete
62
+ requestAnimationFrame(() => {
63
+ measureElement();
64
+ });
65
+ }, [measureElement]);
66
+
67
+ // Re-measure when walkthrough becomes active or when this target becomes relevant
68
+ (0, _react.useEffect)(() => {
69
+ if (isTargetNeeded) {
70
+ // Delay to ensure the element is rendered
71
+ const timer = setTimeout(() => {
72
+ measureElement();
73
+ }, 100);
74
+ return () => clearTimeout(timer);
75
+ }
76
+ }, [isTargetNeeded, measureElement]);
77
+
78
+ // Re-measure on scroll (web only)
79
+ (0, _react.useEffect)(() => {
80
+ if (_reactNative.Platform.OS !== "web" || !isTargetNeeded) return;
81
+ const handleScroll = () => {
82
+ measureElement();
83
+ };
84
+ window.addEventListener("scroll", handleScroll, true);
85
+ window.addEventListener("resize", handleScroll);
86
+ return () => {
87
+ window.removeEventListener("scroll", handleScroll, true);
88
+ window.removeEventListener("resize", handleScroll);
89
+ };
90
+ }, [isTargetNeeded, measureElement]);
91
+
92
+ // Unregister on unmount
93
+ (0, _react.useEffect)(() => {
94
+ return () => {
95
+ unregisterTarget(targetId);
96
+ };
97
+ }, [targetId, unregisterTarget]);
98
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
99
+ ref: viewRef,
100
+ onLayout: handleLayout,
101
+ collapsable: false,
102
+ style: {
103
+ alignSelf: "flex-start"
104
+ },
105
+ children: children
106
+ });
107
+ }
108
+ //# sourceMappingURL=GuidonTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_store","_jsxRuntime","GuidonTarget","children","targetId","active","viewRef","useRef","registerTarget","useGuidonStore","state","unregisterTarget","isActive","config","isTargetNeeded","steps","some","step","measureElement","useCallback","current","Platform","OS","element","getBoundingClientRect","rect","measurements","x","left","window","scrollX","y","top","scrollY","width","height","measureInWindow","handleLayout","_event","requestAnimationFrame","useEffect","timer","setTimeout","clearTimeout","handleScroll","addEventListener","removeEventListener","jsx","View","ref","onLayout","collapsable","style","alignSelf"],"sourceRoot":"../../../src","sources":["components/GuidonTarget.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAA0C,IAAAG,WAAA,GAAAH,OAAA;AAQ1C;AACA;AACA;AACA;AACO,SAASI,YAAYA,CAAC;EAC3BC,QAAQ;EACRC,QAAQ;EACRC,MAAM,GAAG;AACQ,CAAC,EAAE;EACpB,MAAMC,OA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