@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.
Files changed (57) hide show
  1. package/lib/commonjs/components/banner/Banner.js +9 -8
  2. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  3. package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
  4. package/lib/commonjs/components/layout/HeaderFirstLevel.js +9 -6
  5. package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
  6. package/lib/commonjs/components/listitems/ListItemNav.js +9 -0
  7. package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
  8. package/lib/commonjs/components/listitems/ListItemSwitch.js +28 -10
  9. package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
  10. package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js +17 -5
  11. package/lib/commonjs/components/loadingSpinner/LoadingSpinner.js.map +1 -1
  12. package/lib/commonjs/components/switch/NativeSwitch.js +5 -3
  13. package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
  14. package/lib/commonjs/components/textInput/TextInputBase.js +6 -5
  15. package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
  16. package/lib/commonjs/utils/textInput/index.js +2 -1
  17. package/lib/commonjs/utils/textInput/index.js.map +1 -1
  18. package/lib/module/components/banner/Banner.js +9 -8
  19. package/lib/module/components/banner/Banner.js.map +1 -1
  20. package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
  21. package/lib/module/components/layout/HeaderFirstLevel.js +9 -6
  22. package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
  23. package/lib/module/components/listitems/ListItemNav.js +9 -0
  24. package/lib/module/components/listitems/ListItemNav.js.map +1 -1
  25. package/lib/module/components/listitems/ListItemSwitch.js +28 -11
  26. package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
  27. package/lib/module/components/loadingSpinner/LoadingSpinner.js +17 -5
  28. package/lib/module/components/loadingSpinner/LoadingSpinner.js.map +1 -1
  29. package/lib/module/components/switch/NativeSwitch.js +5 -3
  30. package/lib/module/components/switch/NativeSwitch.js.map +1 -1
  31. package/lib/module/components/textInput/TextInputBase.js +6 -5
  32. package/lib/module/components/textInput/TextInputBase.js.map +1 -1
  33. package/lib/module/utils/textInput/index.js +2 -1
  34. package/lib/module/utils/textInput/index.js.map +1 -1
  35. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  36. package/lib/typescript/components/layout/HeaderFirstLevel.d.ts +2 -1
  37. package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
  38. package/lib/typescript/components/listitems/ListItemNav.d.ts +14 -3
  39. package/lib/typescript/components/listitems/ListItemNav.d.ts.map +1 -1
  40. package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -1
  41. package/lib/typescript/components/loadingSpinner/LoadingSpinner.d.ts +4 -4
  42. package/lib/typescript/components/loadingSpinner/LoadingSpinner.d.ts.map +1 -1
  43. package/lib/typescript/components/switch/NativeSwitch.d.ts +2 -2
  44. package/lib/typescript/components/switch/NativeSwitch.d.ts.map +1 -1
  45. package/lib/typescript/components/textInput/TextInputBase.d.ts +5 -5
  46. package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
  47. package/lib/typescript/utils/textInput/index.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/src/components/banner/Banner.tsx +9 -6
  50. package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -2
  51. package/src/components/layout/HeaderFirstLevel.tsx +28 -6
  52. package/src/components/listitems/ListItemNav.tsx +19 -5
  53. package/src/components/listitems/ListItemSwitch.tsx +37 -12
  54. package/src/components/loadingSpinner/LoadingSpinner.tsx +78 -74
  55. package/src/components/switch/NativeSwitch.tsx +10 -2
  56. package/src/components/textInput/TextInputBase.tsx +15 -9
  57. 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 Props = WithTestID<{
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 = 750
39
- }: Props): React.ReactElement => {
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
- <View
49
- style={{ width: size, height: size }}
50
- accessibilityRole="progressbar"
51
- testID={"LoadingSpinnerTestID"}
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
- <Animated.View
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 version of his code.
81
+ a parameterized version of his code.
69
82
  Source: https://www.benmvp.com/blog/how-to-create-circle-svg-gradient-loading-spinner/ */}
70
- <Svg
71
- width={size}
72
- height={size}
73
- viewBox={`0 0 ${size} ${size}`}
74
- fill="none"
75
- >
76
- <Defs>
77
- <LinearGradient id="spinner-secondHalf">
78
- <Stop offset="0%" stopOpacity="0" stopColor={IOColors[color]} />
79
- <Stop
80
- offset="100%"
81
- stopOpacity="1"
82
- stopColor={IOColors[color]}
83
- />
84
- </LinearGradient>
85
- <LinearGradient id="spinner-firstHalf">
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
- <G strokeWidth={stroke}>
96
- <Path
97
- stroke="url(#spinner-secondHalf)"
98
- d={`M ${stroke / 2} ${size / 2} A ${size / 2 - stroke / 2} ${
99
- size / 2 - stroke / 2
100
- } 0 0 1 ${size - stroke / 2} ${size / 2}`}
101
- />
102
- <Path
103
- stroke="url(#spinner-firstHalf)"
104
- d={`M ${size - stroke / 2} ${size / 2} A ${
105
- size / 2 - stroke / 2
106
- } ${size / 2 - stroke / 2} 0 0 1 ${stroke / 2} ${size / 2}`}
107
- />
108
- <Path
109
- stroke={IOColors[color]}
110
- strokeLinecap="round"
111
- d={`M ${stroke / 2} ${size / 2} A ${size / 2 - stroke / 2} ${
112
- size / 2 - stroke / 2
113
- } 0 0 1 ${stroke / 2} ${size / 2 - stroke / 4}`}
114
- />
115
- </G>
116
- </Svg>
117
- </Animated.View>
118
- </View>
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<SwitchProps, "onValueChange" | "value">;
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 = ({ onValueChange, value }: OwnProps) => {
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
- "keyboardType" | "inputMode" | "textContentType" | "autoComplete"
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
- inputTyoe?: InputType;
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
- inputTyoe = "default",
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(inputTyoe),
252
- [inputTyoe]
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
  ]}
@@ -20,7 +20,8 @@ export const getInputPropsByType = (
20
20
  autoComplete: "cc-number",
21
21
  keyboardType: "numeric",
22
22
  textContentType: "creditCardNumber",
23
- inputMode: "numeric"
23
+ inputMode: "numeric",
24
+ returnKeyType: "done"
24
25
  }
25
26
  };
26
27
  default: