@pagopa/io-app-design-system 5.12.1 → 6.0.0-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 (74) hide show
  1. package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +68 -2
  2. package/lib/commonjs/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +285 -9
  3. package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +700 -33
  4. package/lib/commonjs/components/claimsSelector/ClaimsSelector.js +41 -23
  5. package/lib/commonjs/components/claimsSelector/ClaimsSelector.js.map +1 -1
  6. package/lib/commonjs/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +554 -188
  7. package/lib/commonjs/components/headers/HeaderFirstLevel.js +1 -1
  8. package/lib/commonjs/components/headers/HeaderFirstLevel.js.map +1 -1
  9. package/lib/commonjs/components/headers/HeaderSecondLevel.js +3 -2
  10. package/lib/commonjs/components/headers/HeaderSecondLevel.js.map +1 -1
  11. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +925 -41
  12. package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js +14 -18
  13. package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js.map +1 -1
  14. package/lib/commonjs/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +304 -8
  15. package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +430 -32
  16. package/lib/commonjs/components/templates/Dismissable.js +6 -1
  17. package/lib/commonjs/components/templates/Dismissable.js.map +1 -1
  18. package/lib/commonjs/components/templates/ForceScrollDownView.js +5 -4
  19. package/lib/commonjs/components/templates/ForceScrollDownView.js.map +1 -1
  20. package/lib/commonjs/hooks/useAccordionAnimation.js +9 -1
  21. package/lib/commonjs/hooks/useAccordionAnimation.js.map +1 -1
  22. package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +68 -2
  23. package/lib/module/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +285 -9
  24. package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +700 -33
  25. package/lib/module/components/claimsSelector/ClaimsSelector.js +42 -24
  26. package/lib/module/components/claimsSelector/ClaimsSelector.js.map +1 -1
  27. package/lib/module/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +554 -188
  28. package/lib/module/components/headers/HeaderFirstLevel.js +2 -2
  29. package/lib/module/components/headers/HeaderFirstLevel.js.map +1 -1
  30. package/lib/module/components/headers/HeaderSecondLevel.js +4 -3
  31. package/lib/module/components/headers/HeaderSecondLevel.js.map +1 -1
  32. package/lib/module/components/layout/FooterActions.js.map +1 -1
  33. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +925 -41
  34. package/lib/module/components/loadingSpinner/LoadingSpinner.js +15 -19
  35. package/lib/module/components/loadingSpinner/LoadingSpinner.js.map +1 -1
  36. package/lib/module/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +304 -8
  37. package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +430 -32
  38. package/lib/module/components/templates/Dismissable.js +7 -2
  39. package/lib/module/components/templates/Dismissable.js.map +1 -1
  40. package/lib/module/components/templates/ForceScrollDownView.js +6 -5
  41. package/lib/module/components/templates/ForceScrollDownView.js.map +1 -1
  42. package/lib/module/hooks/useAccordionAnimation.js +10 -2
  43. package/lib/module/hooks/useAccordionAnimation.js.map +1 -1
  44. package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts +7 -1
  45. package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts.map +1 -1
  46. package/lib/typescript/components/headers/HeaderSecondLevel.d.ts.map +1 -1
  47. package/lib/typescript/components/icons/Icon.d.ts +5 -1
  48. package/lib/typescript/components/icons/Icon.d.ts.map +1 -1
  49. package/lib/typescript/components/layout/FooterActions.d.ts +3 -3
  50. package/lib/typescript/components/layout/FooterActions.d.ts.map +1 -1
  51. package/lib/typescript/components/loadingSpinner/LoadingSpinner.d.ts.map +1 -1
  52. package/lib/typescript/components/templates/Dismissable.d.ts.map +1 -1
  53. package/lib/typescript/components/templates/ForceScrollDownView.d.ts +1 -1
  54. package/lib/typescript/components/templates/ForceScrollDownView.d.ts.map +1 -1
  55. package/lib/typescript/components/typography/IOText.d.ts +1 -1
  56. package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
  57. package/lib/typescript/hooks/useAccordionAnimation.d.ts +4 -0
  58. package/lib/typescript/hooks/useAccordionAnimation.d.ts.map +1 -1
  59. package/package.json +7 -5
  60. package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +68 -2
  61. package/src/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +285 -9
  62. package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +700 -33
  63. package/src/components/claimsSelector/ClaimsSelector.tsx +56 -37
  64. package/src/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +554 -188
  65. package/src/components/headers/HeaderFirstLevel.tsx +2 -2
  66. package/src/components/headers/HeaderSecondLevel.tsx +4 -4
  67. package/src/components/layout/FooterActions.tsx +3 -3
  68. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +925 -41
  69. package/src/components/loadingSpinner/LoadingSpinner.tsx +20 -24
  70. package/src/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +304 -8
  71. package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +430 -32
  72. package/src/components/templates/Dismissable.tsx +5 -2
  73. package/src/components/templates/ForceScrollDownView.tsx +7 -8
  74. package/src/hooks/useAccordionAnimation.tsx +13 -1
