@pagopa/io-app-design-system 1.43.0 → 1.45.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 (110) hide show
  1. package/lib/commonjs/components/badge/Badge.js +4 -0
  2. package/lib/commonjs/components/badge/Badge.js.map +1 -1
  3. package/lib/commonjs/components/badge/__test__/__snapshots__/badge.test.tsx.snap +8 -0
  4. package/lib/commonjs/components/codeInput/CodeInput.js +6 -8
  5. package/lib/commonjs/components/codeInput/CodeInput.js.map +1 -1
  6. package/lib/commonjs/components/layout/HeaderSecondLevel.js +10 -6
  7. package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -1
  8. package/lib/commonjs/components/listitems/ListItemInfo.js +5 -7
  9. package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
  10. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -4
  11. package/lib/commonjs/components/modules/ModuleAttachment.js +17 -17
  12. package/lib/commonjs/components/modules/ModuleAttachment.js.map +1 -1
  13. package/lib/commonjs/components/modules/ModuleCheckout.js +35 -28
  14. package/lib/commonjs/components/modules/ModuleCheckout.js.map +1 -1
  15. package/lib/commonjs/components/modules/ModuleCredential.js +28 -22
  16. package/lib/commonjs/components/modules/ModuleCredential.js.map +1 -1
  17. package/lib/commonjs/components/modules/ModuleNavigation.js +30 -23
  18. package/lib/commonjs/components/modules/ModuleNavigation.js.map +1 -1
  19. package/lib/commonjs/components/modules/ModulePaymentNotice.js +17 -20
  20. package/lib/commonjs/components/modules/ModulePaymentNotice.js.map +1 -1
  21. package/lib/commonjs/components/modules/ModuleStatic.js +9 -2
  22. package/lib/commonjs/components/modules/ModuleStatic.js.map +1 -1
  23. package/lib/commonjs/components/numberpad/NumberPad.js +7 -8
  24. package/lib/commonjs/components/numberpad/NumberPad.js.map +1 -1
  25. package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +976 -987
  26. package/lib/commonjs/components/stack/Stack.js +4 -4
  27. package/lib/commonjs/components/stack/Stack.js.map +1 -1
  28. package/lib/commonjs/components/textInput/TextInputBase.js +2 -1
  29. package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
  30. package/lib/commonjs/components/textInput/TextInputValidation.js +20 -8
  31. package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
  32. package/lib/commonjs/components/toast/ToastProvider.js +7 -7
  33. package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
  34. package/lib/commonjs/core/IOAnimations.js +5 -0
  35. package/lib/commonjs/core/IOAnimations.js.map +1 -1
  36. package/lib/module/components/badge/Badge.js +4 -0
  37. package/lib/module/components/badge/Badge.js.map +1 -1
  38. package/lib/module/components/badge/__test__/__snapshots__/badge.test.tsx.snap +8 -0
  39. package/lib/module/components/codeInput/CodeInput.js +6 -8
  40. package/lib/module/components/codeInput/CodeInput.js.map +1 -1
  41. package/lib/module/components/layout/HeaderSecondLevel.js +13 -8
  42. package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -1
  43. package/lib/module/components/listitems/ListItemInfo.js +6 -8
  44. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  45. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -4
  46. package/lib/module/components/modules/ModuleAttachment.js +17 -17
  47. package/lib/module/components/modules/ModuleAttachment.js.map +1 -1
  48. package/lib/module/components/modules/ModuleCheckout.js +35 -28
  49. package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
  50. package/lib/module/components/modules/ModuleCredential.js +28 -22
  51. package/lib/module/components/modules/ModuleCredential.js.map +1 -1
  52. package/lib/module/components/modules/ModuleNavigation.js +30 -23
  53. package/lib/module/components/modules/ModuleNavigation.js.map +1 -1
  54. package/lib/module/components/modules/ModulePaymentNotice.js +18 -21
  55. package/lib/module/components/modules/ModulePaymentNotice.js.map +1 -1
  56. package/lib/module/components/modules/ModuleStatic.js +9 -2
  57. package/lib/module/components/modules/ModuleStatic.js.map +1 -1
  58. package/lib/module/components/numberpad/NumberPad.js +8 -9
  59. package/lib/module/components/numberpad/NumberPad.js.map +1 -1
  60. package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +976 -987
  61. package/lib/module/components/stack/Stack.js +4 -4
  62. package/lib/module/components/stack/Stack.js.map +1 -1
  63. package/lib/module/components/textInput/TextInputBase.js +2 -1
  64. package/lib/module/components/textInput/TextInputBase.js.map +1 -1
  65. package/lib/module/components/textInput/TextInputValidation.js +20 -8
  66. package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
  67. package/lib/module/components/toast/ToastProvider.js +7 -7
  68. package/lib/module/components/toast/ToastProvider.js.map +1 -1
  69. package/lib/module/core/IOAnimations.js +5 -0
  70. package/lib/module/core/IOAnimations.js.map +1 -1
  71. package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
  72. package/lib/typescript/components/codeInput/CodeInput.d.ts.map +1 -1
  73. package/lib/typescript/components/layout/HeaderSecondLevel.d.ts +11 -4
  74. package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
  75. package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
  76. package/lib/typescript/components/modules/ModuleAttachment.d.ts.map +1 -1
  77. package/lib/typescript/components/modules/ModuleCredential.d.ts.map +1 -1
  78. package/lib/typescript/components/modules/ModuleNavigation.d.ts.map +1 -1
  79. package/lib/typescript/components/modules/ModulePaymentNotice.d.ts.map +1 -1
  80. package/lib/typescript/components/modules/ModuleStatic.d.ts.map +1 -1
  81. package/lib/typescript/components/numberpad/NumberPad.d.ts.map +1 -1
  82. package/lib/typescript/components/stack/Stack.d.ts +4 -3
  83. package/lib/typescript/components/stack/Stack.d.ts.map +1 -1
  84. package/lib/typescript/components/textInput/TextInputBase.d.ts +2 -1
  85. package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
  86. package/lib/typescript/components/textInput/TextInputValidation.d.ts +13 -1
  87. package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
  88. package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
  89. package/lib/typescript/core/IOAnimations.d.ts +5 -0
  90. package/lib/typescript/core/IOAnimations.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/components/badge/Badge.tsx +4 -0
  93. package/src/components/badge/__test__/__snapshots__/badge.test.tsx.snap +8 -0
  94. package/src/components/codeInput/CodeInput.tsx +8 -16
  95. package/src/components/layout/HeaderSecondLevel.tsx +51 -8
  96. package/src/components/listitems/ListItemInfo.tsx +8 -16
  97. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -4
  98. package/src/components/modules/ModuleAttachment.tsx +14 -15
  99. package/src/components/modules/ModuleCheckout.tsx +34 -46
  100. package/src/components/modules/ModuleCredential.tsx +36 -32
  101. package/src/components/modules/ModuleNavigation.tsx +45 -32
  102. package/src/components/modules/ModulePaymentNotice.tsx +14 -24
  103. package/src/components/modules/ModuleStatic.tsx +6 -3
  104. package/src/components/numberpad/NumberPad.tsx +20 -18
  105. package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +976 -987
  106. package/src/components/stack/Stack.tsx +10 -5
  107. package/src/components/textInput/TextInputBase.tsx +3 -1
  108. package/src/components/textInput/TextInputValidation.tsx +37 -11
  109. package/src/components/toast/ToastProvider.tsx +8 -7
  110. package/src/core/IOAnimations.ts +5 -0
