@pagopa/io-app-design-system 4.2.1 → 4.3.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 (248) hide show
  1. package/lib/commonjs/components/alert/Alert.js +10 -31
  2. package/lib/commonjs/components/alert/Alert.js.map +1 -1
  3. package/lib/commonjs/components/alert/AlertEdgeToEdge.js +9 -29
  4. package/lib/commonjs/components/alert/AlertEdgeToEdge.js.map +1 -1
  5. package/lib/commonjs/components/banner/Banner.js +10 -34
  6. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  7. package/lib/commonjs/components/buttons/ButtonLink.js +20 -53
  8. package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
  9. package/lib/commonjs/components/buttons/ButtonOutline.js +24 -44
  10. package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
  11. package/lib/commonjs/components/buttons/ButtonSolid.js +14 -39
  12. package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
  13. package/lib/commonjs/components/buttons/IconButton.js +13 -32
  14. package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
  15. package/lib/commonjs/components/buttons/IconButtonContained.js +19 -42
  16. package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -1
  17. package/lib/commonjs/components/buttons/IconButtonSolid.js +15 -31
  18. package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
  19. package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +34 -10
  20. package/lib/commonjs/components/layout/index.js +0 -11
  21. package/lib/commonjs/components/layout/index.js.map +1 -1
  22. package/lib/commonjs/components/listitems/ListItemAction.js +14 -40
  23. package/lib/commonjs/components/listitems/ListItemAction.js.map +1 -1
  24. package/lib/commonjs/components/listitems/ListItemCheckbox.js +13 -41
  25. package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -1
  26. package/lib/commonjs/components/listitems/ListItemHeader.js +2 -2
  27. package/lib/commonjs/components/listitems/ListItemHeader.js.map +1 -1
  28. package/lib/commonjs/components/listitems/ListItemInfoCopy.js +15 -43
  29. package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
  30. package/lib/commonjs/components/listitems/ListItemNav.js +17 -48
  31. package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
  32. package/lib/commonjs/components/listitems/ListItemNavAlert.js +19 -50
  33. package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
  34. package/lib/commonjs/components/listitems/ListItemRadio.js +20 -50
  35. package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -1
  36. package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js +2 -2
  37. package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js.map +1 -1
  38. package/lib/commonjs/components/listitems/ListItemTransaction.js +2 -2
  39. package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
  40. package/lib/commonjs/components/listitems/{PressableListItemsBase.js → PressableListItemBase.js} +7 -7
  41. package/lib/commonjs/components/listitems/PressableListItemBase.js.map +1 -0
  42. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +13 -7
  43. package/lib/commonjs/components/listitems/__test__/listitem.test.js +3 -3
  44. package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
  45. package/lib/commonjs/components/listitems/index.js +11 -11
  46. package/lib/commonjs/components/listitems/index.js.map +1 -1
  47. package/lib/commonjs/components/modules/PressableModuleBase.js +17 -11
  48. package/lib/commonjs/components/modules/PressableModuleBase.js.map +1 -1
  49. package/lib/commonjs/components/modules/index.js +8 -8
  50. package/lib/commonjs/components/modules/index.js.map +1 -1
  51. package/lib/commonjs/components/numberpad/NumberButton.js +12 -28
  52. package/lib/commonjs/components/numberpad/NumberButton.js.map +1 -1
  53. package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +20 -0
  54. package/lib/commonjs/components/otpInput/OTPInput.js +2 -1
  55. package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
  56. package/lib/commonjs/components/tabs/TabItem.js +15 -21
  57. package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
  58. package/lib/commonjs/core/IOAnimations.js +6 -12
  59. package/lib/commonjs/core/IOAnimations.js.map +1 -1
  60. package/lib/commonjs/hooks/index.js +28 -0
  61. package/lib/commonjs/hooks/index.js.map +1 -0
  62. package/lib/commonjs/hooks/useListItemAnimation.js +40 -0
  63. package/lib/commonjs/hooks/useListItemAnimation.js.map +1 -0
  64. package/lib/commonjs/hooks/useScaleAnimation.js +36 -0
  65. package/lib/commonjs/hooks/useScaleAnimation.js.map +1 -0
  66. package/lib/commonjs/index.js +11 -0
  67. package/lib/commonjs/index.js.map +1 -1
  68. package/lib/commonjs/utils/hooks/index.js +28 -0
  69. package/lib/commonjs/utils/hooks/index.js.map +1 -0
  70. package/lib/commonjs/utils/hooks/useSpringPressProgressValue.js +5 -7
  71. package/lib/commonjs/utils/hooks/useSpringPressProgressValue.js.map +1 -1
  72. package/lib/module/components/alert/Alert.js +10 -32
  73. package/lib/module/components/alert/Alert.js.map +1 -1
  74. package/lib/module/components/alert/AlertEdgeToEdge.js +10 -31
  75. package/lib/module/components/alert/AlertEdgeToEdge.js.map +1 -1
  76. package/lib/module/components/banner/Banner.js +10 -33
  77. package/lib/module/components/banner/Banner.js.map +1 -1
  78. package/lib/module/components/buttons/ButtonLink.js +23 -56
  79. package/lib/module/components/buttons/ButtonLink.js.map +1 -1
  80. package/lib/module/components/buttons/ButtonOutline.js +27 -47
  81. package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
  82. package/lib/module/components/buttons/ButtonSolid.js +17 -42
  83. package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
  84. package/lib/module/components/buttons/IconButton.js +16 -35
  85. package/lib/module/components/buttons/IconButton.js.map +1 -1
  86. package/lib/module/components/buttons/IconButtonContained.js +21 -45
  87. package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
  88. package/lib/module/components/buttons/IconButtonSolid.js +17 -34
  89. package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
  90. package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +34 -10
  91. package/lib/module/components/layout/index.js +0 -1
  92. package/lib/module/components/layout/index.js.map +1 -1
  93. package/lib/module/components/listitems/ListItemAction.js +15 -42
  94. package/lib/module/components/listitems/ListItemAction.js.map +1 -1
  95. package/lib/module/components/listitems/ListItemCheckbox.js +15 -43
  96. package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -1
  97. package/lib/module/components/listitems/ListItemHeader.js +2 -2
  98. package/lib/module/components/listitems/ListItemHeader.js.map +1 -1
  99. package/lib/module/components/listitems/ListItemInfoCopy.js +16 -45
  100. package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
  101. package/lib/module/components/listitems/ListItemNav.js +17 -47
  102. package/lib/module/components/listitems/ListItemNav.js.map +1 -1
  103. package/lib/module/components/listitems/ListItemNavAlert.js +19 -49
  104. package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
  105. package/lib/module/components/listitems/ListItemRadio.js +22 -52
  106. package/lib/module/components/listitems/ListItemRadio.js.map +1 -1
  107. package/lib/module/components/listitems/ListItemRadioWithAmount.js +1 -1
  108. package/lib/module/components/listitems/ListItemRadioWithAmount.js.map +1 -1
  109. package/lib/module/components/listitems/ListItemTransaction.js +1 -1
  110. package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
  111. package/lib/module/components/listitems/{PressableListItemsBase.js → PressableListItemBase.js} +7 -7
  112. package/lib/module/components/listitems/PressableListItemBase.js.map +1 -0
  113. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +13 -7
  114. package/lib/module/components/listitems/__test__/listitem.test.js +1 -1
  115. package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
  116. package/lib/module/components/listitems/index.js +1 -1
  117. package/lib/module/components/listitems/index.js.map +1 -1
  118. package/lib/module/components/modules/PressableModuleBase.js +17 -10
  119. package/lib/module/components/modules/PressableModuleBase.js.map +1 -1
  120. package/lib/module/components/modules/index.js +1 -1
  121. package/lib/module/components/modules/index.js.map +1 -1
  122. package/lib/module/components/numberpad/NumberButton.js +14 -30
  123. package/lib/module/components/numberpad/NumberButton.js.map +1 -1
  124. package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +20 -0
  125. package/lib/module/components/otpInput/OTPInput.js +2 -1
  126. package/lib/module/components/otpInput/OTPInput.js.map +1 -1
  127. package/lib/module/components/tabs/TabItem.js +18 -24
  128. package/lib/module/components/tabs/TabItem.js.map +1 -1
  129. package/lib/module/core/IOAnimations.js +4 -10
  130. package/lib/module/core/IOAnimations.js.map +1 -1
  131. package/lib/module/hooks/index.js +3 -0
  132. package/lib/module/hooks/index.js.map +1 -0
  133. package/lib/module/hooks/useListItemAnimation.js +33 -0
  134. package/lib/module/hooks/useListItemAnimation.js.map +1 -0
  135. package/lib/module/hooks/useScaleAnimation.js +29 -0
  136. package/lib/module/hooks/useScaleAnimation.js.map +1 -0
  137. package/lib/module/index.js +1 -0
  138. package/lib/module/index.js.map +1 -1
  139. package/lib/module/utils/hooks/index.js +3 -0
  140. package/lib/module/utils/hooks/index.js.map +1 -0
  141. package/lib/module/utils/hooks/useSpringPressProgressValue.js +5 -5
  142. package/lib/module/utils/hooks/useSpringPressProgressValue.js.map +1 -1
  143. package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
  144. package/lib/typescript/components/alert/AlertEdgeToEdge.d.ts.map +1 -1
  145. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  146. package/lib/typescript/components/buttons/ButtonLink.d.ts.map +1 -1
  147. package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
  148. package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
  149. package/lib/typescript/components/buttons/IconButton.d.ts.map +1 -1
  150. package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -1
  151. package/lib/typescript/components/buttons/IconButtonSolid.d.ts.map +1 -1
  152. package/lib/typescript/components/layout/index.d.ts +0 -1
  153. package/lib/typescript/components/layout/index.d.ts.map +1 -1
  154. package/lib/typescript/components/listitems/ListItemAction.d.ts.map +1 -1
  155. package/lib/typescript/components/listitems/ListItemCheckbox.d.ts.map +1 -1
  156. package/lib/typescript/components/listitems/ListItemInfoCopy.d.ts.map +1 -1
  157. package/lib/typescript/components/listitems/ListItemNav.d.ts.map +1 -1
  158. package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
  159. package/lib/typescript/components/listitems/ListItemRadio.d.ts.map +1 -1
  160. package/lib/typescript/components/listitems/ListItemRadioWithAmount.d.ts.map +1 -1
  161. package/lib/typescript/components/listitems/ListItemTransaction.d.ts +1 -1
  162. package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
  163. package/lib/typescript/components/listitems/{PressableListItemsBase.d.ts → PressableListItemBase.d.ts} +3 -2
  164. package/lib/typescript/components/listitems/PressableListItemBase.d.ts.map +1 -0
  165. package/lib/typescript/components/listitems/index.d.ts +1 -1
  166. package/lib/typescript/components/listitems/index.d.ts.map +1 -1
  167. package/lib/typescript/components/modules/PressableModuleBase.d.ts.map +1 -1
  168. package/lib/typescript/components/modules/index.d.ts +1 -1
  169. package/lib/typescript/components/modules/index.d.ts.map +1 -1
  170. package/lib/typescript/components/numberpad/NumberButton.d.ts.map +1 -1
  171. package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
  172. package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
  173. package/lib/typescript/core/IOAnimations.d.ts +6 -10
  174. package/lib/typescript/core/IOAnimations.d.ts.map +1 -1
  175. package/lib/typescript/hooks/index.d.ts +3 -0
  176. package/lib/typescript/hooks/index.d.ts.map +1 -0
  177. package/lib/typescript/hooks/useListItemAnimation.d.ts +10 -0
  178. package/lib/typescript/hooks/useListItemAnimation.d.ts.map +1 -0
  179. package/lib/typescript/hooks/useScaleAnimation.d.ts +10 -0
  180. package/lib/typescript/hooks/useScaleAnimation.d.ts.map +1 -0
  181. package/lib/typescript/index.d.ts +1 -0
  182. package/lib/typescript/index.d.ts.map +1 -1
  183. package/lib/typescript/utils/hooks/index.d.ts +3 -0
  184. package/lib/typescript/utils/hooks/index.d.ts.map +1 -0
  185. package/lib/typescript/utils/hooks/useSpringPressProgressValue.d.ts +7 -8
  186. package/lib/typescript/utils/hooks/useSpringPressProgressValue.d.ts.map +1 -1
  187. package/package.json +1 -1
  188. package/src/components/alert/Alert.tsx +7 -46
  189. package/src/components/alert/AlertEdgeToEdge.tsx +6 -46
  190. package/src/components/banner/Banner.tsx +6 -52
  191. package/src/components/buttons/ButtonLink.tsx +32 -89
  192. package/src/components/buttons/ButtonOutline.tsx +26 -60
  193. package/src/components/buttons/ButtonSolid.tsx +11 -58
  194. package/src/components/buttons/IconButton.tsx +10 -47
  195. package/src/components/buttons/IconButtonContained.tsx +21 -57
  196. package/src/components/buttons/IconButtonSolid.tsx +15 -46
  197. package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +34 -10
  198. package/src/components/layout/index.tsx +0 -1
  199. package/src/components/listitems/ListItemAction.tsx +10 -66
  200. package/src/components/listitems/ListItemCheckbox.tsx +10 -68
  201. package/src/components/listitems/ListItemHeader.tsx +2 -2
  202. package/src/components/listitems/ListItemInfoCopy.tsx +11 -71
  203. package/src/components/listitems/ListItemNav.tsx +13 -74
  204. package/src/components/listitems/ListItemNavAlert.tsx +18 -92
  205. package/src/components/listitems/ListItemRadio.tsx +14 -75
  206. package/src/components/listitems/ListItemRadioWithAmount.tsx +2 -1
  207. package/src/components/listitems/ListItemTransaction.tsx +1 -1
  208. package/src/components/listitems/{PressableListItemsBase.tsx → PressableListItemBase.tsx} +7 -6
  209. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +13 -7
  210. package/src/components/listitems/__test__/listitem.test.tsx +1 -1
  211. package/src/components/listitems/index.tsx +1 -1
  212. package/src/components/modules/PressableModuleBase.tsx +15 -8
  213. package/src/components/modules/index.tsx +1 -1
  214. package/src/components/numberpad/NumberButton.tsx +12 -43
  215. package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +20 -0
  216. package/src/components/otpInput/OTPInput.tsx +1 -0
  217. package/src/components/tabs/TabItem.tsx +15 -29
  218. package/src/core/IOAnimations.ts +8 -10
  219. package/src/hooks/index.tsx +2 -0
  220. package/src/hooks/useListItemAnimation.tsx +59 -0
  221. package/src/hooks/useScaleAnimation.tsx +41 -0
  222. package/src/index.tsx +1 -0
  223. package/src/utils/hooks/index.tsx +2 -0
  224. package/src/utils/hooks/useSpringPressProgressValue.ts +14 -8
  225. package/lib/commonjs/components/layout/FooterWithButtons.js +0 -84
  226. package/lib/commonjs/components/layout/FooterWithButtons.js.map +0 -1
  227. package/lib/commonjs/components/listitems/PressableListItemsBase.js.map +0 -1
  228. package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.js +0 -56
  229. package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.js.map +0 -1
  230. package/lib/commonjs/components/modules/hooks/useModuleSpringAnimation.js +0 -41
  231. package/lib/commonjs/components/modules/hooks/useModuleSpringAnimation.js.map +0 -1
  232. package/lib/module/components/layout/FooterWithButtons.js +0 -75
  233. package/lib/module/components/layout/FooterWithButtons.js.map +0 -1
  234. package/lib/module/components/listitems/PressableListItemsBase.js.map +0 -1
  235. package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js +0 -47
  236. package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js.map +0 -1
  237. package/lib/module/components/modules/hooks/useModuleSpringAnimation.js +0 -34
  238. package/lib/module/components/modules/hooks/useModuleSpringAnimation.js.map +0 -1
  239. package/lib/typescript/components/layout/FooterWithButtons.d.ts +0 -16
  240. package/lib/typescript/components/layout/FooterWithButtons.d.ts.map +0 -1
  241. package/lib/typescript/components/listitems/PressableListItemsBase.d.ts.map +0 -1
  242. package/lib/typescript/components/listitems/hooks/useListItemSpringAnimation.d.ts +0 -13
  243. package/lib/typescript/components/listitems/hooks/useListItemSpringAnimation.d.ts.map +0 -1
  244. package/lib/typescript/components/modules/hooks/useModuleSpringAnimation.d.ts +0 -10
  245. package/lib/typescript/components/modules/hooks/useModuleSpringAnimation.d.ts.map +0 -1
  246. package/src/components/layout/FooterWithButtons.tsx +0 -90
  247. package/src/components/listitems/hooks/useListItemSpringAnimation.ts +0 -72
  248. package/src/components/modules/hooks/useModuleSpringAnimation.ts +0 -49
