@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.
- package/lib/commonjs/components/badge/Badge.js +4 -0
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/badge/__test__/__snapshots__/badge.test.tsx.snap +8 -0
- package/lib/commonjs/components/codeInput/CodeInput.js +6 -8
- package/lib/commonjs/components/codeInput/CodeInput.js.map +1 -1
- package/lib/commonjs/components/layout/HeaderSecondLevel.js +10 -6
- package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js +5 -7
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -4
- package/lib/commonjs/components/modules/ModuleAttachment.js +17 -17
- package/lib/commonjs/components/modules/ModuleAttachment.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleCheckout.js +35 -28
- package/lib/commonjs/components/modules/ModuleCheckout.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleCredential.js +28 -22
- package/lib/commonjs/components/modules/ModuleCredential.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleNavigation.js +30 -23
- package/lib/commonjs/components/modules/ModuleNavigation.js.map +1 -1
- package/lib/commonjs/components/modules/ModulePaymentNotice.js +17 -20
- package/lib/commonjs/components/modules/ModulePaymentNotice.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleStatic.js +9 -2
- package/lib/commonjs/components/modules/ModuleStatic.js.map +1 -1
- package/lib/commonjs/components/numberpad/NumberPad.js +7 -8
- package/lib/commonjs/components/numberpad/NumberPad.js.map +1 -1
- package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +976 -987
- package/lib/commonjs/components/stack/Stack.js +4 -4
- package/lib/commonjs/components/stack/Stack.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +2 -1
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +20 -8
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/components/toast/ToastProvider.js +7 -7
- package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
- package/lib/commonjs/core/IOAnimations.js +5 -0
- package/lib/commonjs/core/IOAnimations.js.map +1 -1
- package/lib/module/components/badge/Badge.js +4 -0
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/badge/__test__/__snapshots__/badge.test.tsx.snap +8 -0
- package/lib/module/components/codeInput/CodeInput.js +6 -8
- package/lib/module/components/codeInput/CodeInput.js.map +1 -1
- package/lib/module/components/layout/HeaderSecondLevel.js +13 -8
- package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfo.js +6 -8
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -4
- package/lib/module/components/modules/ModuleAttachment.js +17 -17
- package/lib/module/components/modules/ModuleAttachment.js.map +1 -1
- package/lib/module/components/modules/ModuleCheckout.js +35 -28
- package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
- package/lib/module/components/modules/ModuleCredential.js +28 -22
- package/lib/module/components/modules/ModuleCredential.js.map +1 -1
- package/lib/module/components/modules/ModuleNavigation.js +30 -23
- package/lib/module/components/modules/ModuleNavigation.js.map +1 -1
- package/lib/module/components/modules/ModulePaymentNotice.js +18 -21
- package/lib/module/components/modules/ModulePaymentNotice.js.map +1 -1
- package/lib/module/components/modules/ModuleStatic.js +9 -2
- package/lib/module/components/modules/ModuleStatic.js.map +1 -1
- package/lib/module/components/numberpad/NumberPad.js +8 -9
- package/lib/module/components/numberpad/NumberPad.js.map +1 -1
- package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +976 -987
- package/lib/module/components/stack/Stack.js +4 -4
- package/lib/module/components/stack/Stack.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +2 -1
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +20 -8
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/components/toast/ToastProvider.js +7 -7
- package/lib/module/components/toast/ToastProvider.js.map +1 -1
- package/lib/module/core/IOAnimations.js +5 -0
- package/lib/module/core/IOAnimations.js.map +1 -1
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/codeInput/CodeInput.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts +11 -4
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleAttachment.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleCredential.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleNavigation.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModulePaymentNotice.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleStatic.d.ts.map +1 -1
- package/lib/typescript/components/numberpad/NumberPad.d.ts.map +1 -1
- package/lib/typescript/components/stack/Stack.d.ts +4 -3
- package/lib/typescript/components/stack/Stack.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts +2 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +13 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
- package/lib/typescript/core/IOAnimations.d.ts +5 -0
- package/lib/typescript/core/IOAnimations.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/badge/Badge.tsx +4 -0
- package/src/components/badge/__test__/__snapshots__/badge.test.tsx.snap +8 -0
- package/src/components/codeInput/CodeInput.tsx +8 -16
- package/src/components/layout/HeaderSecondLevel.tsx +51 -8
- package/src/components/listitems/ListItemInfo.tsx +8 -16
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -4
- package/src/components/modules/ModuleAttachment.tsx +14 -15
- package/src/components/modules/ModuleCheckout.tsx +34 -46
- package/src/components/modules/ModuleCredential.tsx +36 -32
- package/src/components/modules/ModuleNavigation.tsx +45 -32
- package/src/components/modules/ModulePaymentNotice.tsx +14 -24
- package/src/components/modules/ModuleStatic.tsx +6 -3
- package/src/components/numberpad/NumberPad.tsx +20 -18
- package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +976 -987
- package/src/components/stack/Stack.tsx +10 -5
- package/src/components/textInput/TextInputBase.tsx +3 -1
- package/src/components/textInput/TextInputValidation.tsx +37 -11
- package/src/components/toast/ToastProvider.tsx +8 -7
- 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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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(
|
|
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
|
-
}, [
|
|
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 &&
|
|
56
|
-
[isValid,
|
|
81
|
+
() => (isValid === false && errMessage ? errMessage : bottomMessage),
|
|
82
|
+
[isValid, errMessage, bottomMessage]
|
|
57
83
|
);
|
|
58
84
|
|
|
59
85
|
const labelErrorColor: IOColors | undefined = useMemo(
|
|
60
|
-
() => (isValid === false &&
|
|
61
|
-
[isValid,
|
|
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.
|
|
53
|
-
exiting={SlideOutUp.duration(
|
|
54
|
-
layout={SequencedTransition.duration(
|
|
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
|
|
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
|
});
|