@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.
- package/CHANGELOG.md +48 -0
- package/MIGRATION.md +205 -0
- package/README.md +401 -850
- package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.d.ts +14 -0
- package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.d.ts.map +1 -0
- package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.js +21 -0
- package/dist/react-native-platform/hooks/use-tour-scroll-view.hook.js.map +1 -0
- package/dist/react-native-platform/hooks/use-tour-target.hook.d.ts +15 -0
- package/dist/react-native-platform/hooks/use-tour-target.hook.d.ts.map +1 -0
- package/dist/react-native-platform/hooks/use-tour-target.hook.js +28 -0
- package/dist/react-native-platform/hooks/use-tour-target.hook.js.map +1 -0
- package/dist/react-native-platform/host-store.d.ts +24 -0
- package/dist/react-native-platform/host-store.d.ts.map +1 -0
- package/dist/react-native-platform/host-store.js +63 -0
- package/dist/react-native-platform/host-store.js.map +1 -0
- package/dist/react-native-platform/insets.util.d.ts +11 -0
- package/dist/react-native-platform/insets.util.d.ts.map +1 -0
- package/dist/react-native-platform/insets.util.js +31 -0
- package/dist/react-native-platform/insets.util.js.map +1 -0
- package/dist/react-native-platform/layer/native-renderer.d.ts +7 -0
- package/dist/react-native-platform/layer/native-renderer.d.ts.map +1 -0
- package/dist/react-native-platform/layer/native-renderer.js +496 -0
- package/dist/react-native-platform/layer/native-renderer.js.map +1 -0
- package/dist/react-native-platform/layer/tour-host.d.ts +13 -0
- package/dist/react-native-platform/layer/tour-host.d.ts.map +1 -0
- package/dist/react-native-platform/layer/tour-host.js +70 -0
- package/dist/react-native-platform/layer/tour-host.js.map +1 -0
- package/dist/react-native-platform/measure.util.d.ts +20 -0
- package/dist/react-native-platform/measure.util.d.ts.map +1 -0
- package/dist/react-native-platform/measure.util.js +100 -0
- package/dist/react-native-platform/measure.util.js.map +1 -0
- package/dist/react-native-platform/native-context.d.ts +12 -0
- package/dist/react-native-platform/native-context.d.ts.map +1 -0
- package/dist/react-native-platform/native-context.js +4 -0
- package/dist/react-native-platform/native-context.js.map +1 -0
- package/dist/react-native-platform/native-environment.d.ts +14 -0
- package/dist/react-native-platform/native-environment.d.ts.map +1 -0
- package/dist/react-native-platform/native-environment.js +20 -0
- package/dist/react-native-platform/native-environment.js.map +1 -0
- package/dist/react-native-platform/native-platform.d.ts +19 -0
- package/dist/react-native-platform/native-platform.d.ts.map +1 -0
- package/dist/react-native-platform/native-platform.js +265 -0
- package/dist/react-native-platform/native-platform.js.map +1 -0
- package/dist/react-native-platform/reduced-motion.d.ts +4 -0
- package/dist/react-native-platform/reduced-motion.d.ts.map +1 -0
- package/dist/react-native-platform/reduced-motion.js +44 -0
- package/dist/react-native-platform/reduced-motion.js.map +1 -0
- package/dist/react-native-platform/registry.d.ts +18 -0
- package/dist/react-native-platform/registry.d.ts.map +1 -0
- package/dist/react-native-platform/registry.js +51 -0
- package/dist/react-native-platform/registry.js.map +1 -0
- package/dist/react-native-platform/tour-provider.d.ts +16 -3
- package/dist/react-native-platform/tour-provider.d.ts.map +1 -0
- package/dist/react-native-platform/tour-provider.js +92 -211
- package/dist/react-native-platform/tour-provider.js.map +1 -1
- package/dist/react-native.d.ts +14 -10
- package/dist/react-native.d.ts.map +1 -0
- package/dist/react-native.js +7 -7
- package/dist/react-native.js.map +1 -1
- package/dist/react-platform/dom/elements.util.d.ts +35 -0
- package/dist/react-platform/dom/elements.util.d.ts.map +1 -0
- package/dist/react-platform/dom/elements.util.js +155 -0
- package/dist/react-platform/dom/elements.util.js.map +1 -0
- package/dist/react-platform/dom/occluders.util.d.ts +13 -0
- package/dist/react-platform/dom/occluders.util.d.ts.map +1 -0
- package/dist/react-platform/dom/occluders.util.js +75 -0
- package/dist/react-platform/dom/occluders.util.js.map +1 -0
- package/dist/react-platform/dom/scroll-lock.util.d.ts +13 -0
- package/dist/react-platform/dom/scroll-lock.util.d.ts.map +1 -0
- package/dist/react-platform/dom/scroll-lock.util.js +219 -0
- package/dist/react-platform/dom/scroll-lock.util.js.map +1 -0
- package/dist/react-platform/dom/scroll.util.d.ts +44 -0
- package/dist/react-platform/dom/scroll.util.d.ts.map +1 -0
- package/dist/react-platform/dom/scroll.util.js +250 -0
- package/dist/react-platform/dom/scroll.util.js.map +1 -0
- package/dist/react-platform/dom/viewport.util.d.ts +16 -0
- package/dist/react-platform/dom/viewport.util.d.ts.map +1 -0
- package/dist/react-platform/dom/viewport.util.js +65 -0
- package/dist/react-platform/dom/viewport.util.js.map +1 -0
- package/dist/react-platform/dom/web-platform.d.ts +15 -0
- package/dist/react-platform/dom/web-platform.d.ts.map +1 -0
- package/dist/react-platform/dom/web-platform.js +169 -0
- package/dist/react-platform/dom/web-platform.js.map +1 -0
- package/dist/react-platform/layer/styles.d.ts +12 -0
- package/dist/react-platform/layer/styles.d.ts.map +1 -0
- package/dist/react-platform/layer/styles.js +285 -0
- package/dist/react-platform/layer/styles.js.map +1 -0
- package/dist/react-platform/layer/web-renderer.d.ts +4 -0
- package/dist/react-platform/layer/web-renderer.d.ts.map +1 -0
- package/dist/react-platform/layer/web-renderer.js +390 -0
- package/dist/react-platform/layer/web-renderer.js.map +1 -0
- package/dist/react-platform/tour-provider.d.ts +9 -3
- package/dist/react-platform/tour-provider.d.ts.map +1 -0
- package/dist/react-platform/tour-provider.js +28 -218
- package/dist/react-platform/tour-provider.js.map +1 -1
- package/dist/react.d.ts +10 -10
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +5 -7
- package/dist/react.js.map +1 -1
- package/dist/shared/engine/abort.util.d.ts +17 -0
- package/dist/shared/engine/abort.util.d.ts.map +1 -0
- package/dist/shared/engine/abort.util.js +72 -0
- package/dist/shared/engine/abort.util.js.map +1 -0
- package/dist/shared/engine/report.util.d.ts +12 -0
- package/dist/shared/engine/report.util.d.ts.map +1 -0
- package/dist/shared/engine/report.util.js +51 -0
- package/dist/shared/engine/report.util.js.map +1 -0
- package/dist/shared/engine/tour-adapter.type.d.ts +67 -0
- package/dist/shared/engine/tour-adapter.type.d.ts.map +1 -0
- package/dist/shared/engine/tour-adapter.type.js +2 -0
- package/dist/shared/engine/tour-adapter.type.js.map +1 -0
- package/dist/shared/engine/tour-engine.d.ts +101 -0
- package/dist/shared/engine/tour-engine.d.ts.map +1 -0
- package/dist/shared/engine/tour-engine.js +835 -0
- package/dist/shared/engine/tour-engine.js.map +1 -0
- package/dist/shared/geometry/box.util.d.ts +39 -0
- package/dist/shared/geometry/box.util.d.ts.map +1 -0
- package/dist/shared/geometry/box.util.js +146 -0
- package/dist/shared/geometry/box.util.js.map +1 -0
- package/dist/shared/geometry/compute-tooltip-layout.util.d.ts +60 -0
- package/dist/shared/geometry/compute-tooltip-layout.util.d.ts.map +1 -0
- package/dist/shared/geometry/compute-tooltip-layout.util.js +148 -0
- package/dist/shared/geometry/compute-tooltip-layout.util.js.map +1 -0
- package/dist/shared/geometry/geometry.type.d.ts +34 -0
- package/dist/shared/geometry/geometry.type.d.ts.map +1 -0
- package/dist/shared/geometry/geometry.type.js +2 -0
- package/dist/shared/geometry/geometry.type.js.map +1 -0
- package/dist/shared/geometry/reveal.util.d.ts +38 -0
- package/dist/shared/geometry/reveal.util.d.ts.map +1 -0
- package/dist/shared/geometry/reveal.util.js +135 -0
- package/dist/shared/geometry/reveal.util.js.map +1 -0
- package/dist/shared/geometry/target-visibility.util.d.ts +10 -0
- package/dist/shared/geometry/target-visibility.util.d.ts.map +1 -0
- package/dist/shared/geometry/target-visibility.util.js +29 -0
- package/dist/shared/geometry/target-visibility.util.js.map +1 -0
- package/dist/shared/platform/create-tour-adapter.d.ts +9 -0
- package/dist/shared/platform/create-tour-adapter.d.ts.map +1 -0
- package/dist/shared/platform/create-tour-adapter.js +145 -0
- package/dist/shared/platform/create-tour-adapter.js.map +1 -0
- package/dist/shared/platform/platform.type.d.ts +77 -0
- package/dist/shared/platform/platform.type.d.ts.map +1 -0
- package/dist/shared/platform/platform.type.js +2 -0
- package/dist/shared/platform/platform.type.js.map +1 -0
- package/dist/shared/platform/reveal-in-scroll-containers.d.ts +27 -0
- package/dist/shared/platform/reveal-in-scroll-containers.d.ts.map +1 -0
- package/dist/shared/platform/reveal-in-scroll-containers.js +49 -0
- package/dist/shared/platform/reveal-in-scroll-containers.js.map +1 -0
- package/dist/shared/react/tour-context.d.ts +7 -0
- package/dist/shared/react/tour-context.d.ts.map +1 -0
- package/dist/shared/react/tour-context.js +23 -0
- package/dist/shared/react/tour-context.js.map +1 -0
- package/dist/shared/react/tour-provider-core.d.ts +41 -0
- package/dist/shared/react/tour-provider-core.d.ts.map +1 -0
- package/dist/shared/react/tour-provider-core.js +24 -0
- package/dist/shared/react/tour-provider-core.js.map +1 -0
- package/dist/shared/react/tour-root.d.ts +14 -0
- package/dist/shared/react/tour-root.d.ts.map +1 -0
- package/dist/shared/react/tour-root.js +22 -0
- package/dist/shared/react/tour-root.js.map +1 -0
- package/dist/shared/react/use-isomorphic-layout-effect.hook.d.ts +4 -0
- package/dist/shared/react/use-isomorphic-layout-effect.hook.d.ts.map +1 -0
- package/dist/shared/react/use-isomorphic-layout-effect.hook.js +5 -0
- package/dist/shared/react/use-isomorphic-layout-effect.hook.js.map +1 -0
- package/dist/shared/react/use-tour-view.hook.d.ts +5 -0
- package/dist/shared/react/use-tour-view.hook.d.ts.map +1 -0
- package/dist/shared/react/use-tour-view.hook.js +14 -0
- package/dist/shared/react/use-tour-view.hook.js.map +1 -0
- package/dist/shared/react/use-tour.hook.d.ts +7 -0
- package/dist/shared/react/use-tour.hook.d.ts.map +1 -0
- package/dist/shared/react/use-tour.hook.js +10 -0
- package/dist/shared/react/use-tour.hook.js.map +1 -0
- package/dist/shared/renderer/default-tooltip.d.ts +5 -0
- package/dist/shared/renderer/default-tooltip.d.ts.map +1 -0
- package/dist/shared/renderer/default-tooltip.js +13 -0
- package/dist/shared/renderer/default-tooltip.js.map +1 -0
- package/dist/shared/renderer/motion.d.ts +29 -0
- package/dist/shared/renderer/motion.d.ts.map +1 -0
- package/dist/shared/renderer/motion.js +49 -0
- package/dist/shared/renderer/motion.js.map +1 -0
- package/dist/shared/renderer/renderer-context.d.ts +17 -0
- package/dist/shared/renderer/renderer-context.d.ts.map +1 -0
- package/dist/shared/renderer/renderer-context.js +16 -0
- package/dist/shared/renderer/renderer-context.js.map +1 -0
- package/dist/shared/renderer/renderer.type.d.ts +164 -0
- package/dist/shared/renderer/renderer.type.d.ts.map +1 -0
- package/dist/shared/renderer/renderer.type.js +2 -0
- package/dist/shared/renderer/renderer.type.js.map +1 -0
- package/dist/shared/renderer/tooltip-model.d.ts +32 -0
- package/dist/shared/renderer/tooltip-model.d.ts.map +1 -0
- package/dist/shared/renderer/tooltip-model.js +24 -0
- package/dist/shared/renderer/tooltip-model.js.map +1 -0
- package/dist/shared/renderer/tour-overlay.d.ts +24 -0
- package/dist/shared/renderer/tour-overlay.d.ts.map +1 -0
- package/dist/shared/renderer/tour-overlay.js +228 -0
- package/dist/shared/renderer/tour-overlay.js.map +1 -0
- package/dist/shared/types/tour-context.type.d.ts +21 -11
- package/dist/shared/types/tour-context.type.d.ts.map +1 -0
- package/dist/shared/types/tour-end-info.type.d.ts +19 -2
- package/dist/shared/types/tour-end-info.type.d.ts.map +1 -0
- package/dist/shared/types/tour-i18n.type.d.ts +8 -0
- package/dist/shared/types/tour-i18n.type.d.ts.map +1 -0
- package/dist/shared/types/tour-step.type.d.ts +35 -6
- package/dist/shared/types/tour-step.type.d.ts.map +1 -0
- package/dist/shared/types/tour-theme.type.d.ts +22 -2
- package/dist/shared/types/tour-theme.type.d.ts.map +1 -0
- package/dist/shared/types/tour-theme.type.js +1 -16
- package/dist/shared/types/tour-theme.type.js.map +1 -1
- package/dist/shared/types/tour-tooltip-props.type.d.ts +21 -17
- package/dist/shared/types/tour-tooltip-props.type.d.ts.map +1 -0
- package/dist/shared/utils/frame.util.d.ts +6 -0
- package/dist/shared/utils/frame.util.d.ts.map +1 -0
- package/dist/shared/utils/frame.util.js +20 -0
- package/dist/shared/utils/frame.util.js.map +1 -0
- package/dist/shared/utils/get-truncated-dots.util.d.ts +13 -7
- package/dist/shared/utils/get-truncated-dots.util.d.ts.map +1 -0
- package/dist/shared/utils/get-truncated-dots.util.js +30 -30
- package/dist/shared/utils/get-truncated-dots.util.js.map +1 -1
- package/dist/shared/utils/i18n.util.d.ts +7 -0
- package/dist/shared/utils/i18n.util.d.ts.map +1 -0
- package/dist/shared/utils/i18n.util.js +34 -0
- package/dist/shared/utils/i18n.util.js.map +1 -0
- package/dist/shared/utils/theme.util.d.ts +6 -0
- package/dist/shared/utils/theme.util.d.ts.map +1 -0
- package/dist/shared/utils/theme.util.js +31 -0
- package/dist/shared/utils/theme.util.js.map +1 -0
- package/package.json +72 -55
- package/src/react-native-platform/hooks/use-tour-scroll-view.hook.ts +24 -0
- package/src/react-native-platform/hooks/use-tour-target.hook.ts +30 -0
- package/src/react-native-platform/host-store.ts +92 -0
- package/src/react-native-platform/insets.util.ts +39 -0
- package/src/react-native-platform/layer/native-renderer.tsx +776 -0
- package/src/react-native-platform/layer/tour-host.tsx +105 -0
- package/src/react-native-platform/measure.util.ts +140 -0
- package/src/react-native-platform/native-context.ts +15 -0
- package/src/react-native-platform/native-environment.ts +33 -0
- package/src/react-native-platform/native-platform.ts +368 -0
- package/src/react-native-platform/reduced-motion.ts +47 -0
- package/src/react-native-platform/registry.ts +70 -0
- package/src/react-native-platform/tour-provider.tsx +148 -0
- package/src/react-native.ts +15 -0
- package/src/react-platform/dom/elements.util.ts +191 -0
- package/src/react-platform/dom/occluders.util.ts +88 -0
- package/src/react-platform/dom/scroll-lock.util.ts +261 -0
- package/src/react-platform/dom/scroll.util.ts +310 -0
- package/src/react-platform/dom/viewport.util.ts +74 -0
- package/src/react-platform/dom/web-platform.ts +208 -0
- package/src/react-platform/layer/styles.ts +286 -0
- package/src/react-platform/layer/web-renderer.tsx +594 -0
- package/src/react-platform/tour-provider.tsx +44 -0
- package/src/react.ts +13 -0
- package/src/shared/engine/abort.util.ts +84 -0
- package/src/shared/engine/report.util.ts +58 -0
- package/src/shared/engine/tour-adapter.type.ts +73 -0
- package/src/shared/engine/tour-engine.ts +1147 -0
- package/src/shared/geometry/box.util.ts +185 -0
- package/src/shared/geometry/compute-tooltip-layout.util.ts +238 -0
- package/src/shared/geometry/geometry.type.ts +38 -0
- package/src/shared/geometry/reveal.util.ts +190 -0
- package/src/shared/geometry/target-visibility.util.ts +44 -0
- package/src/shared/platform/create-tour-adapter.ts +169 -0
- package/src/shared/platform/platform.type.ts +81 -0
- package/src/shared/platform/reveal-in-scroll-containers.ts +78 -0
- package/src/shared/react/tour-context.ts +28 -0
- package/src/shared/react/tour-provider-core.ts +67 -0
- package/src/shared/react/tour-root.tsx +34 -0
- package/src/shared/react/use-isomorphic-layout-effect.hook.ts +7 -0
- package/src/shared/react/use-tour-view.hook.ts +17 -0
- package/src/shared/react/use-tour.hook.ts +11 -0
- package/src/shared/renderer/default-tooltip.tsx +52 -0
- package/src/shared/renderer/motion.ts +59 -0
- package/src/shared/renderer/renderer-context.ts +33 -0
- package/src/shared/renderer/renderer.type.ts +183 -0
- package/src/shared/renderer/tooltip-model.ts +44 -0
- package/src/shared/renderer/tour-overlay.tsx +453 -0
- package/src/shared/types/tour-context.type.ts +23 -0
- package/src/shared/types/tour-end-info.type.ts +32 -0
- package/src/shared/types/tour-i18n.type.ts +15 -0
- package/src/shared/types/tour-step.type.ts +40 -0
- package/src/shared/types/tour-theme.type.ts +28 -0
- package/src/shared/types/tour-tooltip-props.type.ts +27 -0
- package/src/shared/utils/frame.util.ts +21 -0
- package/src/shared/utils/get-truncated-dots.util.ts +46 -0
- package/src/shared/utils/i18n.util.ts +44 -0
- package/src/shared/utils/theme.util.ts +38 -0
- package/dist/react-native-platform/components/index.d.ts +0 -2
- package/dist/react-native-platform/components/index.js +0 -3
- package/dist/react-native-platform/components/index.js.map +0 -1
- package/dist/react-native-platform/components/tour-overlay.d.ts +0 -3
- package/dist/react-native-platform/components/tour-overlay.js +0 -26
- package/dist/react-native-platform/components/tour-overlay.js.map +0 -1
- package/dist/react-native-platform/components/tour-tooltip.d.ts +0 -3
- package/dist/react-native-platform/components/tour-tooltip.js +0 -167
- package/dist/react-native-platform/components/tour-tooltip.js.map +0 -1
- package/dist/react-native-platform/hooks/index.d.ts +0 -1
- package/dist/react-native-platform/hooks/index.js +0 -2
- package/dist/react-native-platform/hooks/index.js.map +0 -1
- package/dist/react-native-platform/hooks/use-tour-target.d.ts +0 -2
- package/dist/react-native-platform/hooks/use-tour-target.js +0 -13
- package/dist/react-native-platform/hooks/use-tour-target.js.map +0 -1
- package/dist/react-native-platform/index.d.ts +0 -7
- package/dist/react-native-platform/index.js +0 -7
- package/dist/react-native-platform/index.js.map +0 -1
- package/dist/react-native-platform/platform-adapter.d.ts +0 -2
- package/dist/react-native-platform/platform-adapter.js +0 -84
- package/dist/react-native-platform/platform-adapter.js.map +0 -1
- package/dist/react-native-platform/target-registry.d.ts +0 -10
- package/dist/react-native-platform/target-registry.js +0 -17
- package/dist/react-native-platform/target-registry.js.map +0 -1
- package/dist/react-native-platform/types/tour-provider.props.type.d.ts +0 -12
- package/dist/react-native-platform/types/tour-provider.props.type.js +0 -2
- package/dist/react-native-platform/types/tour-provider.props.type.js.map +0 -1
- package/dist/react-platform/components/index.d.ts +0 -2
- package/dist/react-platform/components/index.js +0 -3
- package/dist/react-platform/components/index.js.map +0 -1
- package/dist/react-platform/components/tour-overlay.d.ts +0 -3
- package/dist/react-platform/components/tour-overlay.js +0 -29
- package/dist/react-platform/components/tour-overlay.js.map +0 -1
- package/dist/react-platform/components/tour-tooltip.d.ts +0 -2
- package/dist/react-platform/components/tour-tooltip.js +0 -155
- package/dist/react-platform/components/tour-tooltip.js.map +0 -1
- package/dist/react-platform/index.d.ts +0 -6
- package/dist/react-platform/index.js +0 -6
- package/dist/react-platform/index.js.map +0 -1
- package/dist/react-platform/platform-adapter.d.ts +0 -2
- package/dist/react-platform/platform-adapter.js +0 -101
- package/dist/react-platform/platform-adapter.js.map +0 -1
- package/dist/react-platform/types/tour-provider.props.type.d.ts +0 -12
- package/dist/react-platform/types/tour-provider.props.type.js +0 -2
- package/dist/react-platform/types/tour-provider.props.type.js.map +0 -1
- package/dist/react-platform/utils/find-visible-element.util.d.ts +0 -1
- package/dist/react-platform/utils/find-visible-element.util.js +0 -11
- package/dist/react-platform/utils/find-visible-element.util.js.map +0 -1
- package/dist/react-platform/utils/index.d.ts +0 -1
- package/dist/react-platform/utils/index.js +0 -2
- package/dist/react-platform/utils/index.js.map +0 -1
- package/dist/shared/context/index.d.ts +0 -1
- package/dist/shared/context/index.js +0 -2
- package/dist/shared/context/index.js.map +0 -1
- package/dist/shared/context/tour-context.d.ts +0 -3
- package/dist/shared/context/tour-context.js +0 -14
- package/dist/shared/context/tour-context.js.map +0 -1
- package/dist/shared/hooks/index.d.ts +0 -1
- package/dist/shared/hooks/index.js +0 -2
- package/dist/shared/hooks/index.js.map +0 -1
- package/dist/shared/hooks/use-tour.hook.d.ts +0 -2
- package/dist/shared/hooks/use-tour.hook.js +0 -7
- package/dist/shared/hooks/use-tour.hook.js.map +0 -1
- package/dist/shared/index.d.ts +0 -7
- package/dist/shared/index.js +0 -6
- package/dist/shared/index.js.map +0 -1
- package/dist/shared/types/index.d.ts +0 -10
- package/dist/shared/types/index.js +0 -2
- package/dist/shared/types/index.js.map +0 -1
- package/dist/shared/types/platform-adapter.type.d.ts +0 -24
- package/dist/shared/types/platform-adapter.type.js +0 -2
- package/dist/shared/types/platform-adapter.type.js.map +0 -1
- package/dist/shared/types/rect.type.d.ts +0 -11
- package/dist/shared/types/rect.type.js +0 -2
- package/dist/shared/types/rect.type.js.map +0 -1
- package/dist/shared/types/tour-overlay-props.type.d.ts +0 -8
- package/dist/shared/types/tour-overlay-props.type.js +0 -2
- package/dist/shared/types/tour-overlay-props.type.js.map +0 -1
- package/dist/shared/utils/calculate-tooltip-position.util.d.ts +0 -14
- package/dist/shared/utils/calculate-tooltip-position.util.js +0 -49
- package/dist/shared/utils/calculate-tooltip-position.util.js.map +0 -1
- package/dist/shared/utils/index.d.ts +0 -3
- package/dist/shared/utils/index.js +0 -3
- package/dist/shared/utils/index.js.map +0 -1
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
14
|
+
const total = Number.isFinite(totalSteps) ? Math.max(0, Math.floor(totalSteps)) : 0;
|
|
15
|
+
if (total === 0) {
|
|
16
|
+
return [];
|
|
8
17
|
}
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
|
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":"
|
|
1
|
+
{"version":3,"file":"get-truncated-dots.util.js","sourceRoot":"","sources":["../../../src/shared/utils/get-truncated-dots.util.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,QAAQ,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtC,SAAS,KAAK,CAAC,IAAY,EAAE,EAAU;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,EAAC,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,UAAkB;IACtE,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,KAAK,IAAI,UAAU,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACxG,IAAI,OAAO,IAAI,UAAU,GAAG,CAAC,GAAG,QAAQ,EAAE,CAAC;QACzC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAC,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;IACxG,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC;QACnD,OAAO,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAC,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACpH,CAAC;IAED,OAAO;QACL,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC;QACvB,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAC;QACrC,GAAG,KAAK,CAAC,OAAO,GAAG,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC;QAChD,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAC;QACnC,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAC;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TourI18n } from '../types/tour-i18n.type.js';
|
|
2
|
+
export type ResolvedI18n = 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.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
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
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
40
|
-
|
|
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
|
-
"
|
|
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.
|
|
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
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@types/
|
|
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
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"react
|
|
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
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
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
|
+
}
|