@pagopa/io-app-design-system 1.13.1 → 1.15.0

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 (154) hide show
  1. package/lib/commonjs/components/avatar/Avatar.js +22 -6
  2. package/lib/commonjs/components/avatar/Avatar.js.map +1 -1
  3. package/lib/commonjs/components/avatar/__test__/__snapshots__/avatar.test.tsx.snap +17 -4
  4. package/lib/commonjs/components/avatar/__test__/avatar.test.js +3 -8
  5. package/lib/commonjs/components/avatar/__test__/avatar.test.js.map +1 -1
  6. package/lib/commonjs/components/avatar/index.js +0 -11
  7. package/lib/commonjs/components/avatar/index.js.map +1 -1
  8. package/lib/commonjs/components/badge/Badge.js +46 -5
  9. package/lib/commonjs/components/badge/Badge.js.map +1 -1
  10. package/lib/commonjs/components/banner/Banner.js +9 -8
  11. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  12. package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
  13. package/lib/commonjs/components/icons/svg/IconInstitution.js +3 -3
  14. package/lib/commonjs/components/icons/svg/IconInstitution.js.map +1 -1
  15. package/lib/commonjs/components/icons/svg/originals/IconInstitution.svg +2 -7
  16. package/lib/commonjs/components/listitems/ListItemNav.js +9 -0
  17. package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
  18. package/lib/commonjs/components/listitems/ListItemSwitch.js +28 -10
  19. package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
  20. package/lib/commonjs/components/listitems/ListItemTransaction.js +1 -1
  21. package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
  22. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +1 -1
  23. package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js +3 -3
  24. package/lib/commonjs/components/modules/ModuleIDP.js +6 -49
  25. package/lib/commonjs/components/modules/ModuleIDP.js.map +1 -1
  26. package/lib/commonjs/components/modules/ModulePaymentNotice.js +15 -51
  27. package/lib/commonjs/components/modules/ModulePaymentNotice.js.map +1 -1
  28. package/lib/commonjs/components/modules/PressableModuleBase.js +44 -0
  29. package/lib/commonjs/components/modules/PressableModuleBase.js.map +1 -0
  30. package/lib/commonjs/components/modules/hooks/useModuleSpringAnimation.js +41 -0
  31. package/lib/commonjs/components/modules/hooks/useModuleSpringAnimation.js.map +1 -0
  32. package/lib/commonjs/components/modules/index.js +11 -0
  33. package/lib/commonjs/components/modules/index.js.map +1 -1
  34. package/lib/commonjs/components/switch/NativeSwitch.js +5 -3
  35. package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
  36. package/lib/commonjs/components/textInput/TextInputBase.js +6 -5
  37. package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
  38. package/lib/commonjs/core/IOColors.js +1 -0
  39. package/lib/commonjs/core/IOColors.js.map +1 -1
  40. package/lib/commonjs/core/IOStyles.js +18 -2
  41. package/lib/commonjs/core/IOStyles.js.map +1 -1
  42. package/lib/commonjs/stories/ModuleIDP.stories.js +45 -0
  43. package/lib/commonjs/stories/ModuleIDP.stories.js.map +1 -0
  44. package/lib/commonjs/utils/textInput/index.js +2 -1
  45. package/lib/commonjs/utils/textInput/index.js.map +1 -1
  46. package/lib/module/components/avatar/Avatar.js +24 -8
  47. package/lib/module/components/avatar/Avatar.js.map +1 -1
  48. package/lib/module/components/avatar/__test__/__snapshots__/avatar.test.tsx.snap +17 -4
  49. package/lib/module/components/avatar/__test__/avatar.test.js +3 -8
  50. package/lib/module/components/avatar/__test__/avatar.test.js.map +1 -1
  51. package/lib/module/components/avatar/index.js +0 -1
  52. package/lib/module/components/avatar/index.js.map +1 -1
  53. package/lib/module/components/badge/Badge.js +44 -4
  54. package/lib/module/components/badge/Badge.js.map +1 -1
  55. package/lib/module/components/banner/Banner.js +9 -8
  56. package/lib/module/components/banner/Banner.js.map +1 -1
  57. package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
  58. package/lib/module/components/icons/svg/IconInstitution.js +3 -3
  59. package/lib/module/components/icons/svg/IconInstitution.js.map +1 -1
  60. package/lib/module/components/icons/svg/originals/IconInstitution.svg +2 -7
  61. package/lib/module/components/listitems/ListItemNav.js +9 -0
  62. package/lib/module/components/listitems/ListItemNav.js.map +1 -1
  63. package/lib/module/components/listitems/ListItemSwitch.js +28 -11
  64. package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
  65. package/lib/module/components/listitems/ListItemTransaction.js +1 -1
  66. package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
  67. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +1 -1
  68. package/lib/module/components/loadingSpinner/LoadingSpinner.js +3 -3
  69. package/lib/module/components/modules/ModuleIDP.js +8 -52
  70. package/lib/module/components/modules/ModuleIDP.js.map +1 -1
  71. package/lib/module/components/modules/ModulePaymentNotice.js +17 -54
  72. package/lib/module/components/modules/ModulePaymentNotice.js.map +1 -1
  73. package/lib/module/components/modules/PressableModuleBase.js +34 -0
  74. package/lib/module/components/modules/PressableModuleBase.js.map +1 -0
  75. package/lib/module/components/modules/hooks/useModuleSpringAnimation.js +34 -0
  76. package/lib/module/components/modules/hooks/useModuleSpringAnimation.js.map +1 -0
  77. package/lib/module/components/modules/index.js +1 -0
  78. package/lib/module/components/modules/index.js.map +1 -1
  79. package/lib/module/components/switch/NativeSwitch.js +5 -3
  80. package/lib/module/components/switch/NativeSwitch.js.map +1 -1
  81. package/lib/module/components/textInput/TextInputBase.js +6 -5
  82. package/lib/module/components/textInput/TextInputBase.js.map +1 -1
  83. package/lib/module/core/IOColors.js +1 -0
  84. package/lib/module/core/IOColors.js.map +1 -1
  85. package/lib/module/core/IOStyles.js +15 -0
  86. package/lib/module/core/IOStyles.js.map +1 -1
  87. package/lib/module/stories/ModuleIDP.stories.js +37 -0
  88. package/lib/module/stories/ModuleIDP.stories.js.map +1 -0
  89. package/lib/module/utils/textInput/index.js +2 -1
  90. package/lib/module/utils/textInput/index.js.map +1 -1
  91. package/lib/typescript/components/avatar/Avatar.d.ts +2 -2
  92. package/lib/typescript/components/avatar/Avatar.d.ts.map +1 -1
  93. package/lib/typescript/components/avatar/index.d.ts +0 -1
  94. package/lib/typescript/components/avatar/index.d.ts.map +1 -1
  95. package/lib/typescript/components/badge/Badge.d.ts +2 -1
  96. package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
  97. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  98. package/lib/typescript/components/listitems/ListItemNav.d.ts +14 -3
  99. package/lib/typescript/components/listitems/ListItemNav.d.ts.map +1 -1
  100. package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -1
  101. package/lib/typescript/components/modules/ModuleIDP.d.ts +5 -7
  102. package/lib/typescript/components/modules/ModuleIDP.d.ts.map +1 -1
  103. package/lib/typescript/components/modules/ModulePaymentNotice.d.ts +1 -1
  104. package/lib/typescript/components/modules/ModulePaymentNotice.d.ts.map +1 -1
  105. package/lib/typescript/components/modules/PressableModuleBase.d.ts +10 -0
  106. package/lib/typescript/components/modules/PressableModuleBase.d.ts.map +1 -0
  107. package/lib/typescript/components/modules/hooks/useModuleSpringAnimation.d.ts +10 -0
  108. package/lib/typescript/components/modules/hooks/useModuleSpringAnimation.d.ts.map +1 -0
  109. package/lib/typescript/components/modules/index.d.ts +1 -0
  110. package/lib/typescript/components/modules/index.d.ts.map +1 -1
  111. package/lib/typescript/components/switch/NativeSwitch.d.ts +2 -2
  112. package/lib/typescript/components/switch/NativeSwitch.d.ts.map +1 -1
  113. package/lib/typescript/components/textInput/TextInputBase.d.ts +5 -5
  114. package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
  115. package/lib/typescript/core/IOColors.d.ts +1 -0
  116. package/lib/typescript/core/IOColors.d.ts.map +1 -1
  117. package/lib/typescript/core/IOStyles.d.ts +13 -0
  118. package/lib/typescript/core/IOStyles.d.ts.map +1 -1
  119. package/lib/typescript/stories/ModuleIDP.stories.d.ts +24 -0
  120. package/lib/typescript/stories/ModuleIDP.stories.d.ts.map +1 -0
  121. package/lib/typescript/utils/textInput/index.d.ts.map +1 -1
  122. package/package.json +2 -2
  123. package/src/components/avatar/Avatar.tsx +63 -24
  124. package/src/components/avatar/__test__/__snapshots__/avatar.test.tsx.snap +17 -4
  125. package/src/components/avatar/__test__/avatar.test.tsx +1 -8
  126. package/src/components/avatar/index.tsx +0 -1
  127. package/src/components/badge/Badge.tsx +63 -7
  128. package/src/components/banner/Banner.tsx +9 -6
  129. package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
  130. package/src/components/icons/svg/IconInstitution.tsx +2 -2
  131. package/src/components/icons/svg/originals/IconInstitution.svg +2 -7
  132. package/src/components/listitems/ListItemNav.tsx +19 -5
  133. package/src/components/listitems/ListItemSwitch.tsx +37 -12
  134. package/src/components/listitems/ListItemTransaction.tsx +1 -1
  135. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +1 -1
  136. package/src/components/loadingSpinner/LoadingSpinner.tsx +3 -3
  137. package/src/components/modules/ModuleIDP.tsx +16 -86
  138. package/src/components/modules/ModulePaymentNotice.tsx +14 -77
  139. package/src/components/modules/PressableModuleBase.tsx +45 -0
  140. package/src/components/modules/hooks/useModuleSpringAnimation.ts +49 -0
  141. package/src/components/modules/index.tsx +1 -0
  142. package/src/components/switch/NativeSwitch.tsx +10 -2
  143. package/src/components/textInput/TextInputBase.tsx +16 -9
  144. package/src/core/IOColors.ts +2 -0
  145. package/src/core/IOStyles.ts +22 -1
  146. package/src/stories/ModuleIDP.stories.tsx +44 -0
  147. package/src/utils/textInput/index.ts +2 -1
  148. package/lib/commonjs/components/avatar/MultiImage.js +0 -47
  149. package/lib/commonjs/components/avatar/MultiImage.js.map +0 -1
  150. package/lib/module/components/avatar/MultiImage.js +0 -39
  151. package/lib/module/components/avatar/MultiImage.js.map +0 -1
  152. package/lib/typescript/components/avatar/MultiImage.d.ts +0 -22
  153. package/lib/typescript/components/avatar/MultiImage.d.ts.map +0 -1
  154. package/src/components/avatar/MultiImage.tsx +0 -57
