@pagopa/io-app-design-system 1.13.0 → 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/layout/HeaderFirstLevel.js +9 -6
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
- 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 +17 -5
- package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js.map +1 -1
- 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/layout/HeaderFirstLevel.js +9 -6
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
- 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 +17 -5
- package/lib/module/components/loadingSpinner/LoadingSpinner.js.map +1 -1
- 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/layout/HeaderFirstLevel.d.ts +2 -1
- package/lib/typescript/components/layout/HeaderFirstLevel.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/loadingSpinner/LoadingSpinner.d.ts +4 -4
- package/lib/typescript/components/loadingSpinner/LoadingSpinner.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/layout/HeaderFirstLevel.tsx +28 -6
- package/src/components/listitems/ListItemNav.tsx +19 -5
- package/src/components/listitems/ListItemSwitch.tsx +37 -12
- package/src/components/loadingSpinner/LoadingSpinner.tsx +78 -74
- package/src/components/switch/NativeSwitch.tsx +10 -2
- package/src/components/textInput/TextInputBase.tsx +15 -9
- package/src/utils/textInput/index.ts +2 -1
|
@@ -4,11 +4,12 @@ import Svg, { Defs, G, LinearGradient, Path, Stop } from "react-native-svg";
|
|
|
4
4
|
import { WithTestID } from "../../utils/types";
|
|
5
5
|
import { IOColors } from "../../core";
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
export type LoadingSpinner = WithTestID<{
|
|
8
8
|
color?: IOColors;
|
|
9
|
-
stroke?: number;
|
|
10
9
|
size?: IOLoadingSpinnerSizeScale;
|
|
11
10
|
durationMs?: number;
|
|
11
|
+
accessibilityLabel?: string;
|
|
12
|
+
accessibilityHint?: string;
|
|
12
13
|
}>;
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -17,6 +18,12 @@ type Props = WithTestID<{
|
|
|
17
18
|
*/
|
|
18
19
|
export type IOLoadingSpinnerSizeScale = 24 | 48 | 76;
|
|
19
20
|
|
|
21
|
+
const strokeMap: Record<NonNullable<LoadingSpinner["size"]>, number> = {
|
|
22
|
+
24: 3,
|
|
23
|
+
48: 5,
|
|
24
|
+
76: 7
|
|
25
|
+
};
|
|
26
|
+
|
|
20
27
|
const startRotationAnimation = (
|
|
21
28
|
durationMs: number,
|
|
22
29
|
rotationDegree: Animated.Value
|
|
@@ -33,89 +40,86 @@ const startRotationAnimation = (
|
|
|
33
40
|
|
|
34
41
|
export const LoadingSpinner = ({
|
|
35
42
|
color = "blueIO-500",
|
|
36
|
-
stroke = 3,
|
|
37
43
|
size = 24,
|
|
38
|
-
durationMs =
|
|
39
|
-
|
|
44
|
+
durationMs = 850,
|
|
45
|
+
accessibilityHint,
|
|
46
|
+
accessibilityLabel,
|
|
47
|
+
testID = "LoadingSpinnerTestID"
|
|
48
|
+
}: LoadingSpinner): React.ReactElement => {
|
|
40
49
|
const rotationDegree = useRef(new Animated.Value(0)).current;
|
|
50
|
+
const stroke: number = strokeMap[size];
|
|
41
51
|
|
|
42
52
|
useEffect(() => {
|
|
43
53
|
startRotationAnimation(durationMs, rotationDegree);
|
|
44
54
|
}, [durationMs, rotationDegree]);
|
|
45
55
|
|
|
46
56
|
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
<View
|
|
58
|
+
style={{ width: size, height: size }}
|
|
59
|
+
accessible={true}
|
|
60
|
+
accessibilityRole="progressbar"
|
|
61
|
+
accessibilityHint={accessibilityHint}
|
|
62
|
+
accessibilityLabel={accessibilityLabel}
|
|
63
|
+
importantForAccessibility={"no-hide-descendants"}
|
|
64
|
+
testID={testID}
|
|
65
|
+
>
|
|
66
|
+
<Animated.View
|
|
67
|
+
testID={"LoadingSpinnerAnimatedTestID"}
|
|
68
|
+
style={{
|
|
69
|
+
transform: [
|
|
70
|
+
{
|
|
71
|
+
rotateZ: rotationDegree.interpolate({
|
|
72
|
+
inputRange: [0, 360],
|
|
73
|
+
outputRange: ["0deg", "360deg"]
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}}
|
|
52
78
|
>
|
|
53
|
-
|
|
54
|
-
testID={"LoadingSpinnerAnimatedTestID"}
|
|
55
|
-
style={{
|
|
56
|
-
transform: [
|
|
57
|
-
{
|
|
58
|
-
rotateZ: rotationDegree.interpolate({
|
|
59
|
-
inputRange: [0, 360],
|
|
60
|
-
outputRange: ["0deg", "360deg"]
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
66
|
-
{/* Thanks to Ben Ilegbodu for the article on how to
|
|
79
|
+
{/* Thanks to Ben Ilegbodu for the article on how to
|
|
67
80
|
create a a SVG gradient loading spinner. Below is
|
|
68
|
-
a parameterized version of his
|
|
81
|
+
a parameterized version of his code.
|
|
69
82
|
Source: https://www.benmvp.com/blog/how-to-create-circle-svg-gradient-loading-spinner/ */}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<Stop offset="0%" stopOpacity="1" stopColor={IOColors[color]} />
|
|
87
|
-
<Stop
|
|
88
|
-
offset="100%"
|
|
89
|
-
stopOpacity="1"
|
|
90
|
-
stopColor={IOColors[color]}
|
|
91
|
-
/>
|
|
92
|
-
</LinearGradient>
|
|
93
|
-
</Defs>
|
|
83
|
+
<Svg
|
|
84
|
+
width={size}
|
|
85
|
+
height={size}
|
|
86
|
+
viewBox={`0 0 ${size} ${size}`}
|
|
87
|
+
fill="none"
|
|
88
|
+
>
|
|
89
|
+
<Defs>
|
|
90
|
+
<LinearGradient id="spinner-secondHalf">
|
|
91
|
+
<Stop offset="0%" stopOpacity="0" stopColor={IOColors[color]} />
|
|
92
|
+
<Stop offset="100%" stopOpacity="1" stopColor={IOColors[color]} />
|
|
93
|
+
</LinearGradient>
|
|
94
|
+
<LinearGradient id="spinner-firstHalf">
|
|
95
|
+
<Stop offset="0%" stopOpacity="1" stopColor={IOColors[color]} />
|
|
96
|
+
<Stop offset="100%" stopOpacity="1" stopColor={IOColors[color]} />
|
|
97
|
+
</LinearGradient>
|
|
98
|
+
</Defs>
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</>
|
|
100
|
+
<G strokeWidth={stroke}>
|
|
101
|
+
<Path
|
|
102
|
+
stroke="url(#spinner-secondHalf)"
|
|
103
|
+
d={`M ${stroke / 2} ${size / 2} A ${size / 2 - stroke / 2} ${
|
|
104
|
+
size / 2 - stroke / 2
|
|
105
|
+
} 0 0 1 ${size - stroke / 2} ${size / 2}`}
|
|
106
|
+
/>
|
|
107
|
+
<Path
|
|
108
|
+
stroke="url(#spinner-firstHalf)"
|
|
109
|
+
d={`M ${size - stroke / 2} ${size / 2} A ${
|
|
110
|
+
size / 2 - stroke / 2
|
|
111
|
+
} ${size / 2 - stroke / 2} 0 0 1 ${stroke / 2} ${size / 2}`}
|
|
112
|
+
/>
|
|
113
|
+
<Path
|
|
114
|
+
stroke={IOColors[color]}
|
|
115
|
+
strokeLinecap="round"
|
|
116
|
+
d={`M ${stroke / 2} ${size / 2} A ${size / 2 - stroke / 2} ${
|
|
117
|
+
size / 2 - stroke / 2
|
|
118
|
+
} 0 0 1 ${stroke / 2} ${size / 2 - stroke / 4}`}
|
|
119
|
+
/>
|
|
120
|
+
</G>
|
|
121
|
+
</Svg>
|
|
122
|
+
</Animated.View>
|
|
123
|
+
</View>
|
|
120
124
|
);
|
|
121
125
|
};
|
|
@@ -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
|
]}
|