@pagopa/io-app-design-system 7.1.1 → 7.2.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/index.js +0 -11
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +15 -8
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +6 -2
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/components/index.js +0 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +15 -8
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +7 -3
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/typescript/components/index.d.ts +0 -1
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts +8 -2
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/utils/types.d.ts +2 -0
- package/lib/typescript/utils/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/index.tsx +0 -1
- package/src/components/textInput/TextInputBase.tsx +22 -9
- package/src/components/textInput/TextInputValidation.tsx +11 -5
- package/src/utils/types.ts +5 -1
- package/lib/commonjs/components/claimsSelector/ClaimsSelector.js +0 -167
- package/lib/commonjs/components/claimsSelector/ClaimsSelector.js.map +0 -1
- package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js +0 -64
- package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js.map +0 -1
- package/lib/commonjs/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +0 -1918
- package/lib/commonjs/components/claimsSelector/index.js +0 -17
- package/lib/commonjs/components/claimsSelector/index.js.map +0 -1
- package/lib/module/components/claimsSelector/ClaimsSelector.js +0 -160
- package/lib/module/components/claimsSelector/ClaimsSelector.js.map +0 -1
- package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js +0 -64
- package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js.map +0 -1
- package/lib/module/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +0 -1918
- package/lib/module/components/claimsSelector/index.js +0 -4
- package/lib/module/components/claimsSelector/index.js.map +0 -1
- package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts +0 -48
- package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts.map +0 -1
- package/lib/typescript/components/claimsSelector/__test__/ClaimsSelector.test.d.ts +0 -2
- package/lib/typescript/components/claimsSelector/__test__/ClaimsSelector.test.d.ts.map +0 -1
- package/lib/typescript/components/claimsSelector/index.d.ts +0 -2
- package/lib/typescript/components/claimsSelector/index.d.ts.map +0 -1
- package/src/components/claimsSelector/ClaimsSelector.tsx +0 -231
- package/src/components/claimsSelector/__test__/ClaimsSelector.test.tsx +0 -72
- package/src/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +0 -1918
- package/src/components/claimsSelector/index.tsx +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/claimsSelector/index.tsx"],"mappings":";;AAAA,cAAc,kBAAkB","ignoreList":[]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ListItemInfo } from "../listitems";
|
|
2
|
-
type Props = {
|
|
3
|
-
/**
|
|
4
|
-
* The accordion title.
|
|
5
|
-
*/
|
|
6
|
-
title: string;
|
|
7
|
-
/**
|
|
8
|
-
* The list of items to display within the accordion.
|
|
9
|
-
*/
|
|
10
|
-
items: Array<Item>;
|
|
11
|
-
/**
|
|
12
|
-
* Enable the selection of items with a checkbox.
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
selectionEnabled?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The IDs of the selected items, when the component is controlled.
|
|
18
|
-
*/
|
|
19
|
-
selectedItemIds?: Array<string>;
|
|
20
|
-
/**
|
|
21
|
-
* Whether the accordion starts expanded.
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
defaultExpanded?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Function called when a item is selected.
|
|
27
|
-
*/
|
|
28
|
-
onItemSelected?: (item: Item, selected: boolean) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Function called when the accordion is toggled to collapsed or expanded state.
|
|
31
|
-
*/
|
|
32
|
-
onToggle?: (expanded: boolean) => void;
|
|
33
|
-
accessibilityLabel?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Accordion header gradient colors.
|
|
36
|
-
*/
|
|
37
|
-
headerGradientColors?: Array<string>;
|
|
38
|
-
};
|
|
39
|
-
type Item = {
|
|
40
|
-
id: string;
|
|
41
|
-
value: string;
|
|
42
|
-
description: string;
|
|
43
|
-
type?: "text" | "image";
|
|
44
|
-
endElement?: ListItemInfo["endElement"];
|
|
45
|
-
};
|
|
46
|
-
export declare const ClaimsSelector: ({ title, items, defaultExpanded, onItemSelected, onToggle, accessibilityLabel, selectedItemIds, selectionEnabled, headerGradientColors }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
-
export {};
|
|
48
|
-
//# sourceMappingURL=ClaimsSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClaimsSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/claimsSelector/ClaimsSelector.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAC;AAW9D,KAAK,KAAK,GAAG;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,KAAK,IAAI,GAAG;IACV,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,0IAU5B,KAAK,4CAoIP,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClaimsSelector.test.d.ts","sourceRoot":"","sources":["../../../../../src/components/claimsSelector/__test__/ClaimsSelector.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/claimsSelector/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { Fragment } from "react";
|
|
2
|
-
import { Image, StyleSheet, View } from "react-native";
|
|
3
|
-
import { TouchableWithoutFeedback } from "react-native-gesture-handler";
|
|
4
|
-
import LinearGradient from "react-native-linear-gradient";
|
|
5
|
-
import Animated, { useAnimatedStyle } from "react-native-reanimated";
|
|
6
|
-
import { useIOTheme } from "../../context";
|
|
7
|
-
import { IOAccordionRadius, IOColors, IOSpacingScale } from "../../core";
|
|
8
|
-
import { useAccordionAnimation } from "../../hooks/useAccordionAnimation";
|
|
9
|
-
import { Icon } from "../icons";
|
|
10
|
-
import { Divider } from "../layout";
|
|
11
|
-
import { ListItemCheckbox, ListItemInfo } from "../listitems";
|
|
12
|
-
import { H6 } from "../typography";
|
|
13
|
-
|
|
14
|
-
const accordionBodySpacing: IOSpacingScale = 16;
|
|
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
|
-
|
|
22
|
-
type Props = {
|
|
23
|
-
/**
|
|
24
|
-
* The accordion title.
|
|
25
|
-
*/
|
|
26
|
-
title: string;
|
|
27
|
-
/**
|
|
28
|
-
* The list of items to display within the accordion.
|
|
29
|
-
*/
|
|
30
|
-
items: Array<Item>;
|
|
31
|
-
/**
|
|
32
|
-
* Enable the selection of items with a checkbox.
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
|
-
selectionEnabled?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* The IDs of the selected items, when the component is controlled.
|
|
38
|
-
*/
|
|
39
|
-
selectedItemIds?: Array<string>;
|
|
40
|
-
/**
|
|
41
|
-
* Whether the accordion starts expanded.
|
|
42
|
-
* @default false
|
|
43
|
-
*/
|
|
44
|
-
defaultExpanded?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Function called when a item is selected.
|
|
47
|
-
*/
|
|
48
|
-
onItemSelected?: (item: Item, selected: boolean) => void;
|
|
49
|
-
/**
|
|
50
|
-
* Function called when the accordion is toggled to collapsed or expanded state.
|
|
51
|
-
*/
|
|
52
|
-
onToggle?: (expanded: boolean) => void;
|
|
53
|
-
accessibilityLabel?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Accordion header gradient colors.
|
|
56
|
-
*/
|
|
57
|
-
headerGradientColors?: Array<string>;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
type Item = {
|
|
61
|
-
id: string;
|
|
62
|
-
value: string;
|
|
63
|
-
description: string;
|
|
64
|
-
type?: "text" | "image";
|
|
65
|
-
endElement?: ListItemInfo["endElement"];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const ClaimsSelector = ({
|
|
69
|
-
title,
|
|
70
|
-
items,
|
|
71
|
-
defaultExpanded,
|
|
72
|
-
onItemSelected,
|
|
73
|
-
onToggle,
|
|
74
|
-
accessibilityLabel,
|
|
75
|
-
selectedItemIds,
|
|
76
|
-
selectionEnabled = true,
|
|
77
|
-
headerGradientColors
|
|
78
|
-
}: Props) => {
|
|
79
|
-
const theme = useIOTheme();
|
|
80
|
-
const {
|
|
81
|
-
expanded,
|
|
82
|
-
toggleAccordion,
|
|
83
|
-
onBodyLayout,
|
|
84
|
-
iconAnimatedStyle,
|
|
85
|
-
bodyAnimatedStyle,
|
|
86
|
-
bodyInnerStyle,
|
|
87
|
-
progress
|
|
88
|
-
} = useAccordionAnimation({
|
|
89
|
-
defaultExpanded
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const accordionBackground: IOColors = theme["appBackground-primary"];
|
|
93
|
-
const accordionBorder: IOColors = theme["cardBorder-default"];
|
|
94
|
-
|
|
95
|
-
const onItemPress = () => {
|
|
96
|
-
toggleAccordion();
|
|
97
|
-
onToggle?.(!expanded);
|
|
98
|
-
};
|
|
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
|
-
|
|
124
|
-
const renderClaimItem = (item: Item, index: number) => {
|
|
125
|
-
const { id, value, description, type = "text", endElement } = item;
|
|
126
|
-
return (
|
|
127
|
-
<Fragment key={id}>
|
|
128
|
-
{index !== 0 && <Divider />}
|
|
129
|
-
{
|
|
130
|
-
// We do not support checkbox selection for images, as it is not needed now
|
|
131
|
-
selectionEnabled && type === "text" ? (
|
|
132
|
-
<ListItemCheckbox
|
|
133
|
-
value={value}
|
|
134
|
-
description={description}
|
|
135
|
-
selected={selectedItemIds?.includes(id)}
|
|
136
|
-
onValueChange={
|
|
137
|
-
onItemSelected
|
|
138
|
-
? selected => onItemSelected(item, selected)
|
|
139
|
-
: undefined
|
|
140
|
-
}
|
|
141
|
-
/>
|
|
142
|
-
) : (
|
|
143
|
-
<ListItemInfo
|
|
144
|
-
value={
|
|
145
|
-
type === "image" ? (
|
|
146
|
-
<Image
|
|
147
|
-
source={{ uri: value }}
|
|
148
|
-
style={styles.imageClaim}
|
|
149
|
-
resizeMode="contain"
|
|
150
|
-
accessibilityIgnoresInvertColors
|
|
151
|
-
/>
|
|
152
|
-
) : (
|
|
153
|
-
value
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
label={description}
|
|
157
|
-
accessibilityRole={type}
|
|
158
|
-
reversed
|
|
159
|
-
endElement={endElement}
|
|
160
|
-
/>
|
|
161
|
-
)
|
|
162
|
-
}
|
|
163
|
-
</Fragment>
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<View
|
|
169
|
-
style={[
|
|
170
|
-
styles.accordionWrapper,
|
|
171
|
-
{
|
|
172
|
-
backgroundColor: IOColors[accordionBackground],
|
|
173
|
-
borderColor: IOColors[accordionBorder]
|
|
174
|
-
}
|
|
175
|
-
]}
|
|
176
|
-
>
|
|
177
|
-
<TouchableWithoutFeedback
|
|
178
|
-
accessible={true}
|
|
179
|
-
accessibilityRole="button"
|
|
180
|
-
accessibilityState={{ expanded }}
|
|
181
|
-
accessibilityLabel={accessibilityLabel ?? title}
|
|
182
|
-
onPress={onItemPress}
|
|
183
|
-
>
|
|
184
|
-
<Animated.View
|
|
185
|
-
style={[styles.textContainer, headerRadiusAnimatedStyle]}
|
|
186
|
-
>
|
|
187
|
-
{hasHeaderGradient && (
|
|
188
|
-
<LinearGradient
|
|
189
|
-
colors={headerGradientColors}
|
|
190
|
-
style={StyleSheet.absoluteFill}
|
|
191
|
-
/>
|
|
192
|
-
)}
|
|
193
|
-
<H6 color={headerForegroundColor}>{title}</H6>
|
|
194
|
-
<Animated.View style={iconAnimatedStyle}>
|
|
195
|
-
<Icon name="chevronBottom" color={headerForegroundColor} />
|
|
196
|
-
</Animated.View>
|
|
197
|
-
</Animated.View>
|
|
198
|
-
</TouchableWithoutFeedback>
|
|
199
|
-
|
|
200
|
-
<Animated.View style={bodyAnimatedStyle}>
|
|
201
|
-
<View
|
|
202
|
-
style={[bodyInnerStyle, styles.bodyInnerContainer]}
|
|
203
|
-
onLayout={onBodyLayout}
|
|
204
|
-
>
|
|
205
|
-
{items.map(renderClaimItem)}
|
|
206
|
-
</View>
|
|
207
|
-
</Animated.View>
|
|
208
|
-
</View>
|
|
209
|
-
);
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
const styles = StyleSheet.create({
|
|
213
|
-
accordionWrapper: {
|
|
214
|
-
borderWidth: 1,
|
|
215
|
-
borderRadius: IOAccordionRadius,
|
|
216
|
-
borderCurve: "continuous"
|
|
217
|
-
},
|
|
218
|
-
textContainer: {
|
|
219
|
-
padding: accordionBodySpacing,
|
|
220
|
-
flexDirection: "row",
|
|
221
|
-
alignItems: "center",
|
|
222
|
-
justifyContent: "space-between"
|
|
223
|
-
},
|
|
224
|
-
bodyInnerContainer: {
|
|
225
|
-
width: "100%"
|
|
226
|
-
},
|
|
227
|
-
imageClaim: {
|
|
228
|
-
width: 160,
|
|
229
|
-
aspectRatio: 3 / 4
|
|
230
|
-
}
|
|
231
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { render } from "@testing-library/react-native";
|
|
2
|
-
import { ClaimsSelector } from "../ClaimsSelector";
|
|
3
|
-
|
|
4
|
-
describe("ClaimsSelector", () => {
|
|
5
|
-
it("ClaimsSelector Snapshot (controlled)", () => {
|
|
6
|
-
const { toJSON } = render(
|
|
7
|
-
<ClaimsSelector
|
|
8
|
-
title="Patente di guida"
|
|
9
|
-
selectedItemIds={["name"]}
|
|
10
|
-
items={[
|
|
11
|
-
{
|
|
12
|
-
id: "name",
|
|
13
|
-
value: "Mario Rossi",
|
|
14
|
-
description: "Nome e cognome"
|
|
15
|
-
}
|
|
16
|
-
]}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
expect(toJSON()).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("ClaimsSelector Snapshot (uncontrolled)", () => {
|
|
23
|
-
const { toJSON } = render(
|
|
24
|
-
<ClaimsSelector
|
|
25
|
-
title="Patente di guida"
|
|
26
|
-
items={[
|
|
27
|
-
{
|
|
28
|
-
id: "name",
|
|
29
|
-
value: "Mario Rossi",
|
|
30
|
-
description: "Nome e cognome"
|
|
31
|
-
}
|
|
32
|
-
]}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
expect(toJSON()).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("ClaimsSelector Snapshot (unselectable items)", () => {
|
|
39
|
-
const { toJSON } = render(
|
|
40
|
-
<ClaimsSelector
|
|
41
|
-
title="Patente di guida"
|
|
42
|
-
selectionEnabled={false}
|
|
43
|
-
items={[
|
|
44
|
-
{
|
|
45
|
-
id: "name",
|
|
46
|
-
value: "Mario Rossi",
|
|
47
|
-
description: "Nome e cognome"
|
|
48
|
-
}
|
|
49
|
-
]}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
expect(toJSON()).toMatchSnapshot();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("ClaimsSelector Snapshot (custom component)", () => {
|
|
56
|
-
const { toJSON } = render(
|
|
57
|
-
<ClaimsSelector
|
|
58
|
-
title="Patente di guida"
|
|
59
|
-
selectionEnabled={false}
|
|
60
|
-
items={[
|
|
61
|
-
{
|
|
62
|
-
id: "name",
|
|
63
|
-
value: "data:image/png;base64,iVBORw0KGgoAAAANSUh",
|
|
64
|
-
description: "Nome e cognome",
|
|
65
|
-
type: "image"
|
|
66
|
-
}
|
|
67
|
-
]}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
expect(toJSON()).toMatchSnapshot();
|
|
71
|
-
});
|
|
72
|
-
});
|