@@ -197,7 +197,14 @@ export const Banner = ({
197
197
 
198
198
  const renderMainBlock = () => (
199
199
  <>
200
- <View style={[IOStyles.flex, IOStyles.selfCenter]}>
200
+ <View
201
+ style={[IOStyles.flex, IOStyles.selfCenter]}
202
+ accessible={true}
203
+ // A11y related props
204
+ accessibilityLabel={accessibilityLabel}
205
+ accessibilityHint={accessibilityHint}
206
+ accessibilityRole={action !== undefined ? "button" : undefined}
207
+ >
201
208
  {title && (
202
209
  <>
203
210
  {/* Once we get 'gap' property, we can get rid of
@@ -250,11 +257,7 @@ export const Banner = ({
250
257
  onPress={onPress}
251
258
  onPressIn={onPressIn}
252
259
  onPressOut={onPressOut}
253
- // A11y related props
254
- accessible={true}
255
- accessibilityLabel={accessibilityLabel}
256
- accessibilityHint={accessibilityHint}
257
- accessibilityRole={"button"}
260
+ accessible={false}
258
261
  >
259
262
  <Animated.View
260
263
  style={[
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports[`Test Banner Components Banner Snapshot 1`] = `
4
4
  <View
5
- accessibilityRole="button"
6
5
  accessibilityState={
7
6
  {
8
7
  "busy": undefined,
@@ -20,7 +19,7 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
20
19
  "text": undefined,
21
20
  }
22
21
  }
23
- accessible={true}
22
+ accessible={false}
24
23
  collapsable={false}
25
24
  focusable={true}
26
25
  onBlur={[Function]}
@@ -58,6 +57,8 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
58
57
  }
59
58
  >
60
59
  <View
60
+ accessibilityRole="button"
61
+ accessible={true}
61
62
  style={
62
63
  [
63
64
  {
@@ -5,10 +5,10 @@ import { SVGIconProps } from "../Icon";
5
5
  const IconInstitution = ({ size, style, ...props }: SVGIconProps) => (
6
6
  <Svg width={size} height={size} viewBox="0 0 24 24" style={style} {...props}>
7
7
  <Path
8
+ fill="currentColor"
8
9
  fillRule="evenodd"
10
+ d="M10.402 2.685a2.997 2.997 0 0 1 3.219 0l7.918 5.04a.999.999 0 0 1 .463.842l-.023 1.423H1.999l.022-1.423c0-.342.174-.66.463-.843l7.918-5.039ZM14.693.999A4.995 4.995 0 0 0 9.33 1L1.41 6.04A2.997 2.997 0 0 0 .024 8.566L0 10.989a1 1 0 0 0 .999 1h1v9.99h-1a.999.999 0 1 0 0 1.998H22.978a1 1 0 0 0 0-1.998h-.999v-9.99h1a1 1 0 0 0 .998-1L24 8.567a2.997 2.997 0 0 0-1.388-2.529L14.693 1ZM5.994 21.98H3.996v-9.99h1.998v9.99Zm9.99-9.99v9.99H7.993v-9.99h7.993Zm3.997 9.99h-1.998v-9.99h1.998v9.99ZM13.51 6.471a1.499 1.499 0 1 1-2.997 0 1.499 1.499 0 0 1 2.997 0Z"
9
11
  clipRule="evenodd"
10
- d="M10.4023 2.68517c.9818-.62476 2.2365-.62476 3.2182 0l7.9187 5.03918a.999.999 0 0 1 .4627.84286l-.0229 1.42337H1.99809l.02288-1.42337a.99903.99903 0 0 1 .46269-.84286l7.91864-5.03918Zm4.291-1.68572c-1.6363-1.04126-3.7274-1.04126-5.36368 0L1.41093 6.03864C.54641 6.58878.02288 7.54248.02288 8.56721L0 10.9896c0 .5518.44729.9991.99905.9991h.99904v9.9905H.99905c-.55176 0-.99905.4473-.99905.999 0 .5518.44729.9991.99905.9991H22.9781c.5517 0 .999-.4473.999-.9991 0-.5517-.4473-.999-.999-.999h-.9991v-9.9905h.9991c.5517 0 .999-.4473.999-.9991L24 8.56721c0-1.02473-.5235-1.97843-1.388-2.52858L14.6933.99945ZM5.99428 21.9792H3.99619v-9.9905h1.99809v9.9905Zm9.99042-9.9905v9.9905H7.99237v-9.9905h7.99233Zm3.9962 9.9905h-1.9981v-9.9905h1.9981v9.9905ZM13.51 6.47125c0 .82764-.6709 1.49857-1.4986 1.49857-.8276 0-1.4985-.67093-1.4985-1.49857 0-.82764.6709-1.49858 1.4985-1.49858.8277 0 1.4986.67094 1.4986 1.49858Z"
11
- fill="currentColor"
12
12
  />
13
13
  </Svg>
14
14
  );
@@ -1,8 +1,3 @@
1
- <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
- <path
3
- fill-rule="evenodd"
4
- clip-rule="evenodd"
5
- d="M10.4023 2.68517c.9818-.62476 2.2365-.62476 3.2182 0l7.9187 5.03918a.999.999 0 0 1 .4627.84286l-.0229 1.42337H1.99809l.02288-1.42337a.99903.99903 0 0 1 .46269-.84286l7.91864-5.03918Zm4.291-1.68572c-1.6363-1.04126-3.7274-1.04126-5.36368 0L1.41093 6.03864C.54641 6.58878.02288 7.54248.02288 8.56721L0 10.9896c0 .5518.44729.9991.99905.9991h.99904v9.9905H.99905c-.55176 0-.99905.4473-.99905.999 0 .5518.44729.9991.99905.9991H22.9781c.5517 0 .999-.4473.999-.9991 0-.5517-.4473-.999-.999-.999h-.9991v-9.9905h.9991c.5517 0 .999-.4473.999-.9991L24 8.56721c0-1.02473-.5235-1.97843-1.388-2.52858L14.6933.99945ZM5.99428 21.9792H3.99619v-9.9905h1.99809v9.9905Zm9.99042-9.9905v9.9905H7.99237v-9.9905h7.99233Zm3.9962 9.9905h-1.9981v-9.9905h1.9981v9.9905ZM13.51 6.47125c0 .82764-.6709 1.49857-1.4986 1.49857-.8276 0-1.4985-.67093-1.4985-1.49857 0-.82764.6709-1.49858 1.4985-1.49858.8277 0 1.4986.67094 1.4986 1.49858Z"
6
- fill="#0E0F13"
7
- />
1
+ <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M10.4023 2.68497C11.3841 2.06021 12.6388 2.06021 13.6205 2.68497L21.5392 7.72414C21.8274 7.90752 22.0019 8.22542 22.0019 8.56699L21.979 9.99037H1.99809L2.02097 8.56699C2.02097 8.22542 2.19548 7.90752 2.48366 7.72414L10.4023 2.68497ZM14.6933 0.999255C13.057 -0.0420089 10.9659 -0.0420063 9.32962 0.999256L1.41093 6.03842C0.54641 6.58857 0.0228809 7.54227 0.0228809 8.56699L0 10.9894C0 11.5412 0.447288 11.9885 0.999047 11.9885H1.99809V21.979H0.999047C0.447288 21.979 0 22.4262 0 22.978C0 23.5298 0.447288 23.9771 0.999047 23.9771H2.99714H6.99333H16.9838H20.98H22.9781C23.5298 23.9771 23.9771 23.5298 23.9771 22.978C23.9771 22.4262 23.5298 21.979 22.9781 21.979H21.979V11.9885H22.9781C23.5298 11.9885 23.9771 11.5412 23.9771 10.9894L24 8.56699C24 7.54227 23.4765 6.58857 22.612 6.03842L14.6933 0.999255ZM5.99428 21.979H3.99619V11.9885H5.99428V21.979ZM15.9847 11.9885V21.979H7.99237V11.9885H15.9847ZM19.9809 21.979H17.9828V11.9885H19.9809V21.979ZM13.51 6.47104C13.51 7.29868 12.8391 7.96961 12.0114 7.96961C11.1838 7.96961 10.5129 7.29868 10.5129 6.47104C10.5129 5.6434 11.1838 4.97247 12.0114 4.97247C12.8391 4.97247 13.51 5.6434 13.51 6.47104Z" fill="#2B2E38"/>
8
3
  </svg>
@@ -30,6 +30,7 @@ import { makeFontStyleObject } from "../../utils/fonts";
30
30
  import { WithTestID } from "../../utils/types";
31
31
  import { IOIcons, Icon } from "../icons";
32
32
  import { Body, H6, LabelSmall } from "../typography";
33
+ import { IOLogoPaymentType, LogoPayment } from "../logos";
33
34
 
34
35
  // TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
35
36
  const legacyStyles = StyleSheet.create({
@@ -41,20 +42,27 @@ const legacyStyles = StyleSheet.create({
41
42
  }
42
43
  });
43
44
 
44
- export type ListItemNav = WithTestID<{
45
+ type ListItemNavPartialProps = WithTestID<{
45
46
  value: string | React.ReactNode;
46
47
  description?: string | React.ReactNode;
47
48
  onPress: (event: GestureResponderEvent) => void;
48
- icon?: IOIcons;
49
49
  // Accessibility
50
50
  accessibilityLabel: string;
51
51
  }>;
52
52
 
53
+ export type ListItemNavGraphicProps =
54
+ | { icon?: never; paymentLogo: IOLogoPaymentType }
55
+ | { icon: IOIcons; paymentLogo?: never }
56
+ | { icon?: never; paymentLogo?: never };
57
+
58
+ export type ListItemNav = ListItemNavPartialProps & ListItemNavGraphicProps;
59
+
53
60
  export const ListItemNav = ({
54
61
  value,
55
62
  description,
56
63
  onPress,
57
64
  icon,
65
+ paymentLogo,
58
66
  accessibilityLabel,
59
67
  testID
60
68
  }: ListItemNav) => {
@@ -94,9 +102,7 @@ export const ListItemNav = ({
94
102
  </>
95
103
  );
96
104
 
97
- const navTextComponent = isExperimental
98
- ? navText
99
- : legacyNavText;
105
+ const navTextComponent = isExperimental ? navText : legacyNavText;
100
106
  const mapBackgroundStates: Record<string, string> = {
101
107
  default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
102
108
  pressed: IOColors[theme["listItem-pressed"]]
@@ -171,6 +177,14 @@ export const ListItemNav = ({
171
177
  />
172
178
  </View>
173
179
  )}
180
+ {paymentLogo && (
181
+ <View style={{ marginRight: IOListItemVisualParams.iconMargin }}>
182
+ <LogoPayment
183
+ name={paymentLogo}
184
+ size={IOListItemVisualParams.iconSize}
185
+ />
186
+ </View>
187
+ )}
174
188
  <View style={IOStyles.flex}>{navTextComponent}</View>
175
189
  <View style={{ marginLeft: IOListItemVisualParams.iconMargin }}>
176
190
  <Icon
@@ -1,13 +1,10 @@
1
- import React from "react";
2
- import {
3
- ActivityIndicator,
4
- GestureResponderEvent,
5
- Switch,
6
- View
7
- } from "react-native";
1
+ import React, { useMemo } from "react";
2
+ import { GestureResponderEvent, Switch, View } from "react-native";
8
3
  import {
4
+ IOColors,
9
5
  IOSelectionListItemStyles,
10
6
  IOSelectionListItemVisualParams,
7
+ useIOExperimentalDesign,
11
8
  useIOTheme
12
9
  } from "../../core";
13
10
  import { IOIcons, Icon } from "../icons";
@@ -16,6 +13,7 @@ import { H6, LabelSmall, LabelLink } from "../typography";
16
13
  import { NativeSwitch } from "../switch/NativeSwitch";
17
14
  import { Badge } from "../badge";
18
15
  import { IOLogoPaymentType, LogoPayment } from "../logos";
16
+ import { LoadingSpinner } from "../loadingSpinner";
19
17
 
20
18
  type PartialProps = {
21
19
  label: string;
@@ -52,15 +50,25 @@ export const ListItemSwitch = React.memo(
52
50
  description,
53
51
  icon,
54
52
  paymentLogo,
55
- value,
53
+ value = false,
56
54
  disabled,
57
55
  action,
58
56
  isLoading,
59
57
  badge,
60
58
  onSwitchValueChange
61
59
  }: ListItemSwitchProps) => {
60
+ const { isExperimental } = useIOExperimentalDesign();
62
61
  const theme = useIOTheme();
63
62
 
63
+ // If we have a badge or we are loading, we can't render the switch
64
+ // this affects the accessibility tree and the rendering of the component
65
+ const canRenderSwitch = useMemo(
66
+ () => !isLoading && !badge,
67
+ [isLoading, badge]
68
+ );
69
+
70
+ const primaryColor: IOColors = isExperimental ? "blueIO-500" : "blue";
71
+
64
72
  return (
65
73
  <View
66
74
  testID="ListItemSwitch"
@@ -72,12 +80,14 @@ export const ListItemSwitch = React.memo(
72
80
  ]}
73
81
  pointerEvents={disabled ? "none" : "auto"}
74
82
  needsOffscreenAlphaCompositing={true}
83
+ accessible={false}
75
84
  >
76
85
  <View
77
86
  style={[
78
87
  IOSelectionListItemStyles.listItemInner,
79
88
  { alignItems: "center" }
80
89
  ]}
90
+ accessible={false}
81
91
  >
82
92
  <View
83
93
  style={{
@@ -85,6 +95,10 @@ export const ListItemSwitch = React.memo(
85
95
  flexDirection: "row",
86
96
  alignItems: "center"
87
97
  }}
98
+ accessible={!canRenderSwitch}
99
+ importantForAccessibility={
100
+ !canRenderSwitch ? "yes" : "no-hide-descendants"
101
+ }
88
102
  >
89
103
  {icon && (
90
104
  <View
@@ -114,7 +128,14 @@ export const ListItemSwitch = React.memo(
114
128
  </View>
115
129
  )}
116
130
 
117
- <H6 color={"black"} style={{ flex: 1 }}>
131
+ <H6
132
+ color={"black"}
133
+ style={{ flex: 1 }}
134
+ accessible={!canRenderSwitch}
135
+ importantForAccessibility={
136
+ !canRenderSwitch ? "yes" : "no-hide-descendants"
137
+ }
138
+ >
118
139
  {label}
119
140
  </H6>
120
141
  </View>
@@ -133,9 +154,13 @@ export const ListItemSwitch = React.memo(
133
154
  testID={badge.testID}
134
155
  />
135
156
  )}
136
- {isLoading && <ActivityIndicator color={"black"} />}
137
- {!isLoading && !badge && (
138
- <NativeSwitch value={value} onValueChange={onSwitchValueChange} />
157
+ {isLoading && <LoadingSpinner size={24} color={primaryColor} />}
158
+ {canRenderSwitch && (
159
+ <NativeSwitch
160
+ value={value}
161
+ accessibilityLabel={label}
162
+ onValueChange={onSwitchValueChange}
163
+ />
139
164
  )}
140
165
  </View>
141
166
  </View>
@@ -91,7 +91,7 @@ const MUNICIPALITY_LOGO_SIZE = 44;
91
91
 
92
92
  const LeftComponent = ({ logoIcon }: LeftComponentProps) => {
93
93
  if (isImageUri(logoIcon)) {
94
- return <Avatar logoUri={[logoIcon]} size="small" shape="circle" />;
94
+ return <Avatar logoUri={logoIcon} size="small" shape="circle" />;
95
95
  }
96
96
  if (React.isValidElement(logoIcon)) {
97
97
  return <>{logoIcon}</>;
@@ -146,7 +146,7 @@ exports[`Test List Item Components ListItemIDP Snapshot 1`] = `
146
146
  "paddingHorizontal": 16,
147
147
  "paddingVertical": 16,
148
148
  },
149
- undefined,
149
+ false,
150
150
  {
151
151
  "transform": [
152
152
  {
@@ -20,8 +20,8 @@ export type IOLoadingSpinnerSizeScale = 24 | 48 | 76;
20
20
 
21
21
  const strokeMap: Record<NonNullable<LoadingSpinner["size"]>, number> = {
22
22
  24: 3,
23
- 48: 6,
24
- 76: 9
23
+ 48: 5,
24
+ 76: 7
25
25
  };
26
26
 
27
27
  const startRotationAnimation = (
@@ -41,7 +41,7 @@ const startRotationAnimation = (
41
41
  export const LoadingSpinner = ({
42
42
  color = "blueIO-500",
43
43
  size = 24,
44
- durationMs = 750,
44
+ durationMs = 850,
45
45
  accessibilityHint,
46
46
  accessibilityLabel,
47
47
  testID = "LoadingSpinnerTestID"
@@ -1,57 +1,30 @@
1
1
  import * as React from "react";
2
- import { useCallback } from "react";
3
2
  import {
4
- GestureResponderEvent,
5
3
  Image,
6
4
  ImageSourcePropType,
7
5
  Platform,
8
- Pressable,
9
6
  StyleSheet,
10
7
  Text
11
8
  } from "react-native";
12
- import Animated, {
13
- Extrapolate,
14
- interpolate,
15
- useAnimatedStyle,
16
- useDerivedValue,
17
- useSharedValue,
18
- withSpring
19
- } from "react-native-reanimated";
20
9
  import {
21
10
  IOColors,
22
- IOModuleIDPHSpacing,
23
- IOModuleIDPRadius,
24
- IOModuleIDPSavedVSpacing,
25
- IOModuleIDPVSpacing,
26
11
  IOListItemLogoMargin,
27
- IOScaleValues,
28
- IOSpringValues,
29
12
  useIOExperimentalDesign
30
13
  } from "../../core";
31
14
  import { toAndroidCacheTimestamp } from "../../utils/dates";
32
15
  import { makeFontStyleObject } from "../../utils/fonts";
33
- import { WithTestID } from "../../utils/types";
16
+ import {
17
+ PressableModuleBase,
18
+ PressableModuleBaseProps
19
+ } from "./PressableModuleBase";
34
20
 
35
- type ModuleIDP = WithTestID<{
21
+ interface ModuleIDP extends PressableModuleBaseProps {
36
22
  name: string;
37
23
  localLogo: ImageSourcePropType;
38
24
  logo: ImageSourcePropType;
39
- saved?: boolean;
40
- onPress: (event: GestureResponderEvent) => void;
41
- }>;
25
+ }
42
26
 
43
27
  const styles = StyleSheet.create({
44
- button: {
45
- borderWidth: 1,
46
- borderColor: IOColors["grey-100"],
47
- borderRadius: IOModuleIDPRadius,
48
- backgroundColor: IOColors.white,
49
- flexDirection: "row",
50
- justifyContent: "space-between",
51
- alignItems: "center",
52
- paddingVertical: IOModuleIDPVSpacing,
53
- paddingHorizontal: IOModuleIDPHSpacing
54
- },
55
28
  idpName: {
56
29
  color: IOColors["grey-700"],
57
30
  fontSize: 12,
@@ -84,41 +57,11 @@ export const ModuleIDP = ({
84
57
  name,
85
58
  localLogo,
86
59
  logo,
87
- saved,
60
+ withLooseSpacing = false,
88
61
  onPress,
89
62
  testID
90
63
  }: ModuleIDP) => {
91
- const isPressed = useSharedValue(0);
92
64
  const { isExperimental } = useIOExperimentalDesign();
93
- // Scaling transformation applied when the button is pressed
94
- const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState;
95
-
96
- const scaleTraversed = useDerivedValue(() =>
97
- withSpring(isPressed.value, IOSpringValues.button)
98
- );
99
-
100
- // Interpolate animation values from `isPressed` values
101
- const animatedStyle = useAnimatedStyle(() => {
102
- const scale = interpolate(
103
- scaleTraversed.value,
104
- [0, 1],
105
- [1, animationScaleValue],
106
- Extrapolate.CLAMP
107
- );
108
-
109
- return {
110
- transform: [{ scale }]
111
- };
112
- });
113
-
114
- const handlePressIn = useCallback(() => {
115
- // eslint-disable-next-line functional/immutable-data
116
- isPressed.value = 1;
117
- }, [isPressed]);
118
- const handlePressOut = useCallback(() => {
119
- // eslint-disable-next-line functional/immutable-data
120
- isPressed.value = 0;
121
- }, [isPressed]);
122
65
 
123
66
  // eslint-disable-next-line no-console
124
67
  const urlLogoIDP = localLogo
@@ -127,34 +70,21 @@ export const ModuleIDP = ({
127
70
  uri: `${logo}${androidIdpLogoForcedRefreshed()}`
128
71
  };
129
72
  return (
130
- <Pressable
73
+ <PressableModuleBase
131
74
  onPress={onPress}
132
- onPressIn={handlePressIn}
133
- onPressOut={handlePressOut}
134
- onTouchEnd={handlePressOut}
135
- accessible={true}
136
- accessibilityRole={"button"}
137
- accessibilityLabel={name}
138
75
  testID={testID}
76
+ withLooseSpacing={withLooseSpacing}
139
77
  >
140
- <Animated.View
78
+ <Text
141
79
  style={[
142
- styles.button,
143
- saved && { paddingVertical: IOModuleIDPSavedVSpacing },
144
- animatedStyle
80
+ styles.idpName,
81
+ isExperimental ? styles.idpNameFont : styles.idpLegacyNameFont
145
82
  ]}
146
83
  >
147
- <Text
148
- style={[
149
- styles.idpName,
150
- isExperimental ? styles.idpNameFont : styles.idpLegacyNameFont
151
- ]}
152
- >
153
- {name}
154
- </Text>
155
- <Image source={urlLogoIDP} style={styles.idpLogo} />
156
- </Animated.View>
157
- </Pressable>
84
+ {name}
85
+ </Text>
86
+ <Image source={urlLogoIDP} style={styles.idpLogo} />
87
+ </PressableModuleBase>
158
88
  );
159
89
  };
160
90
 
@@ -1,19 +1,5 @@
1
1
  import * as React from "react";
2
- import { useCallback } from "react";
3
- import {
4
- GestureResponderEvent,
5
- Pressable,
6
- StyleSheet,
7
- View
8
- } from "react-native";
9
- import Animated, {
10
- Extrapolate,
11
- interpolate,
12
- useAnimatedStyle,
13
- useDerivedValue,
14
- useSharedValue,
15
- withSpring
16
- } from "react-native-reanimated";
2
+ import { GestureResponderEvent, StyleSheet, View } from "react-native";
17
3
  import Placeholder from "rn-placeholder";
18
4
  import { WithTestID } from "../../utils/types";
19
5
  import { getAccessibleAmountText } from "../../utils/accessibility";
@@ -21,14 +7,13 @@ import { H6, LabelSmall } from "../typography";
21
7
  import { Badge } from "../badge";
22
8
  import { Icon } from "../icons";
23
9
  import {
24
- IOColors,
25
10
  IOListItemVisualParams,
26
- IOScaleValues,
27
- IOSpringValues,
11
+ IOModuleStyles,
28
12
  IOStyles,
29
13
  useIOExperimentalDesign
30
14
  } from "../../core";
31
15
  import { VSpacer } from "../spacer";
16
+ import { PressableModuleBase } from "./PressableModuleBase";
32
17
 
33
18
  export type PaymentNoticeStatus =
34
19
  | "default"
@@ -36,7 +21,8 @@ export type PaymentNoticeStatus =
36
21
  | "error"
37
22
  | "expired"
38
23
  | "revoked"
39
- | "canceled";
24
+ | "canceled"
25
+ | "in-progress";
40
26
 
41
27
  export type ModulePaymentNoticeProps = WithTestID<
42
28
  {
@@ -60,19 +46,6 @@ export type ModulePaymentNoticeProps = WithTestID<
60
46
  >;
61
47
 
62
48
  const styles = StyleSheet.create({
63
- button: {
64
- flex: 1,
65
- flexDirection: "row",
66
- alignItems: "center",
67
- justifyContent: "space-between",
68
- paddingHorizontal: 16,
69
- paddingVertical: 16,
70
- borderRadius: 8,
71
- borderColor: IOColors.bluegreyLight,
72
- backgroundColor: IOColors.white,
73
- borderStyle: "solid",
74
- borderWidth: 1
75
- },
76
49
  rightSection: {
77
50
  marginLeft: IOListItemVisualParams.iconMargin,
78
51
  flexDirection: "row",
@@ -111,12 +84,14 @@ const ModulePaymentNoticeContent = ({
111
84
  return <Badge variant="default" text={badgeText} />;
112
85
  case "canceled":
113
86
  return <Badge variant="default" text={badgeText} />;
87
+ case "in-progress":
88
+ return <Badge variant="info" text={badgeText} />;
114
89
  }
115
90
  };
116
91
 
117
92
  return (
118
93
  <>
119
- <View style={{ flexGrow: 1, flexShrink: 1 }}>
94
+ <View style={{ flexGrow: 1, flexShrink: 1, paddingEnd: 8 }}>
120
95
  {title && (
121
96
  <LabelSmall numberOfLines={1} weight="Regular" color="bluegrey">
122
97
  {title}
@@ -126,6 +101,7 @@ const ModulePaymentNoticeContent = ({
126
101
  weight="SemiBold"
127
102
  font={isExperimental ? "ReadexPro" : "TitilliumWeb"}
128
103
  color={isExperimental ? "blueIO-500" : "bluegrey"}
104
+ numberOfLines={2}
129
105
  >
130
106
  {subtitle}
131
107
  </LabelSmall>
@@ -161,62 +137,23 @@ export const ModulePaymentNotice = ({
161
137
  onPress,
162
138
  ...rest
163
139
  }: ModulePaymentNoticeProps) => {
164
- const isPressed: Animated.SharedValue<number> = useSharedValue(0);
165
-
166
- // Scaling transformation applied when the button is pressed
167
- const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState;
168
-
169
- const scaleTraversed = useDerivedValue(() =>
170
- withSpring(isPressed.value, IOSpringValues.button)
171
- );
172
-
173
- // Interpolate animation values from `isPressed` values
174
- const animatedStyle = useAnimatedStyle(() => {
175
- const scale = interpolate(
176
- scaleTraversed.value,
177
- [0, 1],
178
- [1, animationScaleValue],
179
- Extrapolate.CLAMP
180
- );
181
-
182
- return {
183
- transform: [{ scale }]
184
- };
185
- });
186
-
187
- const onPressIn = useCallback(() => {
188
- // eslint-disable-next-line functional/immutable-data
189
- isPressed.value = 1;
190
- }, [isPressed]);
191
-
192
- const onPressOut = useCallback(() => {
193
- // eslint-disable-next-line functional/immutable-data
194
- isPressed.value = 0;
195
- }, [isPressed]);
196
-
197
140
  if (isLoading) {
198
141
  return <SkeletonComponent />;
199
142
  }
200
143
 
201
144
  return (
202
- <Pressable
203
- testID={testID}
145
+ <PressableModuleBase
204
146
  onPress={onPress}
205
- onPressIn={onPressIn}
206
- onPressOut={onPressOut}
207
- accessible={true}
208
- accessibilityRole={"button"}
209
147
  accessibilityLabel={accessibilityLabel}
148
+ testID={testID}
210
149
  >
211
- <Animated.View style={[styles.button, animatedStyle]}>
212
- <ModulePaymentNoticeContent {...rest} />
213
- </Animated.View>
214
- </Pressable>
150
+ <ModulePaymentNoticeContent {...rest} />
151
+ </PressableModuleBase>
215
152
  );
216
153
  };
217
154
 
218
155
  const SkeletonComponent = () => (
219
- <View style={styles.button} accessible={false}>
156
+ <View style={IOModuleStyles.button} accessible={false}>
220
157
  <View style={IOStyles.flex}>
221
158
  <Placeholder.Box animate="fade" radius={8} width={179} height={16} />
222
159
  <VSpacer size={4} />
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ import { GestureResponderEvent, Pressable } from "react-native";
3
+ import Animated from "react-native-reanimated";
4
+ import { IOModuleIDPSavedVSpacing, IOModuleStyles } from "../../core";
5
+ import { WithTestID } from "../../utils/types";
6
+ import { useModuleSpringAnimation } from "./hooks/useModuleSpringAnimation";
7
+
8
+ export type PressableModuleBaseProps = WithTestID<{
9
+ accessibilityLabel?: string;
10
+ onPress?: (event: GestureResponderEvent) => void;
11
+ withLooseSpacing?: boolean;
12
+ }>;
13
+
14
+ export const PressableModuleBase = ({
15
+ onPress,
16
+ testID,
17
+ accessibilityLabel,
18
+ withLooseSpacing = false,
19
+ children
20
+ }: React.PropsWithChildren<PressableModuleBaseProps>) => {
21
+ const { handlePressIn, handlePressOut, animatedStyle } =
22
+ useModuleSpringAnimation();
23
+ return (
24
+ <Pressable
25
+ onPress={onPress}
26
+ testID={testID}
27
+ accessible={true}
28
+ accessibilityLabel={accessibilityLabel}
29
+ onPressIn={handlePressIn}
30
+ onPressOut={handlePressOut}
31
+ onTouchEnd={handlePressOut}
32
+ accessibilityRole="button"
33
+ >
34
+ <Animated.View
35
+ style={[
36
+ IOModuleStyles.button,
37
+ withLooseSpacing && { paddingVertical: IOModuleIDPSavedVSpacing },
38
+ animatedStyle
39
+ ]}
40
+ >
41
+ {children}
42
+ </Animated.View>
43
+ </Pressable>
44
+ );
45
+ };