@@ -1,4 +1,4 @@
1
- import React, { ComponentProps, ReactNode, useCallback } from "react";
1
+ import React, { ComponentProps, ReactNode } from "react";
2
2
  import {
3
3
  GestureResponderEvent,
4
4
  Image,
@@ -6,27 +6,16 @@ import {
6
6
  StyleSheet,
7
7
  View
8
8
  } from "react-native";
9
- import Animated, {
10
- Extrapolate,
11
- interpolate,
12
- interpolateColor,
13
- useAnimatedStyle,
14
- useDerivedValue,
15
- useSharedValue,
16
- withSpring
17
- } from "react-native-reanimated";
9
+ import Animated from "react-native-reanimated";
18
10
  import {
19
11
  IOColors,
20
12
  IOListItemStyles,
21
13
  IOListItemVisualParams,
22
- IOScaleValues,
23
14
  IOSelectionListItemVisualParams,
24
- IOSpringValues,
25
15
  IOStyles,
26
- hexToRgba,
27
- useIOExperimentalDesign,
28
16
  useIOTheme
29
17
  } from "../../core";
18
+ import { useListItemAnimation } from "../../hooks";
30
19
  import { WithTestID } from "../../utils/types";
31
20
  import { Avatar } from "../avatar";
32
21
  import { Badge } from "../badge";
@@ -114,8 +103,8 @@ export const ListItemNav = ({
114
103
  loading,
115
104
  numberOfLines
116
105
  }: ListItemNav) => {
117
- const isPressed = useSharedValue(0);
118
- const { isExperimental } = useIOExperimentalDesign();
106
+ const { onPressIn, onPressOut, scaleAnimatedStyle, backgroundAnimatedStyle } =
107
+ useListItemAnimation();
119
108
  const theme = useIOTheme();
120
109
 
121
110
  const withMargin = (GraphicalAsset: ReactNode) => (
@@ -172,56 +161,7 @@ export const ListItemNav = ({
172
161
  </>
173
162
  );
174
163
 
175
- const mapBackgroundStates: Record<string, string> = {
176
- default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
177
- pressed: IOColors[theme["listItem-pressed"]]
178
- };
179
-
180
- const navIconColor = isExperimental
181
- ? theme["interactiveElem-default"]
182
- : "blue";
183
-
184
- // Scaling transformation applied when the button is pressed
185
- const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
186
-
187
- const progressPressed = useDerivedValue(() =>
188
- withSpring(isPressed.value, IOSpringValues.button)
189
- );
190
-
191
- // Interpolate animation values from `isPressed` values
192
- const animatedScaleStyle = useAnimatedStyle(() => {
193
- const scale = interpolate(
194
- progressPressed.value,
195
- [0, 1],
196
- [1, animationScaleValue],
197
- Extrapolate.CLAMP
198
- );
199
-
200
- return {
201
- transform: [{ scale }]
202
- };
203
- });
204
-
205
- const animatedBackgroundStyle = useAnimatedStyle(() => {
206
- const backgroundColor = interpolateColor(
207
- progressPressed.value,
208
- [0, 1],
209
- [mapBackgroundStates.default, mapBackgroundStates.pressed]
210
- );
211
-
212
- return {
213
- backgroundColor
214
- };
215
- });
216
-
217
- const handlePressIn = useCallback(() => {
218
- // eslint-disable-next-line functional/immutable-data
219
- isPressed.value = 1;
220
- }, [isPressed]);
221
- const handlePressOut = useCallback(() => {
222
- // eslint-disable-next-line functional/immutable-data
223
- isPressed.value = 0;
224
- }, [isPressed]);
164
+ const interactiveColor = theme["interactiveElem-default"];
225
165
 
226
166
  const handleOnPress = (event: GestureResponderEvent) => {
227
167
  if (!loading) {
@@ -229,13 +169,12 @@ export const ListItemNav = ({
229
169
  }
230
170
  };
231
171
 
232
- const primaryColor: IOColors = isExperimental ? "blueIO-500" : "blue";
233
-
234
172
  return (
235
173
  <Pressable
236
174
  onPress={handleOnPress}
237
- onPressIn={handlePressIn}
238
- onPressOut={handlePressOut}
175
+ onPressIn={onPressIn}
176
+ onPressOut={onPressOut}
177
+ onTouchEnd={onPressOut}
239
178
  accessible={true}
240
179
  accessibilityState={{ busy: loading }}
241
180
  accessibilityLabel={accessibilityLabel}
@@ -244,10 +183,10 @@ export const ListItemNav = ({
244
183
  testID={testID}
245
184
  >
246
185
  <Animated.View
247
- style={[IOListItemStyles.listItem, animatedBackgroundStyle]}
186
+ style={[IOListItemStyles.listItem, backgroundAnimatedStyle]}
248
187
  >
249
188
  <Animated.View
250
- style={[IOListItemStyles.listItemInner, animatedScaleStyle]}
189
+ style={[IOListItemStyles.listItemInner, scaleAnimatedStyle]}
251
190
  >
252
191
  {/* Possibile graphical assets
253
192
  - Icon
@@ -273,11 +212,11 @@ export const ListItemNav = ({
273
212
  {avatar && withMargin(<Avatar size="small" {...avatar} />)}
274
213
 
275
214
  <View style={IOStyles.flex}>{listItemNavContent}</View>
276
- {loading && <LoadingSpinner color={primaryColor} />}
215
+ {loading && <LoadingSpinner color={interactiveColor} />}
277
216
  {!loading && !hideChevron && (
278
217
  <Icon
279
218
  name="chevronRightListItem"
280
- color={navIconColor}
219
+ color={interactiveColor}
281
220
  size={IOListItemVisualParams.chevronSize}
282
221
  />
283
222
  )}
@@ -1,25 +1,13 @@
1
- import React, { ComponentProps, useCallback, useMemo } from "react";
1
+ import React, { ComponentProps } from "react";
2
2
  import { GestureResponderEvent, Pressable, View } from "react-native";
3
- import Animated, {
4
- Extrapolate,
5
- interpolate,
6
- interpolateColor,
7
- useAnimatedStyle,
8
- useDerivedValue,
9
- useSharedValue,
10
- withSpring
11
- } from "react-native-reanimated";
3
+ import Animated from "react-native-reanimated";
12
4
  import {
13
- IOColors,
14
5
  IOListItemStyles,
15
6
  IOListItemVisualParams,
16
- IOScaleValues,
17
- IOSpringValues,
18
7
  IOStyles,
19
- hexToRgba,
20
- useIOExperimentalDesign,
21
8
  useIOTheme
22
9
  } from "../../core";
10
+ import { useListItemAnimation } from "../../hooks";
23
11
  import { WithTestID } from "../../utils/types";
24
12
  import { Icon } from "../icons";
25
13
  import { H6, BodySmall } from "../typography";
@@ -44,31 +32,17 @@ export const ListItemNavAlert = ({
44
32
  accessibilityHint,
45
33
  testID
46
34
  }: ListItemNavAlert) => {
47
- const isPressed: Animated.SharedValue<number> = useSharedValue(0);
48
- const { isExperimental } = useIOExperimentalDesign();
49
-
50
- const componentValueToAccessibility = useMemo(
51
- () => (typeof value === "string" ? value : ""),
52
- [value]
53
- );
35
+ const theme = useIOTheme();
36
+ const { onPressIn, onPressOut, scaleAnimatedStyle, backgroundAnimatedStyle } =
37
+ useListItemAnimation();
54
38
 
55
- const componentDescriptionToAccessibility = useMemo(
56
- () => (typeof description === "string" ? description : ""),
57
- [description]
58
- );
39
+ const componentValueToAccessibility = typeof value === "string" ? value : "";
40
+ const componentDescriptionToAccessibility =
41
+ typeof description === "string" ? description : "";
59
42
 
60
- const listItemAccessibilityLabel = useMemo(
61
- () =>
62
- accessibilityLabel
63
- ? accessibilityLabel
64
- : `${componentValueToAccessibility}; ${componentDescriptionToAccessibility}`,
65
- [
66
- componentDescriptionToAccessibility,
67
- componentValueToAccessibility,
68
- accessibilityLabel
69
- ]
70
- );
71
- const theme = useIOTheme();
43
+ const listItemAccessibilityLabel =
44
+ accessibilityLabel ??
45
+ `${componentValueToAccessibility}; ${componentDescriptionToAccessibility}`;
72
46
 
73
47
  // TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
74
48
  const listItemNavAlertContent = (
@@ -93,60 +67,12 @@ export const ListItemNavAlert = ({
93
67
  </>
94
68
  );
95
69
 
96
- const iconColor = isExperimental ? theme["interactiveElem-default"] : "blue";
97
-
98
- const mapBackgroundStates: Record<string, string> = {
99
- default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
100
- pressed: IOColors[theme["listItem-pressed"]]
101
- };
102
-
103
- // Scaling transformation applied when the button is pressed
104
- const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
105
-
106
- const progressPressed = useDerivedValue(() =>
107
- withSpring(isPressed.value, IOSpringValues.button)
108
- );
109
-
110
- // Interpolate animation values from `isPressed` values
111
- const animatedScaleStyle = useAnimatedStyle(() => {
112
- const scale = interpolate(
113
- progressPressed.value,
114
- [0, 1],
115
- [1, animationScaleValue],
116
- Extrapolate.CLAMP
117
- );
118
-
119
- return {
120
- transform: [{ scale }]
121
- };
122
- });
123
-
124
- const animatedBackgroundStyle = useAnimatedStyle(() => {
125
- const backgroundColor = interpolateColor(
126
- progressPressed.value,
127
- [0, 1],
128
- [mapBackgroundStates.default, mapBackgroundStates.pressed]
129
- );
130
-
131
- return {
132
- backgroundColor
133
- };
134
- });
135
-
136
- const handlePressIn = useCallback(() => {
137
- // eslint-disable-next-line functional/immutable-data
138
- isPressed.value = 1;
139
- }, [isPressed]);
140
- const handlePressOut = useCallback(() => {
141
- // eslint-disable-next-line functional/immutable-data
142
- isPressed.value = 0;
143
- }, [isPressed]);
144
-
145
70
  return (
146
71
  <Pressable
147
72
  onPress={onPress}
148
- onPressIn={handlePressIn}
149
- onPressOut={handlePressOut}
73
+ onPressIn={onPressIn}
74
+ onPressOut={onPressOut}
75
+ onTouchEnd={onPressOut}
150
76
  accessible={true}
151
77
  accessibilityLabel={listItemAccessibilityLabel}
152
78
  accessibilityHint={accessibilityHint}
@@ -154,12 +80,12 @@ export const ListItemNavAlert = ({
154
80
  testID={testID}
155
81
  >
156
82
  <Animated.View
157
- style={[IOListItemStyles.listItem, animatedBackgroundStyle]}
83
+ style={[IOListItemStyles.listItem, backgroundAnimatedStyle]}
158
84
  importantForAccessibility="no-hide-descendants"
159
85
  accessibilityElementsHidden
160
86
  >
161
87
  <Animated.View
162
- style={[IOListItemStyles.listItemInner, animatedScaleStyle]}
88
+ style={[IOListItemStyles.listItemInner, scaleAnimatedStyle]}
163
89
  >
164
90
  {!withoutIcon && (
165
91
  <View style={{ marginRight: IOListItemVisualParams.iconMargin }}>
@@ -174,7 +100,7 @@ export const ListItemNavAlert = ({
174
100
  <View style={{ marginLeft: IOListItemVisualParams.iconMargin }}>
175
101
  <Icon
176
102
  name="chevronRightListItem"
177
- color={iconColor}
103
+ color={theme["interactiveElem-default"]}
178
104
  size={IOListItemVisualParams.chevronSize}
179
105
  />
180
106
  </View>
@@ -1,33 +1,23 @@
1
1
  import * as React from "react";
2
- import { useCallback, useState } from "react";
2
+ import { useState } from "react";
3
3
  import { Image, Pressable, StyleSheet, View } from "react-native";
4
4
  import ReactNativeHapticFeedback from "react-native-haptic-feedback";
5
- import Animated, {
6
- Extrapolate,
7
- interpolate,
8
- interpolateColor,
9
- useAnimatedStyle,
10
- useDerivedValue,
11
- useSharedValue,
12
- withSpring
13
- } from "react-native-reanimated";
5
+ import Animated from "react-native-reanimated";
14
6
  import Placeholder from "rn-placeholder";
15
7
  import {
16
- IOColors,
17
- IOScaleValues,
18
8
  IOSelectionListItemStyles,
19
9
  IOSelectionListItemVisualParams,
20
- IOSpringValues,
21
10
  IOStyles,
22
- hexToRgba,
23
11
  useIOTheme
24
12
  } from "../../core";
13
+ import { useListItemAnimation } from "../../hooks";
25
14
  import { WithTestID } from "../../utils/types";
26
15
  import { IOIcons, Icon } from "../icons";
27
16
  import { IOLogoPaymentType, LogoPayment } from "../logos";
28
17
  import { AnimatedRadio } from "../radio/AnimatedRadio";
29
18
  import { HSpacer, VSpacer } from "../spacer";
30
19
  import { H6, BodySmall } from "../typography";
20
+ import { VStack } from "../stack";
31
21
 
32
22
  type ListItemRadioGraphicProps =
33
23
  | { icon?: never; paymentLogo: IOLogoPaymentType; uri?: never }
@@ -91,58 +81,10 @@ export const ListItemRadio = ({
91
81
  testID
92
82
  }: ListItemRadioProps) => {
93
83
  const [toggleValue, setToggleValue] = useState(selected ?? false);
94
- // Animations
95
- const isPressed: Animated.SharedValue<number> = useSharedValue(0);
96
- // Scaling transformation applied when the button is pressed
97
- const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
98
-
99
- const progressPressed = useDerivedValue(() =>
100
- withSpring(isPressed.value, IOSpringValues.button)
101
- );
102
-
103
- // Theme
84
+ const { onPressIn, onPressOut, scaleAnimatedStyle, backgroundAnimatedStyle } =
85
+ useListItemAnimation();
104
86
  const theme = useIOTheme();
105
87
 
106
- const mapBackgroundStates: Record<string, string> = {
107
- default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
108
- pressed: IOColors[theme["listItem-pressed"]]
109
- };
110
-
111
- // Interpolate animation values from `isPressed` values
112
- const animatedScaleStyle = useAnimatedStyle(() => {
113
- const scale = interpolate(
114
- progressPressed.value,
115
- [0, 1],
116
- [1, animationScaleValue],
117
- Extrapolate.CLAMP
118
- );
119
-
120
- return {
121
- transform: [{ scale }]
122
- };
123
- });
124
-
125
- const handlePressIn = useCallback(() => {
126
- // eslint-disable-next-line functional/immutable-data
127
- isPressed.value = 1;
128
- }, [isPressed]);
129
- const handlePressOut = useCallback(() => {
130
- // eslint-disable-next-line functional/immutable-data
131
- isPressed.value = 0;
132
- }, [isPressed]);
133
-
134
- const animatedBackgroundStyle = useAnimatedStyle(() => {
135
- const backgroundColor = interpolateColor(
136
- progressPressed.value,
137
- [0, 1],
138
- [mapBackgroundStates.default, mapBackgroundStates.pressed]
139
- );
140
-
141
- return {
142
- backgroundColor
143
- };
144
- });
145
-
146
88
  const toggleRadioItem = () => {
147
89
  ReactNativeHapticFeedback.trigger("impactLight");
148
90
  setToggleValue(!toggleValue);
@@ -154,14 +96,11 @@ export const ListItemRadio = ({
154
96
  const disabledStyle = { opacity: disabled ? DISABLED_OPACITY : 1 };
155
97
 
156
98
  const SkeletonDescriptionLines = () => (
157
- <>
158
- <VSpacer size={8} />
99
+ <VStack space={8}>
159
100
  <Placeholder.Box animate="fade" radius={8} width={"100%"} height={8} />
160
- <VSpacer size={8} />
161
101
  <Placeholder.Box animate="fade" radius={8} width={"100%"} height={8} />
162
- <VSpacer size={8} />
163
102
  <Placeholder.Box animate="fade" radius={8} width={"100%"} height={8} />
164
- </>
103
+ </VStack>
165
104
  );
166
105
 
167
106
  const SkeletonIcon = () => (
@@ -180,7 +119,7 @@ export const ListItemRadio = ({
180
119
  );
181
120
 
182
121
  const SkeletonComponent = () => (
183
- <View style={IOSelectionListItemStyles.listItem}>
122
+ <View style={[IOSelectionListItemStyles.listItem, { rowGap: 8 }]}>
184
123
  <View style={IOSelectionListItemStyles.listItemInner}>
185
124
  <View
186
125
  style={[
@@ -220,23 +159,23 @@ export const ListItemRadio = ({
220
159
  accessibilityLabel={accessibilityLabel}
221
160
  accessibilityHint={accessibilityHint}
222
161
  onPress={toggleRadioItem}
223
- onPressIn={handlePressIn}
224
- onPressOut={handlePressOut}
225
- onTouchEnd={handlePressOut}
162
+ onPressIn={onPressIn}
163
+ onPressOut={onPressOut}
164
+ onTouchEnd={onPressOut}
226
165
  testID={testID}
227
166
  disabled={disabled}
228
167
  >
229
168
  <Animated.View
230
169
  style={[
231
170
  IOSelectionListItemStyles.listItem,
232
- animatedBackgroundStyle,
171
+ backgroundAnimatedStyle,
233
172
  disabledStyle
234
173
  ]}
235
174
  // This is required to avoid opacity
236
175
  // inheritance on Android
237
176
  needsOffscreenAlphaCompositing={true}
238
177
  >
239
- <Animated.View style={animatedScaleStyle}>
178
+ <Animated.View style={scaleAnimatedStyle}>
240
179
  <View style={IOSelectionListItemStyles.listItemInner}>
241
180
  <View style={[IOStyles.row, { flexShrink: 1 }]}>
242
181
  {startImage && (
@@ -6,7 +6,7 @@ import { Icon } from "../icons";
6
6
  import { AnimatedRadio } from "../radio/AnimatedRadio";
7
7
  import { HStack } from "../stack";
8
8
  import { BodySmall, H6 } from "../typography";
9
- import { PressableListItemBase } from "./PressableListItemsBase";
9
+ import { PressableListItemBase } from "./PressableListItemBase";
10
10
 
11
11
  export type ListItemRadioWithAmountProps = {
12
12
  onValueChange?: (newValue: boolean) => void;
@@ -34,6 +34,7 @@ export const ListItemRadioWithAmount = ({
34
34
  formattedAmountString
35
35
  }: ListItemRadioWithAmountProps) => {
36
36
  const [toggleValue, setToggleValue] = React.useState(selected ?? false);
37
+
37
38
  const pressHandler = () => {
38
39
  RNReactNativeHapticFeedback.trigger("impactLight");
39
40
  setToggleValue(val => !val);
@@ -25,7 +25,7 @@ import { H6, BodySmall } from "../typography";
25
25
  import {
26
26
  PressableBaseProps,
27
27
  PressableListItemBase
28
- } from "./PressableListItemsBase";
28
+ } from "./PressableListItemBase";
29
29
 
30
30
  export type ListItemTransactionBadge = {
31
31
  text: string;
@@ -1,9 +1,10 @@
1
1
  import * as React from "react";
2
+ import { PropsWithChildren } from "react";
2
3
  import { Pressable } from "react-native";
3
4
  import Animated from "react-native-reanimated";
4
5
  import { IOListItemStyles, IOListItemVisualParams } from "../../core";
5
6
  import { WithTestID } from "../../utils/types";
6
- import { useListItemSpringAnimation } from "./hooks/useListItemSpringAnimation";
7
+ import { useListItemAnimation } from "../../hooks";
7
8
 
8
9
  export type PressableBaseProps = WithTestID<
9
10
  Pick<
@@ -22,9 +23,9 @@ export const PressableListItemBase = ({
22
23
  children,
23
24
  accessibilityRole,
24
25
  ...props
25
- }: React.PropsWithChildren<PressableBaseProps>) => {
26
- const { onPressIn, onPressOut, animatedScaleStyle, animatedBackgroundStyle } =
27
- useListItemSpringAnimation();
26
+ }: PropsWithChildren<PressableBaseProps>) => {
27
+ const { onPressIn, onPressOut, scaleAnimatedStyle, backgroundAnimatedStyle } =
28
+ useListItemAnimation();
28
29
  return (
29
30
  <Pressable
30
31
  onPress={onPress}
@@ -37,13 +38,13 @@ export const PressableListItemBase = ({
37
38
  {...props}
38
39
  >
39
40
  <Animated.View
40
- style={[IOListItemStyles.listItem, animatedBackgroundStyle]}
41
+ style={[IOListItemStyles.listItem, backgroundAnimatedStyle]}
41
42
  >
42
43
  <Animated.View
43
44
  style={[
44
45
  IOListItemStyles.listItemInner,
45
46
  { columnGap: IOListItemVisualParams.iconMargin },
46
- animatedScaleStyle
47
+ scaleAnimatedStyle
47
48
  ]}
48
49
  >
49
50
  {children}
@@ -312,6 +312,7 @@ exports[`Test List Item Components - Experimental Enabled ListItemInfoCopy Snap
312
312
  onResponderTerminate={[Function]}
313
313
  onResponderTerminationRequest={[Function]}
314
314
  onStartShouldSetResponder={[Function]}
315
+ onTouchEnd={[Function]}
315
316
  >
316
317
  <View
317
318
  accessibilityElementsHidden={true}
@@ -502,6 +503,7 @@ exports[`Test List Item Components - Experimental Enabled ListItemNav Snapshot
502
503
  onResponderTerminate={[Function]}
503
504
  onResponderTerminationRequest={[Function]}
504
505
  onStartShouldSetResponder={[Function]}
506
+ onTouchEnd={[Function]}
505
507
  >
506
508
  <View
507
509
  style={
@@ -661,6 +663,7 @@ exports[`Test List Item Components - Experimental Enabled ListItemNavAlert Snap
661
663
  onResponderTerminate={[Function]}
662
664
  onResponderTerminationRequest={[Function]}
663
665
  onStartShouldSetResponder={[Function]}
666
+ onTouchEnd={[Function]}
664
667
  >
665
668
  <View
666
669
  accessibilityElementsHidden={true}
@@ -1978,6 +1981,7 @@ exports[`Test List Item Components ListItemInfoCopy Snapshot 1`] = `
1978
1981
  onResponderTerminate={[Function]}
1979
1982
  onResponderTerminationRequest={[Function]}
1980
1983
  onStartShouldSetResponder={[Function]}
1984
+ onTouchEnd={[Function]}
1981
1985
  >
1982
1986
  <View
1983
1987
  accessibilityElementsHidden={true}
@@ -2049,7 +2053,7 @@ exports[`Test List Item Components ListItemInfoCopy Snapshot 1`] = `
2049
2053
  [
2050
2054
  {},
2051
2055
  {
2052
- "color": "#0073E6",
2056
+ "color": "#0B3EE3",
2053
2057
  "fontFamily": "Titillium Sans Pro",
2054
2058
  "fontSize": 17,
2055
2059
  "fontStyle": "normal",
@@ -2089,7 +2093,7 @@ exports[`Test List Item Components ListItemInfoCopy Snapshot 1`] = `
2089
2093
  "borderWidth": 0,
2090
2094
  },
2091
2095
  {
2092
- "color": "#0073E6",
2096
+ "color": "#0B3EE3",
2093
2097
  },
2094
2098
  {
2095
2099
  "flex": 0,
@@ -2098,7 +2102,7 @@ exports[`Test List Item Components ListItemInfoCopy Snapshot 1`] = `
2098
2102
  },
2099
2103
  ]
2100
2104
  }
2101
- tintColor="#0073E6"
2105
+ tintColor="#0B3EE3"
2102
2106
  vbHeight={24}
2103
2107
  vbWidth={24}
2104
2108
  width={24}
@@ -2168,6 +2172,7 @@ exports[`Test List Item Components ListItemNav Snapshot 1`] = `
2168
2172
  onResponderTerminate={[Function]}
2169
2173
  onResponderTerminationRequest={[Function]}
2170
2174
  onStartShouldSetResponder={[Function]}
2175
+ onTouchEnd={[Function]}
2171
2176
  >
2172
2177
  <View
2173
2178
  style={
@@ -2249,7 +2254,7 @@ exports[`Test List Item Components ListItemNav Snapshot 1`] = `
2249
2254
  "borderWidth": 0,
2250
2255
  },
2251
2256
  {
2252
- "color": "#0073E6",
2257
+ "color": "#0B3EE3",
2253
2258
  },
2254
2259
  {
2255
2260
  "flex": 0,
@@ -2258,7 +2263,7 @@ exports[`Test List Item Components ListItemNav Snapshot 1`] = `
2258
2263
  },
2259
2264
  ]
2260
2265
  }
2261
- tintColor="#0073E6"
2266
+ tintColor="#0B3EE3"
2262
2267
  vbHeight={24}
2263
2268
  vbWidth={24}
2264
2269
  width={24}
@@ -2327,6 +2332,7 @@ exports[`Test List Item Components ListItemNavAlert Snapshot 1`] = `
2327
2332
  onResponderTerminate={[Function]}
2328
2333
  onResponderTerminationRequest={[Function]}
2329
2334
  onStartShouldSetResponder={[Function]}
2335
+ onTouchEnd={[Function]}
2330
2336
  >
2331
2337
  <View
2332
2338
  accessibilityElementsHidden={true}
@@ -2485,7 +2491,7 @@ exports[`Test List Item Components ListItemNavAlert Snapshot 1`] = `
2485
2491
  "borderWidth": 0,
2486
2492
  },
2487
2493
  {
2488
- "color": "#0073E6",
2494
+ "color": "#0B3EE3",
2489
2495
  },
2490
2496
  {
2491
2497
  "flex": 0,
@@ -2494,7 +2500,7 @@ exports[`Test List Item Components ListItemNavAlert Snapshot 1`] = `
2494
2500
  },
2495
2501
  ]
2496
2502
  }
2497
- tintColor="#0073E6"
2503
+ tintColor="#0B3EE3"
2498
2504
  vbHeight={24}
2499
2505
  vbWidth={24}
2500
2506
  width={24}
@@ -10,7 +10,7 @@ import ListItemNav from "../ListItemNav";
10
10
  import ListItemNavAlert from "../ListItemNavAlert";
11
11
  import { ListItemRadioWithAmount } from "../ListItemRadioWithAmount";
12
12
  import { ListItemTransaction } from "../ListItemTransaction";
13
- import { PressableListItemBase } from "../PressableListItemsBase";
13
+ import { PressableListItemBase } from "../PressableListItemBase";
14
14
 
15
15
  const onButtonPress = () => {
16
16
  Alert.alert("Alert", "Action triggered");
@@ -5,9 +5,9 @@ export * from "./ListItemInfoCopy";
5
5
  export * from "./ListItemNav";
6
6
  export * from "./ListItemNavAlert";
7
7
  export * from "./ListItemTransaction";
8
- export * from "./PressableListItemsBase";
9
8
  export * from "./ListItemSwitch";
10
9
  export * from "./ListItemCheckbox";
11
10
  export * from "./ListItemRadio";
12
11
  export * from "./ListItemRadioWithAmount";
13
12
  export * from "./ListItemAmount";
13
+ export * from "./PressableListItemBase";