@robertlinde/react-tour-kit 0.8.9 → 1.0.1

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 (368) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/MIGRATION.md +205 -0
  3. package/README.md +401 -850
  4. package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.d.ts +14 -0
  5. package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.d.ts.map +1 -0
  6. package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.js +21 -0
  7. package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.js.map +1 -0
  8. package/dist/react-native-platform/hooks/use-tour-target.hook.d.ts +15 -0
  9. package/dist/react-native-platform/hooks/use-tour-target.hook.d.ts.map +1 -0
  10. package/dist/react-native-platform/hooks/use-tour-target.hook.js +28 -0
  11. package/dist/react-native-platform/hooks/use-tour-target.hook.js.map +1 -0
  12. package/dist/react-native-platform/host-store.d.ts +24 -0
  13. package/dist/react-native-platform/host-store.d.ts.map +1 -0
  14. package/dist/react-native-platform/host-store.js +63 -0
  15. package/dist/react-native-platform/host-store.js.map +1 -0
  16. package/dist/react-native-platform/insets.util.d.ts +11 -0
  17. package/dist/react-native-platform/insets.util.d.ts.map +1 -0
  18. package/dist/react-native-platform/insets.util.js +31 -0
  19. package/dist/react-native-platform/insets.util.js.map +1 -0
  20. package/dist/react-native-platform/layer/native-renderer.d.ts +7 -0
  21. package/dist/react-native-platform/layer/native-renderer.d.ts.map +1 -0
  22. package/dist/react-native-platform/layer/native-renderer.js +496 -0
  23. package/dist/react-native-platform/layer/native-renderer.js.map +1 -0
  24. package/dist/react-native-platform/layer/tour-host.d.ts +13 -0
  25. package/dist/react-native-platform/layer/tour-host.d.ts.map +1 -0
  26. package/dist/react-native-platform/layer/tour-host.js +70 -0
  27. package/dist/react-native-platform/layer/tour-host.js.map +1 -0
  28. package/dist/react-native-platform/measure.util.d.ts +20 -0
  29. package/dist/react-native-platform/measure.util.d.ts.map +1 -0
  30. package/dist/react-native-platform/measure.util.js +100 -0
  31. package/dist/react-native-platform/measure.util.js.map +1 -0
  32. package/dist/react-native-platform/native-context.d.ts +12 -0
  33. package/dist/react-native-platform/native-context.d.ts.map +1 -0
  34. package/dist/react-native-platform/native-context.js +4 -0
  35. package/dist/react-native-platform/native-context.js.map +1 -0
  36. package/dist/react-native-platform/native-environment.d.ts +14 -0
  37. package/dist/react-native-platform/native-environment.d.ts.map +1 -0
  38. package/dist/react-native-platform/native-environment.js +20 -0
  39. package/dist/react-native-platform/native-environment.js.map +1 -0
  40. package/dist/react-native-platform/native-platform.d.ts +19 -0
  41. package/dist/react-native-platform/native-platform.d.ts.map +1 -0
  42. package/dist/react-native-platform/native-platform.js +265 -0
  43. package/dist/react-native-platform/native-platform.js.map +1 -0
  44. package/dist/react-native-platform/reduced-motion.d.ts +4 -0
  45. package/dist/react-native-platform/reduced-motion.d.ts.map +1 -0
  46. package/dist/react-native-platform/reduced-motion.js +44 -0
  47. package/dist/react-native-platform/reduced-motion.js.map +1 -0
  48. package/dist/react-native-platform/registry.d.ts +18 -0
  49. package/dist/react-native-platform/registry.d.ts.map +1 -0
  50. package/dist/react-native-platform/registry.js +51 -0
  51. package/dist/react-native-platform/registry.js.map +1 -0
  52. package/dist/react-native-platform/tour-provider.d.ts +16 -3
  53. package/dist/react-native-platform/tour-provider.d.ts.map +1 -0
  54. package/dist/react-native-platform/tour-provider.js +92 -211
  55. package/dist/react-native-platform/tour-provider.js.map +1 -1
  56. package/dist/react-native.d.ts +14 -10
  57. package/dist/react-native.d.ts.map +1 -0
  58. package/dist/react-native.js +7 -7
  59. package/dist/react-native.js.map +1 -1
  60. package/dist/react-platform/dom/elements.util.d.ts +35 -0
  61. package/dist/react-platform/dom/elements.util.d.ts.map +1 -0
  62. package/dist/react-platform/dom/elements.util.js +155 -0
  63. package/dist/react-platform/dom/elements.util.js.map +1 -0
  64. package/dist/react-platform/dom/occluders.util.d.ts +13 -0
  65. package/dist/react-platform/dom/occluders.util.d.ts.map +1 -0
  66. package/dist/react-platform/dom/occluders.util.js +75 -0
  67. package/dist/react-platform/dom/occluders.util.js.map +1 -0
  68. package/dist/react-platform/dom/scroll-lock.util.d.ts +13 -0
  69. package/dist/react-platform/dom/scroll-lock.util.d.ts.map +1 -0
  70. package/dist/react-platform/dom/scroll-lock.util.js +219 -0
  71. package/dist/react-platform/dom/scroll-lock.util.js.map +1 -0
  72. package/dist/react-platform/dom/scroll.util.d.ts +44 -0
  73. package/dist/react-platform/dom/scroll.util.d.ts.map +1 -0
  74. package/dist/react-platform/dom/scroll.util.js +250 -0
  75. package/dist/react-platform/dom/scroll.util.js.map +1 -0
  76. package/dist/react-platform/dom/viewport.util.d.ts +16 -0
  77. package/dist/react-platform/dom/viewport.util.d.ts.map +1 -0
  78. package/dist/react-platform/dom/viewport.util.js +65 -0
  79. package/dist/react-platform/dom/viewport.util.js.map +1 -0
  80. package/dist/react-platform/dom/web-platform.d.ts +15 -0
  81. package/dist/react-platform/dom/web-platform.d.ts.map +1 -0
  82. package/dist/react-platform/dom/web-platform.js +169 -0
  83. package/dist/react-platform/dom/web-platform.js.map +1 -0
  84. package/dist/react-platform/layer/styles.d.ts +12 -0
  85. package/dist/react-platform/layer/styles.d.ts.map +1 -0
  86. package/dist/react-platform/layer/styles.js +285 -0
  87. package/dist/react-platform/layer/styles.js.map +1 -0
  88. package/dist/react-platform/layer/web-renderer.d.ts +4 -0
  89. package/dist/react-platform/layer/web-renderer.d.ts.map +1 -0
  90. package/dist/react-platform/layer/web-renderer.js +390 -0
  91. package/dist/react-platform/layer/web-renderer.js.map +1 -0
  92. package/dist/react-platform/tour-provider.d.ts +9 -3
  93. package/dist/react-platform/tour-provider.d.ts.map +1 -0
  94. package/dist/react-platform/tour-provider.js +28 -218
  95. package/dist/react-platform/tour-provider.js.map +1 -1
  96. package/dist/react.d.ts +10 -10
  97. package/dist/react.d.ts.map +1 -0
  98. package/dist/react.js +5 -7
  99. package/dist/react.js.map +1 -1
  100. package/dist/shared/engine/abort.util.d.ts +17 -0
  101. package/dist/shared/engine/abort.util.d.ts.map +1 -0
  102. package/dist/shared/engine/abort.util.js +72 -0
  103. package/dist/shared/engine/abort.util.js.map +1 -0
  104. package/dist/shared/engine/report.util.d.ts +12 -0
  105. package/dist/shared/engine/report.util.d.ts.map +1 -0
  106. package/dist/shared/engine/report.util.js +51 -0
  107. package/dist/shared/engine/report.util.js.map +1 -0
  108. package/dist/shared/engine/tour-adapter.type.d.ts +67 -0
  109. package/dist/shared/engine/tour-adapter.type.d.ts.map +1 -0
  110. package/dist/shared/engine/tour-adapter.type.js +2 -0
  111. package/dist/shared/engine/tour-adapter.type.js.map +1 -0
  112. package/dist/shared/engine/tour-engine.d.ts +101 -0
  113. package/dist/shared/engine/tour-engine.d.ts.map +1 -0
  114. package/dist/shared/engine/tour-engine.js +835 -0
  115. package/dist/shared/engine/tour-engine.js.map +1 -0
  116. package/dist/shared/geometry/box.util.d.ts +39 -0
  117. package/dist/shared/geometry/box.util.d.ts.map +1 -0
  118. package/dist/shared/geometry/box.util.js +146 -0
  119. package/dist/shared/geometry/box.util.js.map +1 -0
  120. package/dist/shared/geometry/compute-tooltip-layout.util.d.ts +60 -0
  121. package/dist/shared/geometry/compute-tooltip-layout.util.d.ts.map +1 -0
  122. package/dist/shared/geometry/compute-tooltip-layout.util.js +148 -0
  123. package/dist/shared/geometry/compute-tooltip-layout.util.js.map +1 -0
  124. package/dist/shared/geometry/geometry.type.d.ts +34 -0
  125. package/dist/shared/geometry/geometry.type.d.ts.map +1 -0
  126. package/dist/shared/geometry/geometry.type.js +2 -0
  127. package/dist/shared/geometry/geometry.type.js.map +1 -0
  128. package/dist/shared/geometry/reveal.util.d.ts +38 -0
  129. package/dist/shared/geometry/reveal.util.d.ts.map +1 -0
  130. package/dist/shared/geometry/reveal.util.js +135 -0
  131. package/dist/shared/geometry/reveal.util.js.map +1 -0
  132. package/dist/shared/geometry/target-visibility.util.d.ts +10 -0
  133. package/dist/shared/geometry/target-visibility.util.d.ts.map +1 -0
  134. package/dist/shared/geometry/target-visibility.util.js +29 -0
  135. package/dist/shared/geometry/target-visibility.util.js.map +1 -0
  136. package/dist/shared/platform/create-tour-adapter.d.ts +9 -0
  137. package/dist/shared/platform/create-tour-adapter.d.ts.map +1 -0
  138. package/dist/shared/platform/create-tour-adapter.js +145 -0
  139. package/dist/shared/platform/create-tour-adapter.js.map +1 -0
  140. package/dist/shared/platform/platform.type.d.ts +77 -0
  141. package/dist/shared/platform/platform.type.d.ts.map +1 -0
  142. package/dist/shared/platform/platform.type.js +2 -0
  143. package/dist/shared/platform/platform.type.js.map +1 -0
  144. package/dist/shared/platform/reveal-in-scroll-containers.d.ts +27 -0
  145. package/dist/shared/platform/reveal-in-scroll-containers.d.ts.map +1 -0
  146. package/dist/shared/platform/reveal-in-scroll-containers.js +49 -0
  147. package/dist/shared/platform/reveal-in-scroll-containers.js.map +1 -0
  148. package/dist/shared/react/tour-context.d.ts +7 -0
  149. package/dist/shared/react/tour-context.d.ts.map +1 -0
  150. package/dist/shared/react/tour-context.js +23 -0
  151. package/dist/shared/react/tour-context.js.map +1 -0
  152. package/dist/shared/react/tour-provider-core.d.ts +41 -0
  153. package/dist/shared/react/tour-provider-core.d.ts.map +1 -0
  154. package/dist/shared/react/tour-provider-core.js +24 -0
  155. package/dist/shared/react/tour-provider-core.js.map +1 -0
  156. package/dist/shared/react/tour-root.d.ts +14 -0
  157. package/dist/shared/react/tour-root.d.ts.map +1 -0
  158. package/dist/shared/react/tour-root.js +22 -0
  159. package/dist/shared/react/tour-root.js.map +1 -0
  160. package/dist/shared/react/use-isomorphic-layout-effect.hook.d.ts +4 -0
  161. package/dist/shared/react/use-isomorphic-layout-effect.hook.d.ts.map +1 -0
  162. package/dist/shared/react/use-isomorphic-layout-effect.hook.js +5 -0
  163. package/dist/shared/react/use-isomorphic-layout-effect.hook.js.map +1 -0
  164. package/dist/shared/react/use-tour-view.hook.d.ts +5 -0
  165. package/dist/shared/react/use-tour-view.hook.d.ts.map +1 -0
  166. package/dist/shared/react/use-tour-view.hook.js +14 -0
  167. package/dist/shared/react/use-tour-view.hook.js.map +1 -0
  168. package/dist/shared/react/use-tour.hook.d.ts +7 -0
  169. package/dist/shared/react/use-tour.hook.d.ts.map +1 -0
  170. package/dist/shared/react/use-tour.hook.js +10 -0
  171. package/dist/shared/react/use-tour.hook.js.map +1 -0
  172. package/dist/shared/renderer/default-tooltip.d.ts +5 -0
  173. package/dist/shared/renderer/default-tooltip.d.ts.map +1 -0
  174. package/dist/shared/renderer/default-tooltip.js +13 -0
  175. package/dist/shared/renderer/default-tooltip.js.map +1 -0
  176. package/dist/shared/renderer/motion.d.ts +29 -0
  177. package/dist/shared/renderer/motion.d.ts.map +1 -0
  178. package/dist/shared/renderer/motion.js +49 -0
  179. package/dist/shared/renderer/motion.js.map +1 -0
  180. package/dist/shared/renderer/renderer-context.d.ts +17 -0
  181. package/dist/shared/renderer/renderer-context.d.ts.map +1 -0
  182. package/dist/shared/renderer/renderer-context.js +16 -0
  183. package/dist/shared/renderer/renderer-context.js.map +1 -0
  184. package/dist/shared/renderer/renderer.type.d.ts +164 -0
  185. package/dist/shared/renderer/renderer.type.d.ts.map +1 -0
  186. package/dist/shared/renderer/renderer.type.js +2 -0
  187. package/dist/shared/renderer/renderer.type.js.map +1 -0
  188. package/dist/shared/renderer/tooltip-model.d.ts +32 -0
  189. package/dist/shared/renderer/tooltip-model.d.ts.map +1 -0
  190. package/dist/shared/renderer/tooltip-model.js +24 -0
  191. package/dist/shared/renderer/tooltip-model.js.map +1 -0
  192. package/dist/shared/renderer/tour-overlay.d.ts +24 -0
  193. package/dist/shared/renderer/tour-overlay.d.ts.map +1 -0
  194. package/dist/shared/renderer/tour-overlay.js +228 -0
  195. package/dist/shared/renderer/tour-overlay.js.map +1 -0
  196. package/dist/shared/types/tour-context.type.d.ts +21 -11
  197. package/dist/shared/types/tour-context.type.d.ts.map +1 -0
  198. package/dist/shared/types/tour-end-info.type.d.ts +19 -2
  199. package/dist/shared/types/tour-end-info.type.d.ts.map +1 -0
  200. package/dist/shared/types/tour-i18n.type.d.ts +8 -0
  201. package/dist/shared/types/tour-i18n.type.d.ts.map +1 -0
  202. package/dist/shared/types/tour-step.type.d.ts +35 -6
  203. package/dist/shared/types/tour-step.type.d.ts.map +1 -0
  204. package/dist/shared/types/tour-theme.type.d.ts +22 -2
  205. package/dist/shared/types/tour-theme.type.d.ts.map +1 -0
  206. package/dist/shared/types/tour-theme.type.js +1 -16
  207. package/dist/shared/types/tour-theme.type.js.map +1 -1
  208. package/dist/shared/types/tour-tooltip-props.type.d.ts +21 -17
  209. package/dist/shared/types/tour-tooltip-props.type.d.ts.map +1 -0
  210. package/dist/shared/utils/frame.util.d.ts +6 -0
  211. package/dist/shared/utils/frame.util.d.ts.map +1 -0
  212. package/dist/shared/utils/frame.util.js +20 -0
  213. package/dist/shared/utils/frame.util.js.map +1 -0
  214. package/dist/shared/utils/get-truncated-dots.util.d.ts +13 -7
  215. package/dist/shared/utils/get-truncated-dots.util.d.ts.map +1 -0
  216. package/dist/shared/utils/get-truncated-dots.util.js +30 -30
  217. package/dist/shared/utils/get-truncated-dots.util.js.map +1 -1
  218. package/dist/shared/utils/i18n.util.d.ts +7 -0
  219. package/dist/shared/utils/i18n.util.d.ts.map +1 -0
  220. package/dist/shared/utils/i18n.util.js +34 -0
  221. package/dist/shared/utils/i18n.util.js.map +1 -0
  222. package/dist/shared/utils/theme.util.d.ts +6 -0
  223. package/dist/shared/utils/theme.util.d.ts.map +1 -0
  224. package/dist/shared/utils/theme.util.js +31 -0
  225. package/dist/shared/utils/theme.util.js.map +1 -0
  226. package/package.json +72 -55
  227. package/src/react-native-platform/hooks/use-tour-scroll-view.hook.ts +24 -0
  228. package/src/react-native-platform/hooks/use-tour-target.hook.ts +30 -0
  229. package/src/react-native-platform/host-store.ts +92 -0
  230. package/src/react-native-platform/insets.util.ts +39 -0
  231. package/src/react-native-platform/layer/native-renderer.tsx +776 -0
  232. package/src/react-native-platform/layer/tour-host.tsx +105 -0
  233. package/src/react-native-platform/measure.util.ts +140 -0
  234. package/src/react-native-platform/native-context.ts +15 -0
  235. package/src/react-native-platform/native-environment.ts +33 -0
  236. package/src/react-native-platform/native-platform.ts +368 -0
  237. package/src/react-native-platform/reduced-motion.ts +47 -0
  238. package/src/react-native-platform/registry.ts +70 -0
  239. package/src/react-native-platform/tour-provider.tsx +148 -0
  240. package/src/react-native.ts +15 -0
  241. package/src/react-platform/dom/elements.util.ts +191 -0
  242. package/src/react-platform/dom/occluders.util.ts +88 -0
  243. package/src/react-platform/dom/scroll-lock.util.ts +261 -0
  244. package/src/react-platform/dom/scroll.util.ts +310 -0
  245. package/src/react-platform/dom/viewport.util.ts +74 -0
  246. package/src/react-platform/dom/web-platform.ts +208 -0
  247. package/src/react-platform/layer/styles.ts +286 -0
  248. package/src/react-platform/layer/web-renderer.tsx +594 -0
  249. package/src/react-platform/tour-provider.tsx +44 -0
  250. package/src/react.ts +13 -0
  251. package/src/shared/engine/abort.util.ts +84 -0
  252. package/src/shared/engine/report.util.ts +58 -0
  253. package/src/shared/engine/tour-adapter.type.ts +73 -0
  254. package/src/shared/engine/tour-engine.ts +1147 -0
  255. package/src/shared/geometry/box.util.ts +185 -0
  256. package/src/shared/geometry/compute-tooltip-layout.util.ts +238 -0
  257. package/src/shared/geometry/geometry.type.ts +38 -0
  258. package/src/shared/geometry/reveal.util.ts +190 -0
  259. package/src/shared/geometry/target-visibility.util.ts +44 -0
  260. package/src/shared/platform/create-tour-adapter.ts +169 -0
  261. package/src/shared/platform/platform.type.ts +81 -0
  262. package/src/shared/platform/reveal-in-scroll-containers.ts +78 -0
  263. package/src/shared/react/tour-context.ts +28 -0
  264. package/src/shared/react/tour-provider-core.ts +67 -0
  265. package/src/shared/react/tour-root.tsx +34 -0
  266. package/src/shared/react/use-isomorphic-layout-effect.hook.ts +7 -0
  267. package/src/shared/react/use-tour-view.hook.ts +17 -0
  268. package/src/shared/react/use-tour.hook.ts +11 -0
  269. package/src/shared/renderer/default-tooltip.tsx +52 -0
  270. package/src/shared/renderer/motion.ts +59 -0
  271. package/src/shared/renderer/renderer-context.ts +33 -0
  272. package/src/shared/renderer/renderer.type.ts +183 -0
  273. package/src/shared/renderer/tooltip-model.ts +44 -0
  274. package/src/shared/renderer/tour-overlay.tsx +453 -0
  275. package/src/shared/types/tour-context.type.ts +23 -0
  276. package/src/shared/types/tour-end-info.type.ts +32 -0
  277. package/src/shared/types/tour-i18n.type.ts +15 -0
  278. package/src/shared/types/tour-step.type.ts +40 -0
  279. package/src/shared/types/tour-theme.type.ts +28 -0
  280. package/src/shared/types/tour-tooltip-props.type.ts +27 -0
  281. package/src/shared/utils/frame.util.ts +21 -0
  282. package/src/shared/utils/get-truncated-dots.util.ts +46 -0
  283. package/src/shared/utils/i18n.util.ts +44 -0
  284. package/src/shared/utils/theme.util.ts +38 -0
  285. package/dist/react-native-platform/components/index.d.ts +0 -2
  286. package/dist/react-native-platform/components/index.js +0 -3
  287. package/dist/react-native-platform/components/index.js.map +0 -1
  288. package/dist/react-native-platform/components/tour-overlay.d.ts +0 -3
  289. package/dist/react-native-platform/components/tour-overlay.js +0 -26
  290. package/dist/react-native-platform/components/tour-overlay.js.map +0 -1
  291. package/dist/react-native-platform/components/tour-tooltip.d.ts +0 -3
  292. package/dist/react-native-platform/components/tour-tooltip.js +0 -167
  293. package/dist/react-native-platform/components/tour-tooltip.js.map +0 -1
  294. package/dist/react-native-platform/hooks/index.d.ts +0 -1
  295. package/dist/react-native-platform/hooks/index.js +0 -2
  296. package/dist/react-native-platform/hooks/index.js.map +0 -1
  297. package/dist/react-native-platform/hooks/use-tour-target.d.ts +0 -2
  298. package/dist/react-native-platform/hooks/use-tour-target.js +0 -13
  299. package/dist/react-native-platform/hooks/use-tour-target.js.map +0 -1
  300. package/dist/react-native-platform/index.d.ts +0 -7
  301. package/dist/react-native-platform/index.js +0 -7
  302. package/dist/react-native-platform/index.js.map +0 -1
  303. package/dist/react-native-platform/platform-adapter.d.ts +0 -2
  304. package/dist/react-native-platform/platform-adapter.js +0 -84
  305. package/dist/react-native-platform/platform-adapter.js.map +0 -1
  306. package/dist/react-native-platform/target-registry.d.ts +0 -10
  307. package/dist/react-native-platform/target-registry.js +0 -17
  308. package/dist/react-native-platform/target-registry.js.map +0 -1
  309. package/dist/react-native-platform/types/tour-provider.props.type.d.ts +0 -12
  310. package/dist/react-native-platform/types/tour-provider.props.type.js +0 -2
  311. package/dist/react-native-platform/types/tour-provider.props.type.js.map +0 -1
  312. package/dist/react-platform/components/index.d.ts +0 -2
  313. package/dist/react-platform/components/index.js +0 -3
  314. package/dist/react-platform/components/index.js.map +0 -1
  315. package/dist/react-platform/components/tour-overlay.d.ts +0 -3
  316. package/dist/react-platform/components/tour-overlay.js +0 -29
  317. package/dist/react-platform/components/tour-overlay.js.map +0 -1
  318. package/dist/react-platform/components/tour-tooltip.d.ts +0 -2
  319. package/dist/react-platform/components/tour-tooltip.js +0 -155
  320. package/dist/react-platform/components/tour-tooltip.js.map +0 -1
  321. package/dist/react-platform/index.d.ts +0 -6
  322. package/dist/react-platform/index.js +0 -6
  323. package/dist/react-platform/index.js.map +0 -1
  324. package/dist/react-platform/platform-adapter.d.ts +0 -2
  325. package/dist/react-platform/platform-adapter.js +0 -101
  326. package/dist/react-platform/platform-adapter.js.map +0 -1
  327. package/dist/react-platform/types/tour-provider.props.type.d.ts +0 -12
  328. package/dist/react-platform/types/tour-provider.props.type.js +0 -2
  329. package/dist/react-platform/types/tour-provider.props.type.js.map +0 -1
  330. package/dist/react-platform/utils/find-visible-element.util.d.ts +0 -1
  331. package/dist/react-platform/utils/find-visible-element.util.js +0 -11
  332. package/dist/react-platform/utils/find-visible-element.util.js.map +0 -1
  333. package/dist/react-platform/utils/index.d.ts +0 -1
  334. package/dist/react-platform/utils/index.js +0 -2
  335. package/dist/react-platform/utils/index.js.map +0 -1
  336. package/dist/shared/context/index.d.ts +0 -1
  337. package/dist/shared/context/index.js +0 -2
  338. package/dist/shared/context/index.js.map +0 -1
  339. package/dist/shared/context/tour-context.d.ts +0 -3
  340. package/dist/shared/context/tour-context.js +0 -14
  341. package/dist/shared/context/tour-context.js.map +0 -1
  342. package/dist/shared/hooks/index.d.ts +0 -1
  343. package/dist/shared/hooks/index.js +0 -2
  344. package/dist/shared/hooks/index.js.map +0 -1
  345. package/dist/shared/hooks/use-tour.hook.d.ts +0 -2
  346. package/dist/shared/hooks/use-tour.hook.js +0 -7
  347. package/dist/shared/hooks/use-tour.hook.js.map +0 -1
  348. package/dist/shared/index.d.ts +0 -7
  349. package/dist/shared/index.js +0 -6
  350. package/dist/shared/index.js.map +0 -1
  351. package/dist/shared/types/index.d.ts +0 -10
  352. package/dist/shared/types/index.js +0 -2
  353. package/dist/shared/types/index.js.map +0 -1
  354. package/dist/shared/types/platform-adapter.type.d.ts +0 -24
  355. package/dist/shared/types/platform-adapter.type.js +0 -2
  356. package/dist/shared/types/platform-adapter.type.js.map +0 -1
  357. package/dist/shared/types/rect.type.d.ts +0 -11
  358. package/dist/shared/types/rect.type.js +0 -2
  359. package/dist/shared/types/rect.type.js.map +0 -1
  360. package/dist/shared/types/tour-overlay-props.type.d.ts +0 -8
  361. package/dist/shared/types/tour-overlay-props.type.js +0 -2
  362. package/dist/shared/types/tour-overlay-props.type.js.map +0 -1
  363. package/dist/shared/utils/calculate-tooltip-position.util.d.ts +0 -14
  364. package/dist/shared/utils/calculate-tooltip-position.util.js +0 -49
  365. package/dist/shared/utils/calculate-tooltip-position.util.js.map +0 -1
  366. package/dist/shared/utils/index.d.ts +0 -3
  367. package/dist/shared/utils/index.js +0 -3
  368. package/dist/shared/utils/index.js.map +0 -1
