@codeleap/mobile 3.13.2 → 3.13.5
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/package.json
CHANGED
|
@@ -36,10 +36,21 @@ export type TouchableProps =
|
|
|
36
36
|
rippleDisabled?: boolean
|
|
37
37
|
children?: React.ReactNode
|
|
38
38
|
style?: StyleProp<ViewStyle>
|
|
39
|
+
analyticsEnabled?: boolean
|
|
40
|
+
analyticsName?: string
|
|
41
|
+
analyticsData?: Record<string, any>
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export * from './styles'
|
|
42
|
-
|
|
45
|
+
const defaultProps: Partial<TouchableProps> = {
|
|
46
|
+
variants: [],
|
|
47
|
+
debounce: 500,
|
|
48
|
+
noFeedback: false,
|
|
49
|
+
rippleDisabled: false,
|
|
50
|
+
analyticsEnabled: false,
|
|
51
|
+
analyticsName: null,
|
|
52
|
+
analyticsData: {},
|
|
53
|
+
}
|
|
43
54
|
const _Touchable = forwardRef<
|
|
44
55
|
RNView,
|
|
45
56
|
TouchableProps
|
|
@@ -51,14 +62,20 @@ const _Touchable = forwardRef<
|
|
|
51
62
|
style,
|
|
52
63
|
debugName,
|
|
53
64
|
debugComponent,
|
|
54
|
-
debounce
|
|
65
|
+
debounce,
|
|
55
66
|
leadingDebounce,
|
|
56
|
-
noFeedback
|
|
67
|
+
noFeedback,
|
|
57
68
|
styles,
|
|
58
69
|
setPressed,
|
|
59
|
-
rippleDisabled
|
|
70
|
+
rippleDisabled,
|
|
71
|
+
analyticsEnabled,
|
|
72
|
+
analyticsName,
|
|
73
|
+
analyticsData = {},
|
|
60
74
|
...props
|
|
61
|
-
} =
|
|
75
|
+
} = {
|
|
76
|
+
...defaultProps,
|
|
77
|
+
...touchableProps,
|
|
78
|
+
}
|
|
62
79
|
|
|
63
80
|
const pressed = React.useRef(!!leadingDebounce)
|
|
64
81
|
|
|
@@ -92,6 +109,12 @@ const _Touchable = forwardRef<
|
|
|
92
109
|
debugName || variants,
|
|
93
110
|
'User interaction',
|
|
94
111
|
)
|
|
112
|
+
if (analyticsEnabled) {
|
|
113
|
+
const name = analyticsName || debugName
|
|
114
|
+
if (!!name?.trim?.()) {
|
|
115
|
+
logger.analytics?.interaction(name, analyticsData)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
95
118
|
onPress && onPress()
|
|
96
119
|
}
|
|
97
120
|
if (TypeGuards.isNumber(debounce)) {
|
|
@@ -240,4 +263,8 @@ const _Touchable = forwardRef<
|
|
|
240
263
|
)
|
|
241
264
|
})
|
|
242
265
|
|
|
243
|
-
export const Touchable = _Touchable as ((props: TouchableProps) => JSX.Element)
|
|
266
|
+
export const Touchable = _Touchable as ((props: TouchableProps) => JSX.Element) & {
|
|
267
|
+
defaultProps: Partial<TouchableProps>
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
Touchable.defaultProps = defaultProps
|