@pagopa/io-app-design-system 1.13.1 → 1.14.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/Banner.js +9 -8
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
- package/lib/commonjs/components/listitems/ListItemNav.js +9 -0
- package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemSwitch.js +28 -10
- package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
- package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js +3 -3
- package/lib/commonjs/components/switch/NativeSwitch.js +5 -3
- package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +6 -5
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/utils/textInput/index.js +2 -1
- package/lib/commonjs/utils/textInput/index.js.map +1 -1
- package/lib/module/components/banner/Banner.js +9 -8
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
- package/lib/module/components/listitems/ListItemNav.js +9 -0
- package/lib/module/components/listitems/ListItemNav.js.map +1 -1
- package/lib/module/components/listitems/ListItemSwitch.js +28 -11
- package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
- package/lib/module/components/loadingSpinner/LoadingSpinner.js +3 -3
- package/lib/module/components/switch/NativeSwitch.js +5 -3
- package/lib/module/components/switch/NativeSwitch.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +6 -5
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/utils/textInput/index.js +2 -1
- package/lib/module/utils/textInput/index.js.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNav.d.ts +14 -3
- package/lib/typescript/components/listitems/ListItemNav.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -1
- package/lib/typescript/components/switch/NativeSwitch.d.ts +2 -2
- package/lib/typescript/components/switch/NativeSwitch.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts +5 -5
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
- package/lib/typescript/utils/textInput/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/banner/Banner.tsx +9 -6
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
- package/src/components/listitems/ListItemNav.tsx +19 -5
- package/src/components/listitems/ListItemSwitch.tsx +37 -12
- package/src/components/loadingSpinner/LoadingSpinner.tsx +3 -3
- package/src/components/switch/NativeSwitch.tsx +10 -2
- package/src/components/textInput/TextInputBase.tsx +15 -9
- package/src/utils/textInput/index.ts +2 -1
|
@@ -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
|
-
|
|
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
|
|
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 && <
|
|
137
|
-
{
|
|
138
|
-
<NativeSwitch
|
|
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>
|
|
@@ -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:
|
|
24
|
-
76:
|
|
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 =
|
|
44
|
+
durationMs = 850,
|
|
45
45
|
accessibilityHint,
|
|
46
46
|
accessibilityLabel,
|
|
47
47
|
testID = "LoadingSpinnerTestID"
|
|
@@ -4,13 +4,20 @@ import { useIOExperimentalDesign } from "../../core";
|
|
|
4
4
|
import { IOColors } from "../../core/IOColors";
|
|
5
5
|
import { IOSwitchVisualParams } from "../../core/IOStyles";
|
|
6
6
|
|
|
7
|
-
type OwnProps = Pick<
|
|
7
|
+
type OwnProps = Pick<
|
|
8
|
+
SwitchProps,
|
|
9
|
+
"onValueChange" | "value" | "accessible" | "accessibilityLabel"
|
|
10
|
+
>;
|
|
8
11
|
|
|
9
12
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
10
13
|
const bgLegacyTrackColorAndroid =
|
|
11
14
|
Platform.OS === "android" ? IOColors["grey-300"] : IOColors.greyUltraLight;
|
|
12
15
|
|
|
13
|
-
export const NativeSwitch = ({
|
|
16
|
+
export const NativeSwitch = ({
|
|
17
|
+
onValueChange,
|
|
18
|
+
value,
|
|
19
|
+
...accessibility
|
|
20
|
+
}: OwnProps) => {
|
|
14
21
|
const { isExperimental } = useIOExperimentalDesign();
|
|
15
22
|
const trackColor = {
|
|
16
23
|
false: IOColors[IOSwitchVisualParams.bgColorOffState],
|
|
@@ -27,6 +34,7 @@ export const NativeSwitch = ({ onValueChange, value }: OwnProps) => {
|
|
|
27
34
|
|
|
28
35
|
return (
|
|
29
36
|
<Switch
|
|
37
|
+
{...accessibility}
|
|
30
38
|
trackColor={trackColorComponent}
|
|
31
39
|
thumbColor={IOColors[IOSwitchVisualParams.bgCircle]}
|
|
32
40
|
ios_backgroundColor={
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable functional/immutable-data */
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
3
|
import {
|
|
3
4
|
Pressable,
|
|
4
5
|
StyleSheet,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
View,
|
|
7
8
|
ViewStyle
|
|
8
9
|
} from "react-native";
|
|
9
|
-
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import Animated, {
|
|
11
11
|
Easing,
|
|
12
12
|
useAnimatedStyle,
|
|
@@ -19,18 +19,23 @@ import {
|
|
|
19
19
|
IOStyles,
|
|
20
20
|
useIOExperimentalDesign
|
|
21
21
|
} from "../../core";
|
|
22
|
+
import { makeFontStyleObject } from "../../utils/fonts";
|
|
23
|
+
import { getInputPropsByType } from "../../utils/textInput";
|
|
24
|
+
import { InputType } from "../../utils/types";
|
|
22
25
|
import { IOIcons, Icon } from "../icons";
|
|
23
26
|
import { HSpacer } from "../spacer";
|
|
24
27
|
import { LabelSmall } from "../typography";
|
|
25
|
-
import { InputType } from "../../utils/types";
|
|
26
|
-
import { getInputPropsByType } from "../../utils/textInput";
|
|
27
|
-
import { makeFontStyleObject } from "../../utils/fonts";
|
|
28
28
|
|
|
29
29
|
type InputStatus = "initial" | "focused" | "disabled" | "error";
|
|
30
30
|
|
|
31
31
|
type RNTextInputProps = Pick<
|
|
32
32
|
React.ComponentProps<typeof TextInput>,
|
|
33
|
-
|
|
33
|
+
| "keyboardType"
|
|
34
|
+
| "inputMode"
|
|
35
|
+
| "textContentType"
|
|
36
|
+
| "autoComplete"
|
|
37
|
+
| "returnKeyType"
|
|
38
|
+
| "autoCapitalize"
|
|
34
39
|
>;
|
|
35
40
|
|
|
36
41
|
type InputTextProps = {
|
|
@@ -39,7 +44,7 @@ type InputTextProps = {
|
|
|
39
44
|
onChangeText: (value: string) => void;
|
|
40
45
|
accessibilityLabel?: string;
|
|
41
46
|
textInputProps?: RNTextInputProps;
|
|
42
|
-
|
|
47
|
+
inputType?: InputType;
|
|
43
48
|
status?: InputStatus;
|
|
44
49
|
icon?: IOIcons;
|
|
45
50
|
rightElement?: React.ReactNode;
|
|
@@ -152,7 +157,7 @@ export const TextInputBase = ({
|
|
|
152
157
|
onChangeText,
|
|
153
158
|
accessibilityLabel,
|
|
154
159
|
textInputProps,
|
|
155
|
-
|
|
160
|
+
inputType = "default",
|
|
156
161
|
status,
|
|
157
162
|
icon,
|
|
158
163
|
rightElement,
|
|
@@ -248,8 +253,8 @@ export const TextInputBase = ({
|
|
|
248
253
|
}, [value, labelSharedValue, onBlur]);
|
|
249
254
|
|
|
250
255
|
const derivedInputProps = useMemo(
|
|
251
|
-
() => getInputPropsByType(
|
|
252
|
-
[
|
|
256
|
+
() => getInputPropsByType(inputType),
|
|
257
|
+
[inputType]
|
|
253
258
|
);
|
|
254
259
|
|
|
255
260
|
const inputValue = useMemo(
|
|
@@ -319,6 +324,7 @@ export const TextInputBase = ({
|
|
|
319
324
|
style={[
|
|
320
325
|
animatedLabelProps,
|
|
321
326
|
{
|
|
327
|
+
...makeFontStyleObject("Regular", false, "TitilliumWeb"),
|
|
322
328
|
color: IOColors["grey-700"]
|
|
323
329
|
}
|
|
324
330
|
]}
|