@@ -1,37 +1,37 @@
1
- export const MAX_VISIBLE_DOTS = 7;
2
- export const DOT_SIZE = 8;
3
- export const DOT_GAP = 6;
4
- export const DOTS_CONTAINER_WIDTH = MAX_VISIBLE_DOTS * DOT_SIZE + (MAX_VISIBLE_DOTS - 1) * DOT_GAP;
1
+ const maxVisible = 7;
2
+ const siblings = (maxVisible - 5) / 2;
3
+ function range(from, to) {
4
+ return Array.from({ length: to - from + 1 }, (_, offset) => ({ type: 'dot', index: from + offset }));
5
+ }
6
+ /**
7
+ * The step indicator for `totalSteps` steps with `currentStep` (zero-based) selected.
8
+ *
9
+ * Up to 7 steps every step gets a dot. Above that the result always has exactly 7 items, so the
10
+ * indicator keeps a constant width: the first and last step, the current step and its neighbours,
11
+ * and ellipses for the rest. An ellipsis always stands for at least two steps.
12
+ */
5
13
  export function getTruncatedDots(currentStep, totalSteps) {
6
- if (totalSteps <= MAX_VISIBLE_DOTS) {
7
- return Array.from({ length: totalSteps }, (_, i) => ({ type: 'dot', index: i }));
14
+ const total = Number.isFinite(totalSteps) ? Math.max(0, Math.floor(totalSteps)) : 0;
15
+ if (total === 0) {
16
+ return [];
8
17
  }
9
- const dots = [];
10
- const indices = new Set([0, totalSteps - 1, currentStep]);
11
- for (let offset = 1; indices.size < MAX_VISIBLE_DOTS - countGaps(indices); offset++) {
12
- if (currentStep - offset >= 0)
13
- indices.add(currentStep - offset);
14
- if (currentStep + offset < totalSteps)
15
- indices.add(currentStep + offset);
16
- if (offset > totalSteps)
17
- break;
18
+ if (total <= maxVisible) {
19
+ return range(0, total - 1);
18
20
  }
19
- const sorted = [...indices].sort((a, b) => a - b);
20
- for (let i = 0; i < sorted.length; i++) {
21
- if (i > 0 && sorted[i] - sorted[i - 1] > 1) {
22
- dots.push({ type: 'ellipsis' });
23
- }
24
- dots.push({ type: 'dot', index: sorted[i] });
21
+ const last = total - 1;
22
+ const current = Math.min(Math.max(Number.isFinite(currentStep) ? Math.floor(currentStep) : 0, 0), last);
23
+ if (current <= maxVisible - 3 - siblings) {
24
+ return [...range(0, maxVisible - 3), { type: 'ellipsis', position: 'end' }, { type: 'dot', index: last }];
25
25
  }
26
- return dots;
27
- }
28
- function countGaps(indices) {
29
- const sorted = [...indices].sort((a, b) => a - b);
30
- let gaps = 0;
31
- for (let i = 1; i < sorted.length; i++) {
32
- if (sorted[i] - sorted[i - 1] > 1)
33
- gaps++;
26
+ if (current >= total - (maxVisible - 2) + siblings) {
27
+ return [{ type: 'dot', index: 0 }, { type: 'ellipsis', position: 'start' }, ...range(total - (maxVisible - 2), last)];
34
28
  }
35
- return gaps;
29
+ return [
30
+ { type: 'dot', index: 0 },
31
+ { type: 'ellipsis', position: 'start' },
32
+ ...range(current - siblings, current + siblings),
33
+ { type: 'ellipsis', position: 'end' },
34
+ { type: 'dot', index: last },
35
+ ];
36
36
  }
37
37
  //# sourceMappingURL=get-truncated-dots.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-truncated-dots.util.js","sourceRoot":"","sources":["../../../src/shared/utils/get-truncated-dots.util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,QAAQ,GAAG,CAAC,gBAAgB,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;AAInG,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,UAAkB;IACtE,IAAI,UAAU,IAAI,gBAAgB,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,UAAU,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,KAAc,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,IAAI,GAAc,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;IAIlE,KAAK,IAAI,MAAM,GAAG,CAAC,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edI18n = Required<TourI18n>;
3
+ export declare const defaultI18n: ResolvedI18n;
4
+ export declare function resolveI18n(i18n: TourI18n | undefined): ResolvedI18n;
5
+ /** Replaces every `{name}` placeholder with its value; unknown placeholders are left as they are. */
6
+ export declare function formatTemplate(template: string, values: Readonly<Record<string, string | number>>): string;
7
+ //# sourceMappingURL=i18n.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.util.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/i18n.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAC;AAEzD,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAE9C,eAAO,MAAM,WAAW,EAAE,YAOzB,CAAC;AAWF,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,YAAY,CAcpE;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAI1G"}
@@ -0,0 +1,34 @@
1
+ export const defaultI18n = {
2
+ nextLabel: 'Next',
3
+ prevLabel: 'Back',
4
+ finishLabel: 'Finish',
5
+ stepCounterTemplate: '{current} of {total}',
6
+ closeAriaLabel: 'Close tour',
7
+ dotAriaLabelTemplate: 'Go to step {step}',
8
+ };
9
+ const i18nKeys = [
10
+ 'nextLabel',
11
+ 'prevLabel',
12
+ 'finishLabel',
13
+ 'stepCounterTemplate',
14
+ 'closeAriaLabel',
15
+ 'dotAriaLabelTemplate',
16
+ ];
17
+ export function resolveI18n(i18n) {
18
+ if (!i18n) {
19
+ return defaultI18n;
20
+ }
21
+ const resolved = { ...defaultI18n };
22
+ for (const key of i18nKeys) {
23
+ const value = i18n[key];
24
+ if (typeof value === 'string') {
25
+ resolved[key] = value;
26
+ }
27
+ }
28
+ return resolved;
29
+ }
30
+ /** Replaces every `{name}` placeholder with its value; unknown placeholders are left as they are. */
31
+ export function formatTemplate(template, values) {
32
+ return template.replaceAll(/\{(\w+)\}/gu, (match, name) => Object.hasOwn(values, name) ? String(values[name]) : match);
33
+ }
34
+ //# sourceMappingURL=i18n.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.util.js","sourceRoot":"","sources":["../../../src/shared/utils/i18n.util.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,QAAQ;IACrB,mBAAmB,EAAE,sBAAsB;IAC3C,cAAc,EAAE,YAAY;IAC5B,oBAAoB,EAAE,mBAAmB;CAC1C,CAAC;AAEF,MAAM,QAAQ,GAAG;IACf,WAAW;IACX,WAAW;IACX,aAAa;IACb,qBAAqB;IACrB,gBAAgB;IAChB,sBAAsB;CAC0B,CAAC;AAEnD,MAAM,UAAU,WAAW,CAAC,IAA0B;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,QAAQ,GAAG,EAAC,GAAG,WAAW,EAAC,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,MAAiD;IAChG,OAAO,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CAChE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAC3D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { TourTheme } from '../types/tour-theme.type.js';
2
+ export type ResolvedTheme = Required<TourTheme>;
3
+ export declare const defaultTheme: ResolvedTheme;
4
+ /** Fills in defaults for missing (or `undefined`) keys. */
5
+ export declare function resolveTheme(theme: TourTheme | undefined): ResolvedTheme;
6
+ //# sourceMappingURL=theme.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.util.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/theme.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,6BAA6B,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEhD,eAAO,MAAM,YAAY,EAAE,aAO1B,CAAC;AAWF,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,aAAa,CAcxE"}
@@ -0,0 +1,31 @@
1
+ export const defaultTheme = {
2
+ primaryColor: '#2563eb',
3
+ primaryTextColor: '#ffffff',
4
+ tooltipBackground: '#ffffff',
5
+ titleColor: '#111827',
6
+ contentColor: '#4b5563',
7
+ overlayColor: 'rgba(0, 0, 0, 0.5)',
8
+ };
9
+ const themeKeys = [
10
+ 'primaryColor',
11
+ 'primaryTextColor',
12
+ 'tooltipBackground',
13
+ 'titleColor',
14
+ 'contentColor',
15
+ 'overlayColor',
16
+ ];
17
+ /** Fills in defaults for missing (or `undefined`) keys. */
18
+ export function resolveTheme(theme) {
19
+ if (!theme) {
20
+ return defaultTheme;
21
+ }
22
+ const resolved = { ...defaultTheme };
23
+ for (const key of themeKeys) {
24
+ const value = theme[key];
25
+ if (typeof value === 'string' && value.length > 0) {
26
+ resolved[key] = value;
27
+ }
28
+ }
29
+ return resolved;
30
+ }
31
+ //# sourceMappingURL=theme.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.util.js","sourceRoot":"","sources":["../../../src/shared/utils/theme.util.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,YAAY,EAAE,SAAS;IACvB,gBAAgB,EAAE,SAAS;IAC3B,iBAAiB,EAAE,SAAS;IAC5B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,oBAAoB;CACnC,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,cAAc;IACd,kBAAkB;IAClB,mBAAmB;IACnB,YAAY;IACZ,cAAc;IACd,cAAc;CACmC,CAAC;AAEpD,2DAA2D;AAC3D,MAAM,UAAU,YAAY,CAAC,KAA4B;IACvD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,QAAQ,GAAG,EAAC,GAAG,YAAY,EAAC,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,56 +1,77 @@
1
1
  {
2
2
  "name": "@robertlinde/react-tour-kit",
3
- "version": "0.8.9",
3
+ "version": "1.0.1",
4
4
  "type": "module",
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.",
5
+ "description": "Guided product tours for React and React Native. Smooth, accessible, and guaranteed to stay on screen: the target is scrolled into view and the tooltip never renders out of sight.",
6
6
  "author": "Robert Linde",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/robertlinde/react-tour-kit.git"
10
+ "url": "git+https://github.com/robertlinde/react-tour-kit.git"
11
11
  },
12
12
  "homepage": "https://github.com/robertlinde/react-tour-kit#readme",
13
13
  "bugs": {
14
14
  "url": "https://github.com/robertlinde/react-tour-kit/issues"
15
15
  },
16
- "scripts": {
17
- "start:dev": "tsc --watch",
18
- "build": "tsc",
19
- "lint": "xo",
20
- "lint:fix": "xo --fix",
21
- "format": "prettier --write .",
22
- "format:check": "prettier --check .",
23
- "test:e2e:react": "playwright test --config=playwright/playwright.config.ts",
24
- "test:e2e:react:ui": "playwright test --config=playwright/playwright.config.ts --ui",
25
- "prepublishOnly": "npm run build",
26
- "prepare": "husky || true"
27
- },
28
- "main": "./dist/react.js",
29
- "module": "./dist/react.js",
30
- "types": "./dist/react.d.ts",
16
+ "keywords": [
17
+ "react",
18
+ "react-native",
19
+ "expo",
20
+ "tour",
21
+ "product-tour",
22
+ "guided-tour",
23
+ "walkthrough",
24
+ "onboarding",
25
+ "spotlight",
26
+ "tooltip",
27
+ "accessibility"
28
+ ],
29
+ "sideEffects": false,
31
30
  "exports": {
32
31
  "./react": {
33
32
  "types": "./dist/react.d.ts",
34
- "require": "./dist/react.js",
35
- "import": "./dist/react.js"
33
+ "default": "./dist/react.js"
36
34
  },
37
35
  "./react-native": {
38
36
  "types": "./dist/react-native.d.ts",
39
- "require": "./dist/react-native.js",
40
- "import": "./dist/react-native.js"
41
- }
37
+ "default": "./dist/react-native.js"
38
+ },
39
+ "./package.json": "./package.json"
42
40
  },
43
41
  "files": [
44
42
  "dist",
43
+ "src",
45
44
  "README.md",
45
+ "MIGRATION.md",
46
+ "CHANGELOG.md",
46
47
  "LICENSE"
47
48
  ],
48
- "sideEffects": false,
49
+ "scripts": {
50
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
51
+ "build": "npm run clean && tsc -p tsconfig.build.json",
52
+ "dev": "tsc -p tsconfig.build.json --watch",
53
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.tooling.json",
54
+ "lint": "xo --ignore \"demos/**\"",
55
+ "lint:fix": "xo --fix --ignore \"demos/**\"",
56
+ "format": "prettier --write .",
57
+ "format:check": "prettier --check .",
58
+ "test": "vitest run",
59
+ "test:unit": "vitest run --project unit",
60
+ "test:component": "vitest run --project web --project native --project jsdom",
61
+ "test:watch": "vitest",
62
+ "test:e2e": "playwright test",
63
+ "test:e2e:ui": "playwright test --ui",
64
+ "check:package": "publint --strict && attw --pack . --profile esm-only",
65
+ "smoke:node": "node test/smoke-node.mjs",
66
+ "demo:web": "npm run dev --prefix demos/react",
67
+ "demo:ios": "npm run ios --prefix demos/react-native",
68
+ "demo:android": "npm run android --prefix demos/react-native",
69
+ "prepare": "husky || true"
70
+ },
49
71
  "peerDependencies": {
50
72
  "react": "^18.0.0 || ^19.0.0",
51
73
  "react-dom": "^18.0.0 || ^19.0.0",
52
- "react-native": ">=0.70.0",
53
- "react-native-svg": ">=13.0.0"
74
+ "react-native": ">=0.79.0"
54
75
  },
55
76
  "peerDependenciesMeta": {
56
77
  "react-dom": {
@@ -58,41 +79,37 @@
58
79
  },
59
80
  "react-native": {
60
81
  "optional": true
61
- },
62
- "react-native-svg": {
63
- "optional": true
64
82
  }
65
83
  },
66
84
  "devDependencies": {
67
- "@commitlint/cli": "21.2.1",
68
- "@commitlint/config-conventional": "21.2.0",
69
- "@estruyf/github-actions-reporter": "1.12.0",
70
- "@playwright/test": "1.62.1",
71
- "@types/react": "19.2.18",
72
- "@types/react-dom": "19.2.4",
73
- "@types/react-native": "0.73.0",
85
+ "@arethetypeswrong/cli": "0.18.5",
86
+ "@axe-core/playwright": "4.13.0",
87
+ "@commitlint/cli": "21.2.3",
88
+ "@commitlint/config-conventional": "21.2.3",
89
+ "@estruyf/github-actions-reporter": "1.13.0",
90
+ "@playwright/test": "1.64.0",
91
+ "@types/node": "26.6.5",
92
+ "@types/react": "19.3.0",
93
+ "@types/react-dom": "19.3.0",
94
+ "@vitest/browser": "5.0.3",
95
+ "@vitest/browser-playwright": "5.0.3",
96
+ "fast-check": "4.10.2",
74
97
  "husky": "9.1.7",
75
- "lint-staged": "17.3.0",
76
- "prettier": "3.9.6",
77
- "react": "19.2.8",
78
- "react-dom": "19.2.8",
79
- "react-native-svg": "15.15.5",
98
+ "jsdom": "30.1.2",
99
+ "lint-staged": "17.6.0",
100
+ "prettier": "3.9.10",
101
+ "publint": "0.3.25",
102
+ "react": "19.3.0",
103
+ "react-dom": "19.3.0",
104
+ "react-native": "0.87.1",
105
+ "react-native-web": "0.21.4",
80
106
  "typescript": "6.0.3",
107
+ "vitest": "5.0.3",
108
+ "vitest-browser-react": "2.3.0",
81
109
  "xo": "2.0.2"
82
110
  },
83
- "keywords": [
84
- "react",
85
- "react-native",
86
- "tour",
87
- "guided-tour",
88
- "walkthrough",
89
- "onboarding",
90
- "tooltip",
91
- "tutorial",
92
- "intro",
93
- "product-tour"
94
- ],
95
- "engines": {
96
- "node": ">=20.0.0"
111
+ "publishConfig": {
112
+ "access": "public",
113
+ "provenance": true
97
114
  }
98
115
  }
@@ -0,0 +1,24 @@
1
+ import {type ComponentRef, type RefObject, useContext, useRef} from 'react';
2
+ import type {ScrollView} from 'react-native';
3
+ import {useIsomorphicLayoutEffect} from '../../shared/react/use-isomorphic-layout-effect.hook.js';
4
+ import {NativeTourContext} from '../native-context.js';
5
+
6
+ /**
7
+ * Lets the tour scroll a `ScrollView`, `FlatList` or `SectionList` so that targets inside it are
8
+ * brought into view. Attach the returned ref to the list, or pass the ref the list already has.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const listRef = useTourScrollView();
13
+ * return <ScrollView ref={listRef}>…</ScrollView>;
14
+ * ```
15
+ */
16
+ export function useTourScrollView<T = ComponentRef<typeof ScrollView>>(
17
+ existingRef?: RefObject<T | null>,
18
+ ): RefObject<T | null> {
19
+ const ownRef = useRef<T | null>(null);
20
+ const ref = existingRef ?? ownRef;
21
+ const context = useContext(NativeTourContext);
22
+ useIsomorphicLayoutEffect(() => context?.registry.registerScrollView(ref), [context, ref]);
23
+ return ref;
24
+ }
@@ -0,0 +1,30 @@
1
+ import {type ComponentRef, type RefObject, useContext, useRef} from 'react';
2
+ import type {View} from 'react-native';
3
+ import {devWarn} from '../../shared/engine/report.util.js';
4
+ import {useIsomorphicLayoutEffect} from '../../shared/react/use-isomorphic-layout-effect.hook.js';
5
+ import {NativeTourContext} from '../native-context.js';
6
+
7
+ /**
8
+ * Registers a view as a tour target. Attach the returned ref to the view and use `id` as the
9
+ * step's `target`. The ref is typed for `View` (and components that forward to it, such as
10
+ * `Pressable`); pass a type argument for other components.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const ref = useTourTarget('profile-button');
15
+ * return <Pressable ref={ref}>…</Pressable>;
16
+ * ```
17
+ */
18
+ export function useTourTarget<T = ComponentRef<typeof View>>(id: string): RefObject<T | null> {
19
+ const ref = useRef<T | null>(null);
20
+ const context = useContext(NativeTourContext);
21
+ useIsomorphicLayoutEffect(() => {
22
+ if (!context) {
23
+ devWarn(`useTourTarget('${id}') was called outside of <TourProvider>; the target cannot be found.`);
24
+ return undefined;
25
+ }
26
+
27
+ return context.registry.registerTarget(id, ref);
28
+ }, [context, id]);
29
+ return ref;
30
+ }
@@ -0,0 +1,92 @@
1
+ import type {Size} from '../shared/geometry/geometry.type.js';
2
+
3
+ type HostRecord = {
4
+ readonly key: number;
5
+ /** The provider's own host: always at the bottom of the stack, whatever the mount order. */
6
+ readonly root: boolean;
7
+ readonly getInstance: () => unknown;
8
+ size: Size;
9
+ };
10
+
11
+ /**
12
+ * The views the tour can be drawn in: the provider's own full-window layer, plus any `TourHost`
13
+ * mounted inside native modal screens. The most recently mounted host is used.
14
+ */
15
+ export type HostStore = {
16
+ readonly register: (key: number, getInstance: () => unknown, root: boolean) => () => void;
17
+ readonly setSize: (key: number, size: Size) => void;
18
+ /** Key of the host the tour is drawn in. */
19
+ readonly activeKey: () => number | undefined;
20
+ /** True while the tour is drawn in the provider's own host (no `TourHost` is mounted). */
21
+ readonly isRootActive: () => boolean;
22
+ readonly activeHost: () => {readonly instance: unknown; readonly size: Size} | undefined;
23
+ /** Host list changes (which host is active). */
24
+ readonly subscribe: (listener: () => void) => () => void;
25
+ /** Anything that can move targets relative to the layer: host changes and sizes, keyboard. */
26
+ readonly subscribeLayout: (listener: () => void) => () => void;
27
+ readonly notifyLayout: () => void;
28
+ };
29
+
30
+ export function createHostStore(): HostStore {
31
+ const hosts: HostRecord[] = [];
32
+ const listeners = new Set<() => void>();
33
+ const layoutListeners = new Set<() => void>();
34
+ const emit = (set: Set<() => void>): void => {
35
+ // Snapshot: listeners may unsubscribe while being notified.
36
+ const snapshot = [...set];
37
+ for (const listener of snapshot) {
38
+ listener();
39
+ }
40
+ };
41
+
42
+ const store: HostStore = {
43
+ register(key, getInstance, root) {
44
+ const record: HostRecord = {key, root, getInstance, size: {width: 0, height: 0}};
45
+ if (root) {
46
+ hosts.unshift(record);
47
+ } else {
48
+ hosts.push(record);
49
+ }
50
+
51
+ emit(listeners);
52
+ emit(layoutListeners);
53
+ return () => {
54
+ const index = hosts.findIndex((host) => host.key === key);
55
+ if (index !== -1) {
56
+ hosts.splice(index, 1);
57
+ emit(listeners);
58
+ emit(layoutListeners);
59
+ }
60
+ };
61
+ },
62
+ setSize(key, size) {
63
+ const host = hosts.find((candidate) => candidate.key === key);
64
+ if (host && (host.size.width !== size.width || host.size.height !== size.height)) {
65
+ host.size = size;
66
+ emit(layoutListeners);
67
+ }
68
+ },
69
+ activeKey: () => hosts.at(-1)?.key,
70
+ isRootActive: () => hosts.at(-1)?.root ?? true,
71
+ activeHost() {
72
+ const host = hosts.at(-1);
73
+ return host ? {instance: host.getInstance(), size: host.size} : undefined;
74
+ },
75
+ subscribe(listener) {
76
+ listeners.add(listener);
77
+ return () => {
78
+ listeners.delete(listener);
79
+ };
80
+ },
81
+ subscribeLayout(listener) {
82
+ layoutListeners.add(listener);
83
+ return () => {
84
+ layoutListeners.delete(listener);
85
+ };
86
+ },
87
+ notifyLayout() {
88
+ emit(layoutListeners);
89
+ },
90
+ };
91
+ return store;
92
+ }
@@ -0,0 +1,39 @@
1
+ import {Platform, StatusBar} from 'react-native';
2
+ import type {Insets, Size} from '../shared/geometry/geometry.type.js';
3
+
4
+ /** Insets the app can pass in (for example from `useSafeAreaInsets()`); missing sides use the defaults. */
5
+ export type TourInsets = Partial<Insets>;
6
+
7
+ /**
8
+ * Conservative safe-area defaults for when the app does not pass `insets`: large enough that the
9
+ * notch, Dynamic Island, home indicator and system bars of current devices are never covered.
10
+ */
11
+ export function defaultInsets(layer: Size): Insets {
12
+ const landscape = layer.width > layer.height;
13
+ if (Platform.OS === 'ios') {
14
+ if ((Platform as {isPad?: boolean}).isPad) {
15
+ return {top: 24, right: 0, bottom: 20, left: 0};
16
+ }
17
+
18
+ return landscape ? {top: 0, right: 62, bottom: 21, left: 62} : {top: 62, right: 0, bottom: 34, left: 0};
19
+ }
20
+
21
+ if (Platform.OS === 'android') {
22
+ const statusBar = Math.max(StatusBar.currentHeight ?? 0, 24);
23
+ // In landscape the camera cutout and the 3-button bar can be on either side (the device can
24
+ // be turned either way), and the gesture handle stays at the bottom.
25
+ return landscape
26
+ ? {top: statusBar, right: 48, bottom: 24, left: 48}
27
+ : {top: statusBar, right: 0, bottom: 48, left: 0};
28
+ }
29
+
30
+ return {top: 0, right: 0, bottom: 0, left: 0};
31
+ }
32
+
33
+ /** `keyboardOverlap`: how much of the layer the on-screen keyboard covers. */
34
+ export function resolveInsets(provided: TourInsets | undefined, layer: Size, keyboardOverlap: number): Insets {
35
+ const base = provided
36
+ ? {top: provided.top ?? 0, right: provided.right ?? 0, bottom: provided.bottom ?? 0, left: provided.left ?? 0}
37
+ : defaultInsets(layer);
38
+ return {...base, bottom: Math.max(base.bottom, keyboardOverlap)};
39
+ }