@@ -2,14 +2,9 @@ import React, { Fragment } from "react";
2
2
  import { Image, StyleSheet, View } from "react-native";
3
3
  import { TouchableWithoutFeedback } from "react-native-gesture-handler";
4
4
  import LinearGradient from "react-native-linear-gradient";
5
- import Animated from "react-native-reanimated";
5
+ import Animated, { useAnimatedStyle } from "react-native-reanimated";
6
6
  import { useIOTheme } from "../../context";
7
- import {
8
- hexToRgba,
9
- IOAccordionRadius,
10
- IOColors,
11
- IOSpacingScale
12
- } from "../../core";
7
+ import { IOAccordionRadius, IOColors, IOSpacingScale } from "../../core";
13
8
  import { useAccordionAnimation } from "../../hooks/useAccordionAnimation";
14
9
  import { Icon } from "../icons";
15
10
  import { Divider } from "../layout";
@@ -18,6 +13,12 @@ import { H6 } from "../typography";
18
13
 
19
14
  const accordionBodySpacing: IOSpacingScale = 16;
20
15
 
16
+ // Threshold to determine when the accordion is considered fully collapsed
17
+ const COLLAPSED_RADIUS_THRESHOLD = 0.001;
18
+
19
+ // Border width offset to ensure gradient fits within the border curves
20
+ const COLLAPSIBLE_BORDER = 1;
21
+
21
22
  type Props = {
22
23
  /**
23
24
  * The accordion title.
@@ -50,6 +51,10 @@ type Props = {
50
51
  */
51
52
  onToggle?: (expanded: boolean) => void;
52
53
  accessibilityLabel?: string;
54
+ /**
55
+ * Accordion header gradient colors.
56
+ */
57
+ headerGradientColors?: Array<string>;
53
58
  };
54
59
 
