@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
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Styles of the web tour layer. Everything is scoped to `rtk-` classes. Theme values arrive as
3
+ * CSS variables set on `.rtk-root`. All rules live in a cascade layer, so the app's own CSS wins
4
+ * over them without `!important` — except for the few properties marked `!important` here: what
5
+ * keeps the tour in place, clickable and readable, which global resets (Tailwind's preflight,
6
+ * normalize.css, Bootstrap, `dialog {…}` or `button {…}` rules) would otherwise change. Those
7
+ * still follow the CSS variables.
8
+ */
9
+ export const tourCss = `
10
+ @layer react-tour-kit {
11
+ :where(.rtk-root) {
12
+ --rtk-primary: #2563eb;
13
+ --rtk-on-primary: #ffffff;
14
+ --rtk-bg: #ffffff;
15
+ --rtk-title: #111827;
16
+ --rtk-text: #4b5563;
17
+ --rtk-overlay: rgba(0, 0, 0, 0.5);
18
+ --rtk-radius: 12px;
19
+ --rtk-spotlight-radius: 8px;
20
+ --rtk-ease: cubic-bezier(0.2, 0, 0, 1);
21
+ --rtk-z-index: 2147483000;
22
+ }
23
+
24
+ .rtk-root {
25
+ position: fixed !important;
26
+ inset: 0 !important;
27
+ box-sizing: border-box !important;
28
+ width: 100% !important;
29
+ height: 100% !important;
30
+ max-width: none !important;
31
+ max-height: none !important;
32
+ margin: 0 !important;
33
+ padding: 0 !important;
34
+ border: 0 !important;
35
+ background: transparent !important;
36
+ color: var(--rtk-text);
37
+ overflow: visible !important;
38
+ outline: none;
39
+ transform: none !important;
40
+ filter: none !important;
41
+ /* The page may have disabled pointer events on <body> (modal libraries do while open). */
42
+ pointer-events: auto !important;
43
+ z-index: var(--rtk-z-index) !important;
44
+ opacity: 0 !important;
45
+ transition: opacity var(--rtk-fade-duration, 200ms) var(--rtk-ease);
46
+ }
47
+ .rtk-root::backdrop { background: transparent !important; backdrop-filter: none !important; }
48
+ .rtk-root[data-visible] { opacity: 1 !important; }
49
+
50
+ .rtk-backdrop { position: fixed !important; inset: 0 !important; touch-action: pinch-zoom; }
51
+ .rtk-backdrop[data-closable] { cursor: pointer; }
52
+
53
+ .rtk-spotlight {
54
+ /* Its geometry is set inline, which an \`!important\` rule here would override. */
55
+ position: fixed !important;
56
+ right: auto;
57
+ bottom: auto;
58
+ margin: 0 !important;
59
+ box-sizing: border-box !important;
60
+ padding: 0 !important;
61
+ border: 0 !important;
62
+ pointer-events: none !important;
63
+ border-radius: var(--rtk-spotlight-radius);
64
+ box-shadow: 0 0 0 2px var(--rtk-primary), 0 0 0 200vmax var(--rtk-overlay);
65
+ box-shadow: 0 0 0 2px var(--rtk-primary), 0 0 0 6px color-mix(in srgb, var(--rtk-primary) 30%, transparent), 0 0 0 200vmax var(--rtk-overlay);
66
+ }
67
+ .rtk-spotlight[data-collapsed] { box-shadow: 0 0 0 200vmax var(--rtk-overlay); }
68
+
69
+ .rtk-tooltip {
70
+ position: fixed !important;
71
+ top: 0 !important;
72
+ left: 0 !important;
73
+ margin: 0 !important;
74
+ box-sizing: border-box;
75
+ display: flow-root;
76
+ outline: none;
77
+ overflow: visible;
78
+ transform-origin: var(--rtk-origin, center);
79
+ }
80
+ .rtk-tooltip[data-overflowing] { overflow: auto; overscroll-behavior: contain; }
81
+ .rtk-tooltip[data-hidden] { visibility: hidden; }
82
+ .rtk-tooltip[data-entering] {
83
+ animation: rtk-enter var(--rtk-enter-duration, 200ms) var(--rtk-ease) var(--rtk-enter-delay, 0ms) both;
84
+ }
85
+ .rtk-measure {
86
+ position: fixed !important;
87
+ top: 0 !important;
88
+ left: 0 !important;
89
+ visibility: hidden !important;
90
+ pointer-events: none !important;
91
+ box-sizing: border-box;
92
+ display: flow-root;
93
+ }
94
+
95
+ .rtk-card {
96
+ position: relative;
97
+ box-sizing: border-box;
98
+ display: flex;
99
+ flex-direction: column;
100
+ width: 380px;
101
+ max-width: 100%;
102
+ max-height: var(--rtk-max-height, none);
103
+ border-radius: var(--rtk-radius);
104
+ background: var(--rtk-bg);
105
+ color: var(--rtk-text);
106
+ box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.35), 0 4px 12px -6px rgba(15, 23, 42, 0.2);
107
+ font-size: 14px;
108
+ line-height: 1.5;
109
+ text-align: start;
110
+ }
111
+ .rtk-arrow {
112
+ position: absolute;
113
+ width: 10px;
114
+ height: 10px;
115
+ background: var(--rtk-bg);
116
+ transform: rotate(45deg);
117
+ }
118
+ .rtk-arrow[data-side="bottom"] { top: -5px; left: calc(var(--rtk-arrow-offset) - 5px); }
119
+ .rtk-arrow[data-side="top"] { bottom: -5px; left: calc(var(--rtk-arrow-offset) - 5px); }
120
+ .rtk-arrow[data-side="right"] { left: -5px; top: calc(var(--rtk-arrow-offset) - 5px); }
121
+ .rtk-arrow[data-side="left"] { right: -5px; top: calc(var(--rtk-arrow-offset) - 5px); }
122
+
123
+ .rtk-header {
124
+ display: flex;
125
+ align-items: center;
126
+ justify-content: space-between;
127
+ gap: 12px;
128
+ padding: 12px 8px 0 16px;
129
+ }
130
+ .rtk-counter {
131
+ border-radius: 999px;
132
+ padding: 2px 10px;
133
+ background: var(--rtk-primary);
134
+ color: var(--rtk-on-primary);
135
+ font-size: 12px;
136
+ font-weight: 600;
137
+ line-height: 1.6;
138
+ font-variant-numeric: tabular-nums;
139
+ }
140
+ .rtk-close {
141
+ position: relative;
142
+ display: grid;
143
+ place-items: center;
144
+ box-sizing: border-box !important;
145
+ width: 32px !important;
146
+ height: 32px !important;
147
+ margin: 0 !important;
148
+ padding: 0 !important;
149
+ border: 0 !important;
150
+ border-radius: 8px;
151
+ background: transparent !important;
152
+ color: var(--rtk-text) !important;
153
+ cursor: pointer;
154
+ }
155
+ .rtk-close::before, .rtk-button--prev::before {
156
+ content: '';
157
+ position: absolute;
158
+ inset: 0;
159
+ border-radius: inherit;
160
+ background: currentColor;
161
+ opacity: 0;
162
+ transition: opacity 120ms;
163
+ }
164
+ .rtk-close:hover::before { opacity: 0.1; }
165
+ .rtk-body {
166
+ flex: 1 1 auto;
167
+ min-height: 0;
168
+ overflow: auto;
169
+ overscroll-behavior: contain;
170
+ padding: 8px 16px 16px;
171
+ }
172
+ .rtk-title { margin: 0 0 4px; color: var(--rtk-title); font-size: 17px; font-weight: 600; line-height: 1.35; }
173
+ .rtk-content { margin: 0; overflow-wrap: anywhere; }
174
+ .rtk-footer {
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: space-between;
178
+ gap: 8px;
179
+ padding: 0 16px 16px;
180
+ }
181
+ .rtk-button {
182
+ position: relative;
183
+ box-sizing: border-box !important;
184
+ min-height: 36px !important;
185
+ margin: 0 !important;
186
+ padding: 8px 14px !important;
187
+ border: 0 !important;
188
+ border-radius: 8px;
189
+ font-family: inherit;
190
+ font-size: 14px !important;
191
+ font-weight: 500 !important;
192
+ line-height: 1.4 !important;
193
+ cursor: pointer;
194
+ white-space: nowrap;
195
+ }
196
+ .rtk-button--prev { background: transparent !important; color: var(--rtk-text) !important; }
197
+ .rtk-button--prev::before { opacity: 0.08; }
198
+ .rtk-button--prev:hover:not(:disabled)::before { opacity: 0.14; }
199
+ .rtk-button--next { background: var(--rtk-primary) !important; color: var(--rtk-on-primary) !important; }
200
+ .rtk-button--next:hover { filter: brightness(1.08); }
201
+ .rtk-button:disabled { cursor: default; opacity: 0.4; }
202
+ .rtk-dots { display: flex; align-items: center; justify-content: center; min-width: 0; }
203
+ .rtk-dot, .rtk-ellipsis {
204
+ position: relative;
205
+ display: grid;
206
+ place-items: center;
207
+ box-sizing: border-box !important;
208
+ width: 24px !important;
209
+ height: 24px !important;
210
+ margin: 0 !important;
211
+ padding: 0 !important;
212
+ border: 0 !important;
213
+ background: transparent !important;
214
+ color: var(--rtk-text) !important;
215
+ }
216
+ .rtk-dot { cursor: pointer; border-radius: 50%; }
217
+ .rtk-dot::before {
218
+ content: '';
219
+ width: 8px;
220
+ height: 8px;
221
+ border-radius: 50%;
222
+ background: currentColor;
223
+ opacity: 0.3;
224
+ transition: opacity 150ms, transform 150ms;
225
+ }
226
+ .rtk-dot[aria-current="step"] { color: var(--rtk-primary) !important; }
227
+ .rtk-dot[aria-current="step"]::before { opacity: 1; transform: scale(1.15); }
228
+ .rtk-ellipsis::before { content: '…'; opacity: 0.5; font-size: 12px; letter-spacing: 1px; }
229
+ .rtk-close:focus-visible, .rtk-button:focus-visible, .rtk-dot:focus-visible {
230
+ outline: 2px solid var(--rtk-primary);
231
+ outline-offset: 2px;
232
+ }
233
+ .rtk-sr-only {
234
+ position: absolute;
235
+ width: 1px;
236
+ height: 1px;
237
+ margin: -1px;
238
+ padding: 0;
239
+ overflow: hidden;
240
+ clip-path: inset(50%);
241
+ white-space: nowrap;
242
+ border: 0;
243
+ }
244
+
245
+ /* Position uses the individual \`translate\` property (applied first), the entrance uses \`transform\`,
246
+ so scaling happens around the tooltip's own centre and never moves its position. Durations,
247
+ offsets and reduced motion come from the shared motion settings, as variables. */
248
+ @keyframes rtk-enter {
249
+ from {
250
+ opacity: 0;
251
+ transform: translate(var(--rtk-enter-x, 0), var(--rtk-enter-y, 0)) scale(var(--rtk-enter-scale, 1));
252
+ }
253
+ }
254
+
255
+ @media (forced-colors: active) {
256
+ .rtk-spotlight { outline: 3px solid Highlight; }
257
+ .rtk-card { border: 1px solid CanvasText; }
258
+ /* Without backgrounds, a border is what shows a button is one. */
259
+ .rtk-button { border: 1px solid ButtonText !important; }
260
+ .rtk-button:disabled { border-color: GrayText !important; }
261
+ .rtk-dot::before { background: CanvasText; }
262
+ .rtk-dot[aria-current="step"]::before { background: Highlight; }
263
+ }
264
+ }
265
+ `;
266
+ const injected = new WeakSet();
267
+ /** Adds the stylesheet to a document once. Constructable stylesheets are not subject to CSP `style-src` restrictions. */
268
+ export function injectTourStyles(document_) {
269
+ if (injected.has(document_)) {
270
+ return;
271
+ }
272
+ injected.add(document_);
273
+ try {
274
+ const sheet = new CSSStyleSheet();
275
+ sheet.replaceSync(tourCss);
276
+ document_.adoptedStyleSheets = [...document_.adoptedStyleSheets, sheet];
277
+ }
278
+ catch {
279
+ const style = document_.createElement('style');
280
+ style.dataset.rtk = '';
281
+ style.textContent = tourCss;
282
+ document_.head.append(style);
283
+ }
284
+ }
285
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/react-platform/layer/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgQtB,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAY,CAAC;AAEzC,yHAAyH;AACzH,MAAM,UAAU,gBAAgB,CAAC,SAAmB;IAClD,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;QAClC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3B,SAAS,CAAC,kBAAkB,GAAG,CAAC,GAAG,SAAS,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,CAAC,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;QACvB,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;QAC5B,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TourRenderer } from '../../shared/renderer/renderer.type.js';
2
+ /** How the web draws the tour. */
3
+ export declare const webRenderer: TourRenderer;
4
+ //# sourceMappingURL=web-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-renderer.d.ts","sourceRoot":"","sources":["../../../src/react-platform/layer/web-renderer.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAgBV,YAAY,EACb,MAAM,wCAAwC,CAAC;AAkjBhD,kCAAkC;AAClC,eAAO,MAAM,WAAW,EAAE,YAA6E,CAAC"}
@@ -0,0 +1,390 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useInsertionEffect, useRef, useState, } from 'react';
3
+ import { clamp } from '../../shared/geometry/box.util.js';
4
+ import { useIsomorphicLayoutEffect } from '../../shared/react/use-isomorphic-layout-effect.hook.js';
5
+ import { motion } from '../../shared/renderer/motion.js';
6
+ import { handlesKey, pageDirection } from '../dom/elements.util.js';
7
+ import { lockScroll } from '../dom/scroll-lock.util.js';
8
+ import { injectTourStyles } from './styles.js';
9
+ const [x1, y1, x2, y2] = motion.easing;
10
+ const standardEasing = `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`;
11
+ // ---------------------------------------------------------------------------------------------
12
+ // Layer: a modal <dialog> in the top layer
13
+ // ---------------------------------------------------------------------------------------------
14
+ /** Elements made inert by the fallback below, so they can be restored. */
15
+ const inertedByTour = new WeakMap();
16
+ /**
17
+ * Opens the dialog as a modal: top layer, rest of the page inert, focus restored on close.
18
+ * Without `showModal` (very old browsers, jsdom) the dialog is shown with a high z-index
19
+ * (`--rtk-z-index`) and the rest of the page is made inert manually.
20
+ */
21
+ function openModal(dialog) {
22
+ if (dialog.open || dialog.hasAttribute('open')) {
23
+ return;
24
+ }
25
+ if (typeof dialog.showModal === 'function') {
26
+ try {
27
+ dialog.showModal();
28
+ return;
29
+ }
30
+ catch {
31
+ // Not connected or not allowed: fall through to the fallback.
32
+ }
33
+ }
34
+ dialog.setAttribute('open', '');
35
+ const others = [...document.body.children].filter((element) => element !== dialog && !element.contains(dialog) && !element.hasAttribute('inert'));
36
+ for (const element of others) {
37
+ element.setAttribute('inert', '');
38
+ }
39
+ inertedByTour.set(dialog, others);
40
+ }
41
+ function closeModal(dialog) {
42
+ if (typeof dialog.close === 'function' && dialog.open) {
43
+ dialog.close();
44
+ }
45
+ else {
46
+ dialog.removeAttribute('open');
47
+ }
48
+ for (const element of inertedByTour.get(dialog) ?? []) {
49
+ element.removeAttribute('inert');
50
+ }
51
+ inertedByTour.delete(dialog);
52
+ }
53
+ function safeMatches(element, selector) {
54
+ try {
55
+ return element.matches(selector);
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
61
+ /** The tooltip on screen, to put focus on. */
62
+ function shownTooltip(dialog) {
63
+ return dialog.querySelector('[data-rtk-tooltip]:not([data-hidden])');
64
+ }
65
+ /**
66
+ * Returns focus to where it was when the tour opened. Browsers do this when a modal dialog closes,
67
+ * but forget where it was once the dialog has been re-opened over one of the app's own.
68
+ */
69
+ function restoreFocus(trigger, dialog) {
70
+ if (!(trigger instanceof HTMLElement) || trigger === document.body || !trigger.isConnected) {
71
+ return;
72
+ }
73
+ const active = document.activeElement;
74
+ if (!active || active === document.body || dialog.contains(active)) {
75
+ trigger.focus({ preventScroll: true });
76
+ }
77
+ }
78
+ /**
79
+ * A modal `<dialog>` in the top layer: above any z-index, with the page inert, focus restored on
80
+ * close and the page kept from scrolling. Keys and the dialog's own close requests become intents.
81
+ */
82
+ function Layer({ children, state, isVisible, fadeMs, isInteractive, theme, titleId, descriptionId, fallbackLabel, announcement, stepKey, onIntent, }) {
83
+ const layerRef = useRef(null);
84
+ const liveRef = useRef(null);
85
+ const reopening = useRef(false);
86
+ const [direction] = useState(pageDirection);
87
+ useInsertionEffect(() => {
88
+ injectTourStyles(document);
89
+ }, []);
90
+ useIsomorphicLayoutEffect(() => {
91
+ const dialog = layerRef.current;
92
+ if (!dialog) {
93
+ return undefined;
94
+ }
95
+ const trigger = document.activeElement;
96
+ openModal(dialog);
97
+ const unlock = lockScroll(dialog);
98
+ return () => {
99
+ unlock();
100
+ reopening.current = true;
101
+ closeModal(dialog);
102
+ restoreFocus(trigger, dialog);
103
+ };
104
+ }, []);
105
+ // If the app opened its own modal (in onBeforeStep), move the tour back on top of it.
106
+ useEffect(() => {
107
+ const dialog = layerRef.current;
108
+ if (!dialog || stepKey === undefined) {
109
+ return;
110
+ }
111
+ const other = [...document.querySelectorAll('dialog')].find((element) => element !== dialog && element.open && safeMatches(element, ':modal'));
112
+ if (other && dialog.open && safeMatches(dialog, ':modal')) {
113
+ const focused = document.activeElement;
114
+ // `close` fires asynchronously; the handler consumes this flag.
115
+ reopening.current = true;
116
+ closeModal(dialog);
117
+ openModal(dialog);
118
+ // Opening focuses the first button: keep focus where it was in the tour.
119
+ const refocus = focused instanceof HTMLElement && dialog.contains(focused) ? focused : shownTooltip(dialog);
120
+ refocus?.focus({ preventScroll: true });
121
+ }
122
+ }, [stepKey]);
123
+ // A custom tooltip may not render an element with the title id: then label the dialog directly.
124
+ useEffect(() => {
125
+ const dialog = layerRef.current;
126
+ if (!dialog || titleId === undefined) {
127
+ return;
128
+ }
129
+ // `getElementById`: ids from useId() contain characters that would need escaping in selectors.
130
+ // eslint-disable-next-line unicorn/prefer-query-selector
131
+ if (document.getElementById(titleId)) {
132
+ dialog.removeAttribute('aria-label');
133
+ }
134
+ else {
135
+ dialog.setAttribute('aria-label', fallbackLabel);
136
+ }
137
+ }, [stepKey, titleId, fallbackLabel]);
138
+ useEffect(() => {
139
+ if (announcement && liveRef.current) {
140
+ liveRef.current.textContent = announcement;
141
+ }
142
+ }, [announcement, stepKey]);
143
+ const style = {
144
+ '--rtk-primary': theme.primaryColor,
145
+ '--rtk-on-primary': theme.primaryTextColor,
146
+ '--rtk-bg': theme.tooltipBackground,
147
+ '--rtk-title': theme.titleColor,
148
+ '--rtk-text': theme.contentColor,
149
+ '--rtk-overlay': theme.overlayColor,
150
+ '--rtk-fade-duration': `${fadeMs}ms`,
151
+ };
152
+ const onKeyDown = (event) => {
153
+ const { nativeEvent, key } = event;
154
+ if (!isInteractive ||
155
+ event.defaultPrevented ||
156
+ nativeEvent.isComposing ||
157
+ event.altKey ||
158
+ event.ctrlKey ||
159
+ event.metaKey) {
160
+ return;
161
+ }
162
+ if (key === 'Escape') {
163
+ event.preventDefault();
164
+ onIntent('escape');
165
+ return;
166
+ }
167
+ if ((key === 'ArrowRight' || key === 'ArrowLeft') && !handlesKey(event.target, key)) {
168
+ event.preventDefault();
169
+ // In right-to-left pages, the arrow pointing to the start goes forward.
170
+ const isForward = (key === 'ArrowRight') !== (direction === 'rtl');
171
+ onIntent(isForward ? 'next' : 'previous');
172
+ }
173
+ };
174
+ return (_jsxs("dialog", { ref: layerRef, className: "rtk-root", "data-rtk-root": "", "data-state": state, "data-visible": isVisible ? '' : undefined, dir: direction === 'rtl' ? 'rtl' : undefined, "aria-labelledby": titleId, "aria-describedby": descriptionId, style: style, onKeyDown: onKeyDown, onCancel: (event) => {
175
+ // Escape (and the Android back gesture) fire `cancel`; the tour decides how to close.
176
+ event.preventDefault();
177
+ onIntent('escape');
178
+ }, onClose: () => {
179
+ if (reopening.current) {
180
+ reopening.current = false;
181
+ return;
182
+ }
183
+ // The browser closed the dialog by force (for example a second Escape press).
184
+ onIntent('escape');
185
+ }, children: [children, _jsx("div", { ref: liveRef, className: "rtk-sr-only", "aria-live": "polite", "aria-atomic": "true" })] }));
186
+ }
187
+ function Backdrop({ isDismissible, onPress }) {
188
+ return (_jsx("div", { className: "rtk-backdrop", "data-rtk-backdrop": "", "data-closable": isDismissible ? '' : undefined, onClick: (event) => {
189
+ onPress({ x: event.clientX, y: event.clientY });
190
+ } }));
191
+ }
192
+ const spotlightProperties = ['left', 'top', 'width', 'height', 'border-radius'];
193
+ /** How far off screen a hole may be: past the ring around it. */
194
+ const offScreenMargin = 16;
195
+ /**
196
+ * Keeps a hole that is far off screen (a target still to be scrolled to) just past the screen's
197
+ * edge: the dim is the hole's shadow, which only reaches so far.
198
+ */
199
+ function nearScreen(hole) {
200
+ const width = document.documentElement.clientWidth || globalThis.innerWidth;
201
+ const height = document.documentElement.clientHeight || globalThis.innerHeight;
202
+ return {
203
+ ...hole,
204
+ x: clamp(hole.x, -offScreenMargin - hole.width, width + offScreenMargin),
205
+ y: clamp(hole.y, -offScreenMargin - hole.height, height + offScreenMargin),
206
+ };
207
+ }
208
+ /** The dimmed overlay with a rounded hole, drawn with a single box-shadow. */
209
+ function Spotlight({ hole: requested, transition }) {
210
+ const hole = requested ? nearScreen(requested) : undefined;
211
+ const style = hole
212
+ ? {
213
+ left: hole.x,
214
+ top: hole.y,
215
+ width: hole.width,
216
+ height: hole.height,
217
+ borderRadius: `min(var(--rtk-spotlight-radius), ${hole.width / 2}px, ${hole.height / 2}px)`,
218
+ }
219
+ : { left: '50%', top: '50%', width: 0, height: 0, borderRadius: 0 };
220
+ if (transition) {
221
+ const easing = transition.easing === 'linear' ? 'linear' : standardEasing;
222
+ style.transition = spotlightProperties
223
+ .map((property) => `${property} ${transition.durationMs}ms ${easing}`)
224
+ .join(', ');
225
+ }
226
+ return (_jsx("div", { "aria-hidden": "true", className: "rtk-spotlight", "data-rtk-spotlight": "", "data-collapsed": hole ? undefined : '', style: style }));
227
+ }
228
+ function isVerticalWritingMode(element) {
229
+ return getComputedStyle(element).writingMode.startsWith('vertical');
230
+ }
231
+ /**
232
+ * True when the tooltip's content is bigger than its frame (it reached the size limits), so the
233
+ * frame has to scroll. Decorations sticking out of the content (the arrow) do not count.
234
+ */
235
+ function overflowsFrame(frame) {
236
+ const children = [...frame.children].filter((child) => child instanceof HTMLElement);
237
+ if (children.length === 0 || children.length < frame.children.length) {
238
+ return frame.scrollHeight > frame.clientHeight + 1 || frame.scrollWidth > frame.clientWidth + 1;
239
+ }
240
+ let left = 0;
241
+ let top = 0;
242
+ let right = 0;
243
+ let bottom = 0;
244
+ for (const child of children) {
245
+ left = Math.min(left, child.offsetLeft);
246
+ top = Math.min(top, child.offsetTop);
247
+ right = Math.max(right, child.offsetLeft + child.offsetWidth);
248
+ bottom = Math.max(bottom, child.offsetTop + child.offsetHeight);
249
+ }
250
+ return left < -1 || top < -1 || right > frame.clientWidth + 1 || bottom > frame.clientHeight + 1;
251
+ }
252
+ /** Positions the tooltip (with `translate`, so the entrance's `transform` never moves it), reports its size and takes focus. */
253
+ function TooltipFrame({ children, layout, entrance, isBusy, isHidden, onSize }) {
254
+ const ref = useRef(null);
255
+ const [isEntering, setIsEntering] = useState(true);
256
+ const [isOverflowing, setIsOverflowing] = useState(false);
257
+ // Report size changes (late-loading fonts or images, content changes); keep scrolling available
258
+ // when the content does not fit. Sizes come from ResizeObserver's border box: unlike
259
+ // getBoundingClientRect it ignores the entrance animation's scale. The content is observed too:
260
+ // it can keep growing once the frame has reached its size limits.
261
+ useIsomorphicLayoutEffect(() => {
262
+ const element = ref.current;
263
+ if (!element) {
264
+ return undefined;
265
+ }
266
+ const report = (box) => {
267
+ const isVertical = isVerticalWritingMode(element);
268
+ const width = box ? (isVertical ? box.blockSize : box.inlineSize) : element.offsetWidth;
269
+ const height = box ? (isVertical ? box.inlineSize : box.blockSize) : element.offsetHeight;
270
+ onSize({ width, height });
271
+ };
272
+ if (typeof ResizeObserver !== 'function') {
273
+ // No ResizeObserver (jsdom): report the size once.
274
+ report(undefined);
275
+ return undefined;
276
+ }
277
+ const observer = new ResizeObserver((entries) => {
278
+ setIsOverflowing(overflowsFrame(element));
279
+ const own = entries.find((entry) => entry.target === element);
280
+ if (own) {
281
+ report(own.borderBoxSize?.[0]);
282
+ }
283
+ });
284
+ observer.observe(element);
285
+ for (const child of element.children) {
286
+ observer.observe(child);
287
+ }
288
+ return () => {
289
+ observer.disconnect();
290
+ };
291
+ }, [onSize]);
292
+ // Move focus into the tooltip so screen readers read it and keyboard users can act on it.
293
+ useEffect(() => {
294
+ ref.current?.focus({ preventScroll: true });
295
+ }, []);
296
+ const style = {
297
+ translate: `${layout.x}px ${layout.y}px`,
298
+ maxWidth: layout.maxWidth,
299
+ maxHeight: layout.maxHeight,
300
+ '--rtk-max-height': `${layout.maxHeight}px`,
301
+ '--rtk-enter-x': `${entrance.dx}px`,
302
+ '--rtk-enter-y': `${entrance.dy}px`,
303
+ '--rtk-enter-scale': String(entrance.scale),
304
+ '--rtk-enter-duration': `${entrance.durationMs}ms`,
305
+ '--rtk-enter-delay': `${entrance.delayMs}ms`,
306
+ };
307
+ return (_jsx("div", { ref: ref, className: "rtk-tooltip", "data-rtk-tooltip": "", "data-placement": layout.placement, "data-entering": isEntering ? '' : undefined, "data-hidden": isHidden ? '' : undefined, "data-overflowing": isOverflowing ? '' : undefined, "aria-busy": isBusy ? 'true' : undefined, tabIndex: -1, style: style, onAnimationEnd: (event) => {
308
+ // Animations inside a custom tooltip bubble up here too.
309
+ if (event.target === event.currentTarget) {
310
+ setIsEntering(false);
311
+ }
312
+ }, children: children }));
313
+ }
314
+ function MeasureFrame({ children, maxWidth, maxHeight, onSize }) {
315
+ const ref = useRef(null);
316
+ useIsomorphicLayoutEffect(() => {
317
+ const element = ref.current;
318
+ if (element) {
319
+ const rect = element.getBoundingClientRect();
320
+ onSize({ width: rect.width, height: rect.height });
321
+ }
322
+ }, [onSize]);
323
+ const style = { maxWidth, maxHeight, '--rtk-max-height': `${maxHeight}px` };
324
+ return (_jsx("div", { ref: ref, "aria-hidden": "true", className: "rtk-measure", style: style, children: children }));
325
+ }
326
+ // ---------------------------------------------------------------------------------------------
327
+ // Card parts
328
+ // ---------------------------------------------------------------------------------------------
329
+ function CloseIcon() {
330
+ return (_jsx("svg", { "aria-hidden": "true", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", focusable: "false", children: _jsx("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" }) }));
331
+ }
332
+ function Card({ placement, children }) {
333
+ return (_jsx("div", { className: "rtk-card", "data-placement": placement, children: children }));
334
+ }
335
+ function Arrow({ side, offset }) {
336
+ const style = { '--rtk-arrow-offset': `${offset}px` };
337
+ return _jsx("div", { "aria-hidden": "true", className: "rtk-arrow", "data-side": side, style: style });
338
+ }
339
+ function Header({ children }) {
340
+ return _jsx("div", { className: "rtk-header", children: children });
341
+ }
342
+ function Counter({ text }) {
343
+ return _jsx("span", { className: "rtk-counter", children: text });
344
+ }
345
+ function CloseButton({ label, onPress }) {
346
+ return (_jsx("button", { type: "button", className: "rtk-close", "aria-label": label, onClick: onPress, children: _jsx(CloseIcon, {}) }));
347
+ }
348
+ function Body({ children }) {
349
+ return _jsx("div", { className: "rtk-body", children: children });
350
+ }
351
+ /** A heading by role rather than an `<h2>`: global heading styles (resets, typography) do not reach it. */
352
+ function Title({ id, children }) {
353
+ return (_jsx("div", { id: id, role: "heading", "aria-level": 2, className: "rtk-title", children: children }));
354
+ }
355
+ function Content({ id, children }) {
356
+ return (_jsx("div", { id: id, className: "rtk-content", children: children }));
357
+ }
358
+ function Footer({ children }) {
359
+ return _jsx("div", { className: "rtk-footer", children: children });
360
+ }
361
+ function Button({ kind, label, isDisabled, onPress }) {
362
+ return (_jsx("button", { type: "button", className: kind === 'next' ? 'rtk-button rtk-button--next' : 'rtk-button rtk-button--prev', disabled: isDisabled, onClick: onPress, children: label }));
363
+ }
364
+ function Dots({ label, children }) {
365
+ return (_jsx("div", { className: "rtk-dots", role: "group", "aria-label": label, children: children }));
366
+ }
367
+ function Dot({ label, isCurrent, onPress }) {
368
+ return (_jsx("button", { type: "button", className: "rtk-dot", "aria-label": label, "aria-current": isCurrent ? 'step' : undefined, onClick: onPress }));
369
+ }
370
+ function Ellipsis() {
371
+ return _jsx("span", { "aria-hidden": "true", className: "rtk-ellipsis" });
372
+ }
373
+ const card = {
374
+ Card,
375
+ Arrow,
376
+ Header,
377
+ Counter,
378
+ CloseButton,
379
+ Body,
380
+ Title,
381
+ Content,
382
+ Footer,
383
+ Button,
384
+ Dots,
385
+ Dot,
386
+ Ellipsis,
387
+ };
388
+ /** How the web draws the tour. */
389
+ export const webRenderer = { Layer, Backdrop, Spotlight, TooltipFrame, MeasureFrame, card };
390
+ //# sourceMappingURL=web-renderer.js.map