@@ -2,23 +2,28 @@ import React, { ReactNode } from "react";
2
2
  import { View, ViewStyle } from "react-native";
3
3
  import { IOSpacer } from "../../core";
4
4
 
5
+ type AllowedStyleProps = Pick<
6
+ ViewStyle,
7
+ "alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap"
8
+ >;
9
+
5
10
  type Stack = {
6
11
  space?: IOSpacer;
7
12
  children: ReactNode;
8
- alignItems?: ViewStyle["alignItems"];
13
+ style?: AllowedStyleProps;
9
14
  };
10
15
 
11
16
  /**
12
17
  Horizontal Stack component
13
18
  @param {IOSpacer} space
14
19
  */
15
- export const HStack = ({ space, children, alignItems }: Stack) => (
20
+ export const HStack = ({ space, children, style }: Stack) => (
16
21
  <View
17
22
  style={{
18
23
  display: "flex",
19
24
  flexDirection: "row",
20
25
  columnGap: space,
21
- alignItems
26
+ ...style
22
27
  }}
23
28
  >
24
29
  {children}
@@ -30,13 +35,13 @@ Vertical Stack component
30
35
  @param {IOSpacer} space
31
36
  */
32
37
 
33
- export const VStack = ({ space, children, alignItems }: Stack) => (
38
+ export const VStack = ({ space, children, style }: Stack) => (
34
39
  <View
35
40
  style={{
36
41
  display: "flex",
37
42
  flexDirection: "column",
38
43
  rowGap: space,
39
- alignItems
44
+ ...style
40
45
  }}
41
46
  >
42
47
  {children}
@@ -40,6 +40,7 @@ type InputTextProps = WithTestID<{
40
40
  value: string;
41
41
  onChangeText: (value: string) => void;
42
42
  accessibilityLabel?: string;
43
+ accessibilityHint?: string;
43
44
  textInputProps?: RNTextInputProps;
44
45
  inputType?: InputType;
45
46
  status?: InputStatus;
@@ -197,6 +198,7 @@ export const TextInputBase = ({
197
198
  value = "",
198
199
  onChangeText,
199
200
  accessibilityLabel,
201
+ accessibilityHint,
200
202
  textInputProps,
201
203
  inputType = "default",
202
204
  status,
@@ -355,7 +357,6 @@ export const TextInputBase = ({
355
357
  ]}
356
358
  accessible={false}
357
359
  accessibilityRole={"none"}
358
- accessibilityElementsHidden
359
360
  importantForAccessibility="no"
360
361
  >
361
362
  {/* Fake border managed with Animated.View to avoid
@@ -393,6 +394,7 @@ export const TextInputBase = ({
393
394
  disableFullscreenUI={true}
394
395
  accessibilityState={{ disabled }}
395
396
  accessibilityLabel={accessibilityLabel ?? placeholder}
397
+ accessibilityHint={accessibilityHint}
396
398
  selectionColor={IOColors[theme["interactiveElem-default"]]} // Caret on iOS
397
399
  cursorColor={IOColors[theme["interactiveElem-default"]]} // Caret Android
398
400
  maxLength={counterLimit}
@@ -11,14 +11,28 @@ import { triggerHaptic } from "../../functions";
11
11
  import { IOIconSizeScale, IOIcons, Icon } from "../icons";
12
12
  import { TextInputBase } from "./TextInputBase";
13
13
 
14
+ export type ValidationWithOptions = { isValid: boolean; errorMessage: string };
15
+
14
16
  type TextInputValidationProps = Omit<
15
17
  React.ComponentProps<typeof TextInputBase>,
16
18
  "rightElement" | "status" | "bottomMessageColor" | "isPassword"
17
19
  > & {
18
- onValidate: (value: string) => boolean;
20
+ /**
21
+ * This function can return either a `boolean` or a `ValidationWithOptions` object.
22
+ * If a `boolean` is returned and the field is not valid, the value of the errorMessage prop will be displayed/announced.
23
+ * If a `ValidationWithOptions` object is returned and the field is not valid, the value displayed/announced will be the one contained within this object.
24
+ */
25
+ onValidate: (value: string) => boolean | ValidationWithOptions;
26
+ /**
27
+ * In case of a dynamic `errorMessage`, use the `onValidate` function with a `ValidationWithOptions` object as the return value to ensure that screen readers announce the correct value.
28
+ */
19
29
  errorMessage: string;
20
30
  };
21
31
 
32
+ function isValidationWithOptions(validation: boolean | ValidationWithOptions): validation is ValidationWithOptions {
33
+ return typeof validation === 'object' && 'isValid' in validation && 'errorMessage' in validation;
34
+ }
35
+
22
36
  const feedbackIconSize: IOIconSizeScale = 24;
23
37
 
24
38
  export const TextInputValidation = ({
@@ -31,20 +45,32 @@ export const TextInputValidation = ({
31
45
  ...props
32
46
  }: TextInputValidationProps) => {
33
47
  const [isValid, setIsValid] = useState<boolean | undefined>(undefined);
48
+ const [errMessage, setErrMessage] = useState(errorMessage);
34
49
 
35
- const onBlurHandler = useCallback(() => {
36
- const validation = onValidate(value);
37
- setIsValid(validation);
38
- if (!validation) {
50
+ const getErrorFeedback = useCallback((isValid: boolean, message: string) => {
51
+ setIsValid(isValid);
52
+ setErrMessage(message);
53
+
54
+ if (!isValid) {
39
55
  triggerHaptic("notificationError");
40
- AccessibilityInfo.announceForAccessibilityWithOptions(errorMessage, {
56
+ AccessibilityInfo.announceForAccessibilityWithOptions(message, {
41
57
  queue: true
42
58
  });
43
59
  } else {
44
60
  triggerHaptic("notificationSuccess");
45
61
  }
62
+ }, []);
63
+
64
+ const onBlurHandler = useCallback(() => {
65
+ const validation = onValidate(value);
66
+
67
+ if (isValidationWithOptions(validation)) {
68
+ getErrorFeedback(validation.isValid, validation.errorMessage);
69
+ } else {
70
+ getErrorFeedback(validation, errorMessage);
71
+ }
46
72
  onBlur?.();
47
- }, [onValidate, value, onBlur, errorMessage]);
73
+ }, [value, errorMessage, onBlur, onValidate, getErrorFeedback]);
48
74
 
49
75
  const onFocusHandler = useCallback(() => {
50
76
  setIsValid(undefined);
@@ -52,13 +78,13 @@ export const TextInputValidation = ({
52
78
  }, [onFocus]);
53
79
 
54
80
  const labelError = useMemo(
55
- () => (isValid === false && errorMessage ? errorMessage : bottomMessage),
56
- [isValid, errorMessage, bottomMessage]
81
+ () => (isValid === false && errMessage ? errMessage : bottomMessage),
82
+ [isValid, errMessage, bottomMessage]
57
83
  );
58
84
 
59
85
  const labelErrorColor: IOColors | undefined = useMemo(
60
- () => (isValid === false && errorMessage ? "error-600" : undefined),
61
- [isValid, errorMessage]
86
+ () => (isValid === false && errMessage ? "error-600" : undefined),
87
+ [isValid, errMessage]
62
88
  );
63
89
 
64
90
  const feedbackIconAttrMap: Record<
@@ -12,6 +12,7 @@ import Animated, {
12
12
  SlideInUp,
13
13
  SlideOutUp
14
14
  } from "react-native-reanimated";
15
+ import { IOVisualCostants } from "../../core";
15
16
  import { triggerHaptic } from "../../functions";
16
17
  import { Dismissable } from "../layout/Dismissable";
17
18
  import { ToastNotification } from "./ToastNotification";
@@ -49,9 +50,9 @@ const ToastNotificationStackItem = ({
49
50
  ...toast
50
51
  }: ToastNotificationStackItemProps) => (
51
52
  <Animated.View
52
- entering={SlideInUp.duration(300).easing(Easing.inOut(Easing.exp))}
53
- exiting={SlideOutUp.duration(300).easing(Easing.inOut(Easing.exp))}
54
- layout={SequencedTransition.duration(300)}
53
+ entering={SlideInUp.springify().damping(16).mass(0.9).stiffness(90)}
54
+ exiting={SlideOutUp.duration(700).easing(Easing.inOut(Easing.exp))}
55
+ layout={SequencedTransition.duration(500).delay(50)}
55
56
  style={{ paddingBottom: 8 }}
56
57
  >
57
58
  <Dismissable onDismiss={onDismiss}>
@@ -119,7 +120,10 @@ export const ToastProvider = ({ children }: ToastProviderProps) => {
119
120
  <ToastContext.Provider value={contextValue as ToastContext}>
120
121
  <InitializeToastRef />
121
122
  <SafeAreaView style={styles.container} pointerEvents="box-none">
122
- <View style={styles.list} pointerEvents="box-none">
123
+ <View
124
+ style={{ padding: IOVisualCostants.appMarginDefault }}
125
+ pointerEvents="box-none"
126
+ >
123
127
  {toasts.map(toast => (
124
128
  <ToastNotificationStackItem
125
129
  key={toast.id}
@@ -150,8 +154,5 @@ const styles = StyleSheet.create({
150
154
  right: 0,
151
155
  top: 0,
152
156
  overflow: "visible"
153
- },
154
- list: {
155
- padding: 24
156
157
  }
157
158
  });
@@ -19,6 +19,11 @@ export const IOSpringValues = {
19
19
  damping: 10,
20
20
  mass: 0.5,
21
21
  stiffness: 200
22
+ },
23
+ header: {
24
+ damping: 10,
25
+ mass: 0.5,
26
+ stiffness: 200
22
27
  }
23
28
  };
24
29