@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.
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +68 -2
- package/lib/commonjs/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +285 -9
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +700 -33
- package/lib/commonjs/components/claimsSelector/ClaimsSelector.js +41 -23
- package/lib/commonjs/components/claimsSelector/ClaimsSelector.js.map +1 -1
- package/lib/commonjs/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +554 -188
- package/lib/commonjs/components/headers/HeaderFirstLevel.js +1 -1
- package/lib/commonjs/components/headers/HeaderFirstLevel.js.map +1 -1
- package/lib/commonjs/components/headers/HeaderSecondLevel.js +3 -2
- package/lib/commonjs/components/headers/HeaderSecondLevel.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +925 -41
- package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js +14 -18
- package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js.map +1 -1
- package/lib/commonjs/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +304 -8
- package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +430 -32
- package/lib/commonjs/components/templates/Dismissable.js +6 -1
- package/lib/commonjs/components/templates/Dismissable.js.map +1 -1
- package/lib/commonjs/components/templates/ForceScrollDownView.js +5 -4
- package/lib/commonjs/components/templates/ForceScrollDownView.js.map +1 -1
- package/lib/commonjs/hooks/useAccordionAnimation.js +9 -1
- package/lib/commonjs/hooks/useAccordionAnimation.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +68 -2
- package/lib/module/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +285 -9
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +700 -33
- package/lib/module/components/claimsSelector/ClaimsSelector.js +42 -24
- package/lib/module/components/claimsSelector/ClaimsSelector.js.map +1 -1
- package/lib/module/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +554 -188
- package/lib/module/components/headers/HeaderFirstLevel.js +2 -2
- package/lib/module/components/headers/HeaderFirstLevel.js.map +1 -1
- package/lib/module/components/headers/HeaderSecondLevel.js +4 -3
- package/lib/module/components/headers/HeaderSecondLevel.js.map +1 -1
- package/lib/module/components/layout/FooterActions.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +925 -41
- package/lib/module/components/loadingSpinner/LoadingSpinner.js +15 -19
- package/lib/module/components/loadingSpinner/LoadingSpinner.js.map +1 -1
- package/lib/module/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +304 -8
- package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +430 -32
- package/lib/module/components/templates/Dismissable.js +7 -2
- package/lib/module/components/templates/Dismissable.js.map +1 -1
- package/lib/module/components/templates/ForceScrollDownView.js +6 -5
- package/lib/module/components/templates/ForceScrollDownView.js.map +1 -1
- package/lib/module/hooks/useAccordionAnimation.js +10 -2
- package/lib/module/hooks/useAccordionAnimation.js.map +1 -1
- package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts +7 -1
- package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts.map +1 -1
- package/lib/typescript/components/headers/HeaderSecondLevel.d.ts.map +1 -1
- package/lib/typescript/components/icons/Icon.d.ts +5 -1
- package/lib/typescript/components/icons/Icon.d.ts.map +1 -1
- package/lib/typescript/components/layout/FooterActions.d.ts +3 -3
- package/lib/typescript/components/layout/FooterActions.d.ts.map +1 -1
- package/lib/typescript/components/loadingSpinner/LoadingSpinner.d.ts.map +1 -1
- package/lib/typescript/components/templates/Dismissable.d.ts.map +1 -1
- package/lib/typescript/components/templates/ForceScrollDownView.d.ts +1 -1
- package/lib/typescript/components/templates/ForceScrollDownView.d.ts.map +1 -1
- package/lib/typescript/components/typography/IOText.d.ts +1 -1
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/hooks/useAccordionAnimation.d.ts +4 -0
- package/lib/typescript/hooks/useAccordionAnimation.d.ts.map +1 -1
- package/package.json +7 -5
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +68 -2
- package/src/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +285 -9
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +700 -33
- package/src/components/claimsSelector/ClaimsSelector.tsx +56 -37
- package/src/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +554 -188
- package/src/components/headers/HeaderFirstLevel.tsx +2 -2
- package/src/components/headers/HeaderSecondLevel.tsx +4 -4
- package/src/components/layout/FooterActions.tsx +3 -3
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +925 -41
- package/src/components/loadingSpinner/LoadingSpinner.tsx +20 -24
- package/src/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +304 -8
- package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +430 -32
- package/src/components/templates/Dismissable.tsx +5 -2
- package/src/components/templates/ForceScrollDownView.tsx +7 -8
- 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-
|
|
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
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|