55
60
  type Item = {
@@ -57,6 +62,7 @@ type Item = {
57
62
  value: string;
58
63
  description: string;
59
64
  type?: "text" | "image";
65
+ endElement?: ListItemInfo["endElement"];
60
66
  };
61
67
 
62
68
  export const ClaimsSelector = ({
@@ -67,7 +73,8 @@ export const ClaimsSelector = ({
67
73
  onToggle,
68
74
  accessibilityLabel,
69
75
  selectedItemIds,
70
- selectionEnabled = true
76
+ selectionEnabled = true,
77
+ headerGradientColors
71
78
  }: Props) => {
72
79
  const theme = useIOTheme();
73
80
  const {
@@ -76,12 +83,13 @@ export const ClaimsSelector = ({
76
83
  onBodyLayout,
77
84
  iconAnimatedStyle,
78
85
  bodyAnimatedStyle,
79
- bodyInnerStyle
86
+ bodyInnerStyle,
87
+ progress
80
88
  } = useAccordionAnimation({
81
89
  defaultExpanded
82
90
  });
83
91
 
84
- const accordionBackground: IOColors = theme["appBackground-secondary"];
92
+ const accordionBackground: IOColors = theme["appBackground-primary"];
85
93
  const accordionBorder: IOColors = theme["cardBorder-default"];
86
94
 
87
95
  const onItemPress = () => {
@@ -89,8 +97,32 @@ export const ClaimsSelector = ({
89
97
  onToggle?.(!expanded);
90
98
  };
91
99
 
100
+ const hasHeaderGradient =
101
+ headerGradientColors && headerGradientColors.length >= 2;
102
+
103
+ const headerForegroundColor: IOColors = hasHeaderGradient
104
+ ? "black"
105
+ : theme["textBody-default"];
106
+
107
+ const headerRadiusAnimatedStyle = useAnimatedStyle(() => {
108
+ /**
109
+ * Dynamically adjust bottom corner radius based on the expansion progress.
110
+ * Bottom corners are rounded only when the accordion is fully collapsed to
111
+ * ensure visual consistency with the outer container.
112
+ */
113
+ const bottomRadius =
114
+ progress.value < COLLAPSED_RADIUS_THRESHOLD ? IOAccordionRadius : 0;
115
+ return {
116
+ borderTopLeftRadius: IOAccordionRadius - COLLAPSIBLE_BORDER,
117
+ borderTopRightRadius: IOAccordionRadius - COLLAPSIBLE_BORDER,
118
+ borderBottomLeftRadius: bottomRadius - COLLAPSIBLE_BORDER,
119
+ borderBottomRightRadius: bottomRadius - COLLAPSIBLE_BORDER,
120
+ overflow: "hidden"
121
+ };
122
+ });
123
+
92
124
  const renderClaimItem = (item: Item, index: number) => {
93
- const { id, value, description, type = "text" } = item;
125
+ const { id, value, description, type = "text", endElement } = item;
94
126
  return (
95
127
  <Fragment key={id}>
96
128
  {index !== 0 && <Divider />}
@@ -124,6 +156,7 @@ export const ClaimsSelector = ({
124
156
  label={description}
125
157
  accessibilityRole={type}
126
158
  reversed
159
+ endElement={endElement}
127
160
  />
128
161
  )
129
162
  }
@@ -148,15 +181,20 @@ export const ClaimsSelector = ({
148
181
  accessibilityLabel={accessibilityLabel ?? title}
149
182
  onPress={onItemPress}
150
183
  >
151
- <View style={styles.textContainer}>
152
- <H6 color={theme["textBody-default"]}>{title}</H6>
153
- <Animated.View style={iconAnimatedStyle}>
154
- <Icon
155
- name="chevronBottom"
156
- color={theme["interactiveElem-default"]}
184
+ <Animated.View
185
+ style={[styles.textContainer, headerRadiusAnimatedStyle]}
186
+ >
187
+ {hasHeaderGradient && (
188
+ <LinearGradient
189
+ colors={headerGradientColors}
190
+ style={StyleSheet.absoluteFill}
157
191
  />
192
+ )}
193
+ <H6 color={headerForegroundColor}>{title}</H6>
194
+ <Animated.View style={iconAnimatedStyle}>
195
+ <Icon name="chevronBottom" color={headerForegroundColor} />
158
196
  </Animated.View>
159
- </View>
197
+ </Animated.View>
160
198
  </TouchableWithoutFeedback>
161
199
 
162
200
  <Animated.View style={bodyAnimatedStyle}>
@@ -167,16 +205,6 @@ export const ClaimsSelector = ({
167
205
  {items.map(renderClaimItem)}
168
206
  </View>
169
207
  </Animated.View>
170
-
171
- {/* This gradient adds a smooth end to the content. If it is missing,
172
- the content will be cut sharply during the height transition. */}
173
- <LinearGradient
174
- style={styles.linearGradient}
175
- colors={[
176
- hexToRgba(IOColors[accordionBackground], 0),
177
- IOColors[accordionBackground]
178
- ]}
179
- />
180
208
  </View>
181
209
  );
182
210
  };
@@ -196,15 +224,6 @@ const styles = StyleSheet.create({
196
224
  bodyInnerContainer: {
197
225
  width: "100%"
198
226
  },
199
- linearGradient: {
200
- height: accordionBodySpacing,
201
- position: "absolute",
202
- // Place at the bottom
203
- bottom: 0,
204
- // Avoid gradient overlaps with border radius
205
- left: accordionBodySpacing,
206
- right: accordionBodySpacing
207
- },
208
227
  imageClaim: {
209
228
  width: 160,
210
229
  aspectRatio: 3 / 4