react-native-lumen 1.0.1 → 1.1.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/README.md +770 -231
- package/lib/module/components/TourOverlay.js +45 -45
- package/lib/module/components/TourOverlay.js.map +1 -1
- package/lib/module/components/TourProvider.js +345 -80
- package/lib/module/components/TourProvider.js.map +1 -1
- package/lib/module/components/TourTooltip.js +113 -73
- package/lib/module/components/TourTooltip.js.map +1 -1
- package/lib/module/components/TourZone.js +229 -125
- package/lib/module/components/TourZone.js.map +1 -1
- package/lib/module/constants/defaults.js +43 -0
- package/lib/module/constants/defaults.js.map +1 -1
- package/lib/module/context/TourContext.js +5 -0
- package/lib/module/context/TourContext.js.map +1 -0
- package/lib/module/hooks/useTour.js +1 -1
- package/lib/module/hooks/useTour.js.map +1 -1
- package/lib/module/hooks/useTourScrollView.js +74 -0
- package/lib/module/hooks/useTourScrollView.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/storage.js +188 -0
- package/lib/module/utils/storage.js.map +1 -0
- package/lib/typescript/src/components/TourOverlay.d.ts.map +1 -1
- package/lib/typescript/src/components/TourProvider.d.ts +21 -4
- package/lib/typescript/src/components/TourProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/TourTooltip.d.ts.map +1 -1
- package/lib/typescript/src/components/TourZone.d.ts +19 -1
- package/lib/typescript/src/components/TourZone.d.ts.map +1 -1
- package/lib/typescript/src/constants/defaults.d.ts +10 -0
- package/lib/typescript/src/constants/defaults.d.ts.map +1 -1
- package/lib/typescript/src/context/TourContext.d.ts +3 -0
- package/lib/typescript/src/context/TourContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useTourScrollView.d.ts +76 -0
- package/lib/typescript/src/hooks/useTourScrollView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +316 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/storage.d.ts +51 -0
- package/lib/typescript/src/utils/storage.d.ts.map +1 -0
- package/package.json +169 -171
- package/src/components/TourOverlay.tsx +0 -153
- package/src/components/TourProvider.tsx +0 -361
- package/src/components/TourTooltip.tsx +0 -256
- package/src/components/TourZone.tsx +0 -371
- package/src/constants/animations.ts +0 -71
- package/src/constants/defaults.ts +0 -15
- package/src/hooks/useTour.ts +0 -10
- package/src/index.tsx +0 -8
- package/src/types/index.ts +0 -142
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { memo } from 'react';
|
|
3
|
+
import { memo, useMemo } from 'react';
|
|
4
4
|
import { StyleSheet, Dimensions } from 'react-native';
|
|
5
5
|
import Svg, { Path } from 'react-native-svg';
|
|
6
6
|
import Animated, { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
7
7
|
import { useTour } from "../hooks/useTour.js";
|
|
8
|
+
import { DEFAULT_ZONE_STYLE } from "../constants/defaults.js";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const {
|
|
10
11
|
width: SCREEN_WIDTH,
|
|
@@ -13,15 +14,11 @@ const {
|
|
|
13
14
|
const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
14
15
|
const AnimatedView = Animated.View;
|
|
15
16
|
|
|
16
|
-
//
|
|
17
|
-
// x,y are top-left coordinates
|
|
17
|
+
// SVG rounded-rect path with a cutout hole (fillRule="evenodd")
|
|
18
18
|
const createRoundedRectPath = (x, y, w, h, r) => {
|
|
19
19
|
'worklet';
|
|
20
20
|
|
|
21
|
-
// Ensure radius doesn't exceed dimensions
|
|
22
21
|
const radius = Math.min(r, w / 2, h / 2);
|
|
23
|
-
|
|
24
|
-
// Standard SVG Path command for rounded rect
|
|
25
22
|
return `
|
|
26
23
|
M ${x + radius}, ${y}
|
|
27
24
|
H ${x + w - radius}
|
|
@@ -43,15 +40,21 @@ export const TourOverlay = /*#__PURE__*/memo(() => {
|
|
|
43
40
|
targetHeight,
|
|
44
41
|
targetRadius,
|
|
45
42
|
opacity,
|
|
43
|
+
zoneBorderWidth,
|
|
46
44
|
config,
|
|
47
45
|
currentStep,
|
|
48
|
-
steps
|
|
46
|
+
steps,
|
|
47
|
+
currentZoneStyle
|
|
49
48
|
} = useTour();
|
|
49
|
+
const zoneStyle = useMemo(() => {
|
|
50
|
+
return {
|
|
51
|
+
...DEFAULT_ZONE_STYLE,
|
|
52
|
+
...config?.zoneStyle,
|
|
53
|
+
...currentZoneStyle
|
|
54
|
+
};
|
|
55
|
+
}, [config?.zoneStyle, currentZoneStyle]);
|
|
50
56
|
|
|
51
|
-
//
|
|
52
|
-
// Outer rectangle covers the whole screen
|
|
53
|
-
// Inner shape is the "hole"
|
|
54
|
-
// fillRule="evenodd" makes the intersection transparent
|
|
57
|
+
// Backdrop SVG: full-screen rect minus the highlight cutout
|
|
55
58
|
const animatedProps = useAnimatedProps(() => {
|
|
56
59
|
const holePath = createRoundedRectPath(targetX.value, targetY.value, targetWidth.value, targetHeight.value, targetRadius.value);
|
|
57
60
|
const path = `
|
|
@@ -70,33 +73,10 @@ export const TourOverlay = /*#__PURE__*/memo(() => {
|
|
|
70
73
|
const step = currentStep ? steps[currentStep] : null;
|
|
71
74
|
const isClickable = step?.clickable ?? false;
|
|
72
75
|
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
// - Actually, if we want to block OUTSIDE but allow INSIDE:
|
|
77
|
-
// - SVG path normally blocks where it draws (the dark part).
|
|
78
|
-
// - The 'hole' is empty, so touches pass through the hole to the app?
|
|
79
|
-
// - YES, with fillRule="evenodd", the hole effectively has no fill.
|
|
80
|
-
// - So if SVG is 'auto', touching the dark mask is blocked (if we consume touch).
|
|
81
|
-
// - Touching the hole goes through to the app (GOOD for clickable).
|
|
82
|
-
// - IF we want to BLOCK the hole (clickable=false):
|
|
83
|
-
// - We need a transparent view covering the hole that consumes touches.
|
|
84
|
-
//
|
|
85
|
-
// 2. preventInteraction = false (default):
|
|
86
|
-
// - Overlay shouldn't block anything?
|
|
87
|
-
// - pointerEvents='none' on the whole container.
|
|
88
|
-
|
|
89
|
-
const shouldBlockOutside = config?.preventInteraction ?? false;
|
|
90
|
-
|
|
91
|
-
// If we don't want to block outside, we just let everything pass.
|
|
92
|
-
// But wait, if we let everything pass, we can't implement 'clickable=false' strictness?
|
|
93
|
-
// Usually preventInteraction=false means "just show the highlighter, let user do whatever".
|
|
94
|
-
|
|
76
|
+
// When preventInteraction is true, the SVG blocks touches outside the hole.
|
|
77
|
+
// A transparent view covers the hole to block touches inside it when clickable=false.
|
|
78
|
+
const shouldBlockOutside = step?.preventInteraction ?? config?.preventInteraction ?? false;
|
|
95
79
|
const containerPointerEvents = shouldBlockOutside && currentStep ? 'box-none' : 'none';
|
|
96
|
-
|
|
97
|
-
// If blocking outside, the SVG (which is absolute fill) needs to catch touches on the dark part.
|
|
98
|
-
|
|
99
|
-
// Blocker style for the hole (only if NOT clickable)
|
|
100
80
|
const blockerStyle = useAnimatedStyle(() => {
|
|
101
81
|
return {
|
|
102
82
|
position: 'absolute',
|
|
@@ -104,10 +84,31 @@ export const TourOverlay = /*#__PURE__*/memo(() => {
|
|
|
104
84
|
top: targetY.value,
|
|
105
85
|
width: targetWidth.value,
|
|
106
86
|
height: targetHeight.value,
|
|
107
|
-
// We can match radius too if needed, but rect is fine for touch area usually
|
|
108
87
|
borderRadius: targetRadius.value
|
|
109
88
|
};
|
|
110
89
|
});
|
|
90
|
+
|
|
91
|
+
// Border/glow ring tracks the highlight and fades with the backdrop
|
|
92
|
+
const zoneBorderStyle = useAnimatedStyle(() => {
|
|
93
|
+
const isGlowEnabled = config?.enableGlow === true;
|
|
94
|
+
const borderW = zoneBorderWidth?.value ?? zoneStyle.borderWidth;
|
|
95
|
+
return {
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
left: targetX.value,
|
|
98
|
+
top: targetY.value,
|
|
99
|
+
width: targetWidth.value,
|
|
100
|
+
height: targetHeight.value,
|
|
101
|
+
borderRadius: targetRadius.value,
|
|
102
|
+
borderWidth: borderW,
|
|
103
|
+
borderColor: zoneStyle.borderColor,
|
|
104
|
+
backgroundColor: 'transparent',
|
|
105
|
+
opacity: opacity.value,
|
|
106
|
+
...(isGlowEnabled && {
|
|
107
|
+
boxShadow: `${zoneStyle.glowOffsetX}px ${zoneStyle.glowOffsetY}px ${zoneStyle.glowRadius}px ${zoneStyle.glowSpread}px ${zoneStyle.glowColor}`
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const showBorder = config?.enableGlow === true || zoneStyle.borderWidth > 0;
|
|
111
112
|
return /*#__PURE__*/_jsxs(AnimatedView, {
|
|
112
113
|
pointerEvents: containerPointerEvents,
|
|
113
114
|
style: StyleSheet.absoluteFill,
|
|
@@ -117,17 +118,16 @@ export const TourOverlay = /*#__PURE__*/memo(() => {
|
|
|
117
118
|
style: StyleSheet.absoluteFill,
|
|
118
119
|
children: /*#__PURE__*/_jsx(AnimatedPath, {
|
|
119
120
|
animatedProps: animatedProps,
|
|
120
|
-
fill: "black"
|
|
121
|
-
,
|
|
121
|
+
fill: "black",
|
|
122
122
|
fillRule: "evenodd",
|
|
123
|
-
onPress: () => {
|
|
124
|
-
// Consume touch on the backdrop?
|
|
125
|
-
}
|
|
123
|
+
onPress: () => {}
|
|
126
124
|
})
|
|
127
125
|
}), shouldBlockOutside && !isClickable && currentStep && /*#__PURE__*/_jsx(AnimatedView, {
|
|
128
126
|
style: blockerStyle,
|
|
129
|
-
pointerEvents: "auto"
|
|
130
|
-
|
|
127
|
+
pointerEvents: "auto"
|
|
128
|
+
}), showBorder && currentStep && /*#__PURE__*/_jsx(AnimatedView, {
|
|
129
|
+
style: zoneBorderStyle,
|
|
130
|
+
pointerEvents: "none"
|
|
131
131
|
})]
|
|
132
132
|
});
|
|
133
133
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memo","StyleSheet","Dimensions","Svg","Path","Animated","useAnimatedProps","useAnimatedStyle","useTour","jsx","_jsx","jsxs","_jsxs","width","SCREEN_WIDTH","height","SCREEN_HEIGHT","get","AnimatedPath","createAnimatedComponent","AnimatedView","View","createRoundedRectPath","x","y","w","h","r","radius","Math","min","TourOverlay","targetX","targetY","targetWidth","targetHeight","targetRadius","opacity","config","currentStep","steps","animatedProps","holePath","value","path","d","fillOpacity","step","isClickable","clickable","shouldBlockOutside","preventInteraction","containerPointerEvents","blockerStyle","position","left","top","borderRadius","pointerEvents","style","absoluteFill","children","fill","fillRule","onPress"],"sourceRoot":"..\\..\\..\\src","sources":["components/TourOverlay.tsx"],"mappings":";;AAAA,SAASA,IAAI,
|
|
1
|
+
{"version":3,"names":["memo","useMemo","StyleSheet","Dimensions","Svg","Path","Animated","useAnimatedProps","useAnimatedStyle","useTour","DEFAULT_ZONE_STYLE","jsx","_jsx","jsxs","_jsxs","width","SCREEN_WIDTH","height","SCREEN_HEIGHT","get","AnimatedPath","createAnimatedComponent","AnimatedView","View","createRoundedRectPath","x","y","w","h","r","radius","Math","min","TourOverlay","targetX","targetY","targetWidth","targetHeight","targetRadius","opacity","zoneBorderWidth","config","currentStep","steps","currentZoneStyle","zoneStyle","animatedProps","holePath","value","path","d","fillOpacity","step","isClickable","clickable","shouldBlockOutside","preventInteraction","containerPointerEvents","blockerStyle","position","left","top","borderRadius","zoneBorderStyle","isGlowEnabled","enableGlow","borderW","borderWidth","borderColor","backgroundColor","boxShadow","glowOffsetX","glowOffsetY","glowRadius","glowSpread","glowColor","showBorder","pointerEvents","style","absoluteFill","children","fill","fillRule","onPress"],"sourceRoot":"..\\..\\..\\src","sources":["components/TourOverlay.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAsBC,OAAO,QAAQ,OAAO;AACzD,SAASC,UAAU,EAAEC,UAAU,QAAQ,cAAc;AACrD,OAAOC,GAAG,IAAI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