@pagopa/io-app-design-system 2.1.1 → 3.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/listitems/ListItemRadioWithAmount.js +1 -3
- package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js +51 -74
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/PressableListItemsBase.js +3 -1
- package/lib/commonjs/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +18 -28
- package/lib/commonjs/components/listitems/__test__/listitem.test.js +0 -2
- package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadioWithAmount.js +1 -3
- package/lib/module/components/listitems/ListItemRadioWithAmount.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js +52 -75
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/PressableListItemsBase.js +4 -2
- package/lib/module/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +18 -28
- package/lib/module/components/listitems/__test__/listitem.test.js +0 -2
- package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/typescript/components/listitems/ListItemRadioWithAmount.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts +13 -11
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/PressableListItemsBase.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/listitems/ListItemRadioWithAmount.tsx +0 -1
- package/src/components/listitems/ListItemTransaction.tsx +60 -97
- package/src/components/listitems/PressableListItemsBase.tsx +6 -2
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +18 -28
- package/src/components/listitems/__test__/listitem.test.tsx +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ImageURISource,
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { ImageURISource, View } from "react-native";
|
|
3
3
|
import Placeholder from "rn-placeholder";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -20,38 +20,26 @@ import { LogoPaymentWithFallback } from "../common/LogoPaymentWithFallback";
|
|
|
20
20
|
import { IOIconSizeScale, Icon } from "../icons";
|
|
21
21
|
import { IOLogoPaymentType } from "../logos";
|
|
22
22
|
import { VSpacer } from "../spacer";
|
|
23
|
+
import { HStack } from "../stack";
|
|
23
24
|
import { H6, LabelSmall } from "../typography";
|
|
24
25
|
import {
|
|
25
26
|
PressableBaseProps,
|
|
26
27
|
PressableListItemBase
|
|
27
28
|
} from "./PressableListItemsBase";
|
|
28
29
|
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| "cancelled"
|
|
34
|
-
| "refunded"
|
|
35
|
-
| "reversal";
|
|
36
|
-
|
|
37
|
-
export type ListItemTransactionStatusWithoutBadge = Extract<
|
|
38
|
-
ListItemTransactionStatus,
|
|
39
|
-
"success" | "refunded"
|
|
40
|
-
>;
|
|
41
|
-
|
|
42
|
-
export type ListItemTransactionStatusWithBadge = Exclude<
|
|
43
|
-
ListItemTransactionStatus,
|
|
44
|
-
"success" | "refunded"
|
|
45
|
-
>;
|
|
30
|
+
export type ListItemTransactionBadge = {
|
|
31
|
+
text: string;
|
|
32
|
+
variant: Badge["variant"];
|
|
33
|
+
};
|
|
46
34
|
|
|
47
35
|
export type ListItemTransactionLogo =
|
|
48
36
|
| IOLogoPaymentType
|
|
49
37
|
| ImageURISource
|
|
50
|
-
|
|
|
38
|
+
| ReactNode;
|
|
51
39
|
|
|
52
40
|
export type ListItemTransaction = WithTestID<
|
|
53
41
|
PressableBaseProps & {
|
|
54
|
-
|
|
42
|
+
showChevron?: boolean;
|
|
55
43
|
isLoading?: boolean;
|
|
56
44
|
/**
|
|
57
45
|
* A logo that will be displayed on the left of the list item.
|
|
@@ -72,32 +60,32 @@ export type ListItemTransaction = WithTestID<
|
|
|
72
60
|
transaction: {
|
|
73
61
|
amount: string;
|
|
74
62
|
amountAccessibilityLabel: string;
|
|
75
|
-
|
|
63
|
+
badge?: never;
|
|
64
|
+
refund?: boolean;
|
|
76
65
|
};
|
|
77
|
-
badgeText?: string;
|
|
78
66
|
}
|
|
79
67
|
| {
|
|
80
68
|
transaction: {
|
|
81
69
|
amount?: string;
|
|
82
70
|
amountAccessibilityLabel?: string;
|
|
83
|
-
|
|
71
|
+
badge: ListItemTransactionBadge;
|
|
72
|
+
refund?: never;
|
|
84
73
|
};
|
|
85
|
-
badgeText: string;
|
|
86
74
|
}
|
|
87
75
|
)
|
|
88
76
|
>;
|
|
89
77
|
|
|
90
|
-
type LeftComponentProps = {
|
|
91
|
-
logoIcon: ListItemTransactionLogo;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
78
|
const CARD_LOGO_SIZE: IOIconSizeScale = 24;
|
|
95
79
|
const MUNICIPALITY_LOGO_SIZE = 44;
|
|
96
80
|
// this is the <Avatar/>'s "small" size,
|
|
97
81
|
// since it is bigger than the card logos, we use
|
|
98
82
|
// it as a base size for homogeneous sizing via container size.
|
|
99
83
|
|
|
100
|
-
const
|
|
84
|
+
const StartComponent = ({
|
|
85
|
+
logoIcon
|
|
86
|
+
}: {
|
|
87
|
+
logoIcon: ListItemTransactionLogo;
|
|
88
|
+
}) => {
|
|
101
89
|
if (isImageUri(logoIcon)) {
|
|
102
90
|
return <Avatar logoUri={logoIcon} size="small" />;
|
|
103
91
|
}
|
|
@@ -114,23 +102,20 @@ const LeftComponent = ({ logoIcon }: LeftComponentProps) => {
|
|
|
114
102
|
|
|
115
103
|
export const ListItemTransaction = ({
|
|
116
104
|
accessibilityLabel,
|
|
117
|
-
|
|
105
|
+
showChevron = false,
|
|
118
106
|
isLoading = false,
|
|
119
107
|
paymentLogoIcon,
|
|
120
108
|
onPress,
|
|
121
109
|
subtitle,
|
|
122
110
|
testID,
|
|
123
111
|
title,
|
|
124
|
-
transaction: { amount, amountAccessibilityLabel,
|
|
125
|
-
badgeText,
|
|
112
|
+
transaction: { amount, amountAccessibilityLabel, badge, refund },
|
|
126
113
|
numberOfLines = 2,
|
|
127
114
|
accessible
|
|
128
115
|
}: ListItemTransaction) => {
|
|
129
116
|
const { isExperimental } = useIOExperimentalDesign();
|
|
130
117
|
const theme = useIOTheme();
|
|
131
118
|
|
|
132
|
-
const maybeBadgeText = badgeText ?? "-";
|
|
133
|
-
|
|
134
119
|
if (isLoading) {
|
|
135
120
|
return <SkeletonComponent />;
|
|
136
121
|
}
|
|
@@ -139,56 +124,28 @@ export const ListItemTransaction = ({
|
|
|
139
124
|
? theme["interactiveElem-default"]
|
|
140
125
|
: "blue";
|
|
141
126
|
|
|
142
|
-
const
|
|
143
|
-
const
|
|
127
|
+
const amountColorDefault: IOColors = theme["textBody-default"];
|
|
128
|
+
const amountColorRefund: IOColors = theme.successText;
|
|
144
129
|
|
|
145
|
-
const
|
|
146
|
-
const TransactionAmountOrBadgeComponent = () => {
|
|
147
|
-
switch (status) {
|
|
148
|
-
case "success":
|
|
149
|
-
return (
|
|
150
|
-
<H6
|
|
151
|
-
accessibilityLabel={amountAccessibilityLabel}
|
|
152
|
-
color={hasChevronRight ? interactiveColor : amountColor}
|
|
153
|
-
numberOfLines={numberOfLines}
|
|
154
|
-
>
|
|
155
|
-
{amount || ""}
|
|
156
|
-
</H6>
|
|
157
|
-
);
|
|
158
|
-
case "refunded":
|
|
159
|
-
return (
|
|
160
|
-
<H6
|
|
161
|
-
accessibilityLabel={amountAccessibilityLabel}
|
|
162
|
-
color={hasChevronRight ? interactiveColor : successColor}
|
|
163
|
-
numberOfLines={numberOfLines}
|
|
164
|
-
>
|
|
165
|
-
{amount || ""}
|
|
166
|
-
</H6>
|
|
167
|
-
);
|
|
168
|
-
case "failure":
|
|
169
|
-
case "cancelled":
|
|
170
|
-
return <Badge variant="error" text={maybeBadgeText} />;
|
|
171
|
-
case "reversal":
|
|
172
|
-
return <Badge variant="lightBlue" text={maybeBadgeText} />;
|
|
173
|
-
case "pending":
|
|
174
|
-
return <Badge variant="info" text={maybeBadgeText} />;
|
|
175
|
-
}
|
|
176
|
-
};
|
|
130
|
+
const amountColor = refund ? amountColorRefund : amountColorDefault;
|
|
177
131
|
|
|
178
|
-
|
|
179
|
-
|
|
132
|
+
const ListItemTransactionContent = () => (
|
|
133
|
+
<>
|
|
134
|
+
<HStack
|
|
135
|
+
space={IOListItemLogoMargin}
|
|
136
|
+
style={{ alignItems: "center", flexShrink: 1 }}
|
|
137
|
+
>
|
|
180
138
|
{paymentLogoIcon && (
|
|
181
139
|
<View
|
|
182
140
|
style={{
|
|
183
|
-
marginRight: IOListItemLogoMargin,
|
|
184
141
|
width: MUNICIPALITY_LOGO_SIZE,
|
|
185
142
|
alignItems: "center"
|
|
186
143
|
}}
|
|
187
144
|
>
|
|
188
|
-
<
|
|
145
|
+
<StartComponent logoIcon={paymentLogoIcon} />
|
|
189
146
|
</View>
|
|
190
147
|
)}
|
|
191
|
-
<View style={
|
|
148
|
+
<View style={{ flexShrink: 1 }}>
|
|
192
149
|
<LabelSmall
|
|
193
150
|
numberOfLines={numberOfLines}
|
|
194
151
|
color={theme["textBody-default"]}
|
|
@@ -200,19 +157,29 @@ export const ListItemTransaction = ({
|
|
|
200
157
|
{subtitle}
|
|
201
158
|
</LabelSmall>
|
|
202
159
|
</View>
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
160
|
+
</HStack>
|
|
161
|
+
<HStack style={{ alignItems: "center" }}>
|
|
162
|
+
{badge ? (
|
|
163
|
+
<Badge variant={badge?.variant} text={badge?.text} />
|
|
164
|
+
) : (
|
|
165
|
+
<H6
|
|
166
|
+
accessibilityLabel={amountAccessibilityLabel}
|
|
167
|
+
color={showChevron ? interactiveColor : amountColor}
|
|
168
|
+
numberOfLines={numberOfLines}
|
|
169
|
+
>
|
|
170
|
+
{amount}
|
|
171
|
+
</H6>
|
|
172
|
+
)}
|
|
173
|
+
{showChevron && (
|
|
174
|
+
<Icon
|
|
175
|
+
name="chevronRightListItem"
|
|
176
|
+
color={interactiveColor}
|
|
177
|
+
size={IOListItemVisualParams.chevronSize}
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
180
|
+
</HStack>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
216
183
|
|
|
217
184
|
if (onPress) {
|
|
218
185
|
return (
|
|
@@ -232,7 +199,12 @@ export const ListItemTransaction = ({
|
|
|
232
199
|
accessible={accessible}
|
|
233
200
|
accessibilityLabel={accessibilityLabel}
|
|
234
201
|
>
|
|
235
|
-
<View
|
|
202
|
+
<View
|
|
203
|
+
style={[
|
|
204
|
+
IOListItemStyles.listItemInner,
|
|
205
|
+
{ columnGap: IOListItemVisualParams.iconMargin }
|
|
206
|
+
]}
|
|
207
|
+
>
|
|
236
208
|
<ListItemTransactionContent />
|
|
237
209
|
</View>
|
|
238
210
|
</View>
|
|
@@ -262,12 +234,3 @@ const SkeletonComponent = () => (
|
|
|
262
234
|
</View>
|
|
263
235
|
</View>
|
|
264
236
|
);
|
|
265
|
-
|
|
266
|
-
const Styles = StyleSheet.create({
|
|
267
|
-
rightSection: {
|
|
268
|
-
marginLeft: IOListItemVisualParams.iconMargin,
|
|
269
|
-
flexDirection: "row",
|
|
270
|
-
alignItems: "center",
|
|
271
|
-
height: "100%"
|
|
272
|
-
}
|
|
273
|
-
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Pressable } from "react-native";
|
|
3
3
|
import Animated from "react-native-reanimated";
|
|
4
|
-
import { IOListItemStyles } from "../../core";
|
|
4
|
+
import { IOListItemStyles, IOListItemVisualParams } from "../../core";
|
|
5
5
|
import { WithTestID } from "../../utils/types";
|
|
6
6
|
import { useListItemSpringAnimation } from "./hooks/useListItemSpringAnimation";
|
|
7
7
|
|
|
@@ -40,7 +40,11 @@ export const PressableListItemBase = ({
|
|
|
40
40
|
style={[IOListItemStyles.listItem, animatedBackgroundStyle]}
|
|
41
41
|
>
|
|
42
42
|
<Animated.View
|
|
43
|
-
style={[
|
|
43
|
+
style={[
|
|
44
|
+
IOListItemStyles.listItemInner,
|
|
45
|
+
{ columnGap: IOListItemVisualParams.iconMargin },
|
|
46
|
+
animatedScaleStyle
|
|
47
|
+
]}
|
|
44
48
|
>
|
|
45
49
|
{children}
|
|
46
50
|
</Animated.View>
|
|
@@ -920,6 +920,9 @@ exports[`Test List Item Components - Experimental Enabled ListItemRadioWithAmou
|
|
|
920
920
|
"flexDirection": "row",
|
|
921
921
|
"justifyContent": "space-between",
|
|
922
922
|
},
|
|
923
|
+
{
|
|
924
|
+
"columnGap": 12,
|
|
925
|
+
},
|
|
923
926
|
{
|
|
924
927
|
"transform": [
|
|
925
928
|
{
|
|
@@ -1069,13 +1072,6 @@ exports[`Test List Item Components - Experimental Enabled ListItemRadioWithAmou
|
|
|
1069
1072
|
}
|
|
1070
1073
|
}
|
|
1071
1074
|
>
|
|
1072
|
-
<View
|
|
1073
|
-
style={
|
|
1074
|
-
{
|
|
1075
|
-
"width": 8,
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
/>
|
|
1079
1075
|
<Text
|
|
1080
1076
|
allowFontScaling={true}
|
|
1081
1077
|
dynamicTypeRamp="headline"
|
|
@@ -1308,6 +1304,9 @@ exports[`Test List Item Components - Experimental Enabled ListItemRadioWithAmou
|
|
|
1308
1304
|
"flexDirection": "row",
|
|
1309
1305
|
"justifyContent": "space-between",
|
|
1310
1306
|
},
|
|
1307
|
+
{
|
|
1308
|
+
"columnGap": 12,
|
|
1309
|
+
},
|
|
1311
1310
|
{
|
|
1312
1311
|
"transform": [
|
|
1313
1312
|
{
|
|
@@ -1357,13 +1356,6 @@ exports[`Test List Item Components - Experimental Enabled ListItemRadioWithAmou
|
|
|
1357
1356
|
}
|
|
1358
1357
|
}
|
|
1359
1358
|
>
|
|
1360
|
-
<View
|
|
1361
|
-
style={
|
|
1362
|
-
{
|
|
1363
|
-
"width": 8,
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
/>
|
|
1367
1359
|
<Text
|
|
1368
1360
|
allowFontScaling={true}
|
|
1369
1361
|
dynamicTypeRamp="headline"
|
|
@@ -1678,6 +1670,9 @@ exports[`Test List Item Components - Experimental Enabled PressableListItemsBas
|
|
|
1678
1670
|
"flexDirection": "row",
|
|
1679
1671
|
"justifyContent": "space-between",
|
|
1680
1672
|
},
|
|
1673
|
+
{
|
|
1674
|
+
"columnGap": 12,
|
|
1675
|
+
},
|
|
1681
1676
|
{
|
|
1682
1677
|
"transform": [
|
|
1683
1678
|
{
|
|
@@ -2612,6 +2607,9 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 1`] = `
|
|
|
2612
2607
|
"flexDirection": "row",
|
|
2613
2608
|
"justifyContent": "space-between",
|
|
2614
2609
|
},
|
|
2610
|
+
{
|
|
2611
|
+
"columnGap": 12,
|
|
2612
|
+
},
|
|
2615
2613
|
{
|
|
2616
2614
|
"transform": [
|
|
2617
2615
|
{
|
|
@@ -2761,13 +2759,6 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 1`] = `
|
|
|
2761
2759
|
}
|
|
2762
2760
|
}
|
|
2763
2761
|
>
|
|
2764
|
-
<View
|
|
2765
|
-
style={
|
|
2766
|
-
{
|
|
2767
|
-
"width": 8,
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
/>
|
|
2771
2762
|
<Text
|
|
2772
2763
|
allowFontScaling={false}
|
|
2773
2764
|
dynamicTypeRamp="headline"
|
|
@@ -3000,6 +2991,9 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 2`] = `
|
|
|
3000
2991
|
"flexDirection": "row",
|
|
3001
2992
|
"justifyContent": "space-between",
|
|
3002
2993
|
},
|
|
2994
|
+
{
|
|
2995
|
+
"columnGap": 12,
|
|
2996
|
+
},
|
|
3003
2997
|
{
|
|
3004
2998
|
"transform": [
|
|
3005
2999
|
{
|
|
@@ -3049,13 +3043,6 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 2`] = `
|
|
|
3049
3043
|
}
|
|
3050
3044
|
}
|
|
3051
3045
|
>
|
|
3052
|
-
<View
|
|
3053
|
-
style={
|
|
3054
|
-
{
|
|
3055
|
-
"width": 8,
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
/>
|
|
3059
3046
|
<Text
|
|
3060
3047
|
allowFontScaling={false}
|
|
3061
3048
|
dynamicTypeRamp="headline"
|
|
@@ -3370,6 +3357,9 @@ exports[`Test List Item Components PressableListItemsBase Snapshot 1`] = `
|
|
|
3370
3357
|
"flexDirection": "row",
|
|
3371
3358
|
"justifyContent": "space-between",
|
|
3372
3359
|
},
|
|
3360
|
+
{
|
|
3361
|
+
"columnGap": 12,
|
|
3362
|
+
},
|
|
3373
3363
|
{
|
|
3374
3364
|
"transform": [
|
|
3375
3365
|
{
|
|
@@ -81,7 +81,6 @@ describe("Test List Item Components", () => {
|
|
|
81
81
|
title="TITLE"
|
|
82
82
|
subtitle="subtitle"
|
|
83
83
|
transaction={{
|
|
84
|
-
status: "success",
|
|
85
84
|
amount: "€ 1.000,00",
|
|
86
85
|
amountAccessibilityLabel: "€ 1.000,00"
|
|
87
86
|
}}
|
|
@@ -184,7 +183,6 @@ describe("Test List Item Components - Experimental Enabled ", () => {
|
|
|
184
183
|
title="TITLE"
|
|
185
184
|
subtitle="subtitle"
|
|
186
185
|
transaction={{
|
|
187
|
-
status: "success",
|
|
188
186
|
amount: "€ 1.000,00",
|
|
189
187
|
amountAccessibilityLabel: "€ 1.000,00"
|
|
190
188
|
}}
|