@pagopa/io-app-design-system 5.0.0-7 → 5.0.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/accordion/AccordionItem.js +20 -56
- package/lib/commonjs/components/accordion/AccordionItem.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js +6 -4
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js +4 -2
- package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js.map +1 -1
- package/lib/commonjs/components/claimsSelector/ClaimsSelector.js +119 -0
- package/lib/commonjs/components/claimsSelector/ClaimsSelector.js.map +1 -0
- package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js +46 -0
- package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js.map +1 -0
- package/lib/commonjs/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +1270 -0
- package/lib/commonjs/components/claimsSelector/index.js +17 -0
- package/lib/commonjs/components/claimsSelector/index.js.map +1 -0
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemCheckbox.js +1 -1
- package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js +6 -2
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemRadio.js +1 -1
- package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemSwitch.js +1 -1
- package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +10 -0
- package/lib/commonjs/components/radio/AnimatedRadio.js +5 -3
- package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/commonjs/components/switch/NativeSwitch.js +6 -5
- package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
- package/lib/commonjs/components/switch/index.js +0 -22
- package/lib/commonjs/components/switch/index.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +19 -7
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH1.js +1 -2
- package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH2.js +2 -2
- package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH3.js +2 -2
- package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +26 -5
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/core/IOStyles.js +2 -16
- package/lib/commonjs/core/IOStyles.js.map +1 -1
- package/lib/commonjs/hooks/useAccordionAnimation.js +83 -0
- package/lib/commonjs/hooks/useAccordionAnimation.js.map +1 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/accordion/AccordionItem.js +19 -52
- package/lib/module/components/accordion/AccordionItem.js.map +1 -1
- package/lib/module/components/buttons/ButtonLink.js +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +1 -1
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/checkbox/AnimatedCheckbox.js +6 -4
- package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js +5 -3
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js.map +1 -1
- package/lib/module/components/claimsSelector/ClaimsSelector.js +109 -0
- package/lib/module/components/claimsSelector/ClaimsSelector.js.map +1 -0
- package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js +41 -0
- package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js.map +1 -0
- package/lib/module/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +1270 -0
- package/lib/module/components/claimsSelector/index.js +2 -0
- package/lib/module/components/claimsSelector/index.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/listitems/ListItemCheckbox.js +1 -1
- package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfo.js +6 -2
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadio.js +1 -1
- package/lib/module/components/listitems/ListItemRadio.js.map +1 -1
- package/lib/module/components/listitems/ListItemSwitch.js +1 -1
- package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +10 -0
- package/lib/module/components/radio/AnimatedRadio.js +5 -3
- package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/module/components/switch/NativeSwitch.js +6 -5
- package/lib/module/components/switch/NativeSwitch.js.map +1 -1
- package/lib/module/components/switch/index.js +0 -2
- package/lib/module/components/switch/index.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/typography/markdown/MdH1.js +1 -2
- package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH2.js +2 -2
- package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH3.js +2 -2
- package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/module/core/IOColors.js +26 -5
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/core/IOStyles.js +1 -14
- package/lib/module/core/IOStyles.js.map +1 -1
- package/lib/module/hooks/useAccordionAnimation.js +76 -0
- package/lib/module/hooks/useAccordionAnimation.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/accordion/AccordionItem.d.ts +0 -6
- package/lib/typescript/components/accordion/AccordionItem.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedCheckbox.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedMessageCheckbox.d.ts.map +1 -1
- package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts +42 -0
- package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts.map +1 -0
- package/lib/typescript/components/claimsSelector/__test__/ClaimsSelector.test.d.ts +2 -0
- package/lib/typescript/components/claimsSelector/__test__/ClaimsSelector.test.d.ts.map +1 -0
- package/lib/typescript/components/claimsSelector/index.d.ts +2 -0
- package/lib/typescript/components/claimsSelector/index.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemInfo.d.ts +2 -1
- package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
- package/lib/typescript/components/radio/AnimatedRadio.d.ts.map +1 -1
- package/lib/typescript/components/switch/NativeSwitch.d.ts.map +1 -1
- package/lib/typescript/components/switch/index.d.ts +0 -2
- package/lib/typescript/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +31 -4
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +1 -1
- package/lib/typescript/components/typography/H1.d.ts +1 -1
- package/lib/typescript/components/typography/H2.d.ts +1 -1
- package/lib/typescript/components/typography/H3.d.ts +1 -1
- package/lib/typescript/components/typography/H4.d.ts +1 -1
- package/lib/typescript/components/typography/H5.d.ts +1 -1
- package/lib/typescript/components/typography/H6.d.ts +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
- package/lib/typescript/core/IOColors.d.ts +4 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/core/IOStyles.d.ts +0 -14
- package/lib/typescript/core/IOStyles.d.ts.map +1 -1
- package/lib/typescript/hooks/useAccordionAnimation.d.ts +41 -0
- package/lib/typescript/hooks/useAccordionAnimation.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/AccordionItem.tsx +21 -82
- package/src/components/buttons/ButtonLink.tsx +1 -1
- package/src/components/buttons/ButtonSolid.tsx +1 -1
- package/src/components/checkbox/AnimatedCheckbox.tsx +6 -4
- package/src/components/checkbox/AnimatedMessageCheckbox.tsx +5 -6
- package/src/components/claimsSelector/ClaimsSelector.tsx +185 -0
- package/src/components/claimsSelector/__test__/ClaimsSelector.test.tsx +55 -0
- package/src/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +1270 -0
- package/src/components/claimsSelector/index.tsx +1 -0
- package/src/components/index.tsx +1 -0
- package/src/components/listitems/ListItemCheckbox.tsx +1 -1
- package/src/components/listitems/ListItemInfo.tsx +7 -2
- package/src/components/listitems/ListItemRadio.tsx +1 -1
- package/src/components/listitems/ListItemSwitch.tsx +1 -1
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +10 -0
- package/src/components/radio/AnimatedRadio.tsx +5 -3
- package/src/components/switch/NativeSwitch.tsx +7 -5
- package/src/components/switch/index.tsx +0 -2
- package/src/components/textInput/TextInputValidation.tsx +140 -97
- package/src/components/typography/markdown/MdH1.tsx +1 -2
- package/src/components/typography/markdown/MdH2.tsx +2 -2
- package/src/components/typography/markdown/MdH3.tsx +2 -2
- package/src/core/IOColors.ts +31 -4
- package/src/core/IOStyles.ts +1 -28
- package/src/hooks/useAccordionAnimation.tsx +106 -0
- package/src/index.tsx +1 -0
- package/lib/commonjs/components/switch/AnimatedSwitch.js +0 -94
- package/lib/commonjs/components/switch/AnimatedSwitch.js.map +0 -1
- package/lib/commonjs/components/switch/SwitchLabel.js +0 -76
- package/lib/commonjs/components/switch/SwitchLabel.js.map +0 -1
- package/lib/module/components/switch/AnimatedSwitch.js +0 -85
- package/lib/module/components/switch/AnimatedSwitch.js.map +0 -1
- package/lib/module/components/switch/SwitchLabel.js +0 -68
- package/lib/module/components/switch/SwitchLabel.js.map +0 -1
- package/lib/typescript/components/switch/AnimatedSwitch.d.ts +0 -13
- package/lib/typescript/components/switch/AnimatedSwitch.d.ts.map +0 -1
- package/lib/typescript/components/switch/SwitchLabel.d.ts +0 -18
- package/lib/typescript/components/switch/SwitchLabel.d.ts.map +0 -1
- package/src/components/switch/AnimatedSwitch.tsx +0 -126
- package/src/components/switch/SwitchLabel.tsx +0 -80
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ClaimsSelector";
|
package/src/components/index.tsx
CHANGED
|
@@ -60,6 +60,7 @@ export type ListItemInfo = WithTestID<{
|
|
|
60
60
|
// Accessibility
|
|
61
61
|
accessibilityLabel?: string;
|
|
62
62
|
accessibilityRole?: AccessibilityRole;
|
|
63
|
+
reversed?: boolean;
|
|
63
64
|
}> &
|
|
64
65
|
GraphicProps &
|
|
65
66
|
InteractiveProps;
|
|
@@ -70,6 +71,7 @@ export const ListItemInfo = ({
|
|
|
70
71
|
label,
|
|
71
72
|
value,
|
|
72
73
|
numberOfLines = 2,
|
|
74
|
+
reversed = false,
|
|
73
75
|
icon,
|
|
74
76
|
paymentLogoIcon,
|
|
75
77
|
endElement,
|
|
@@ -99,7 +101,10 @@ export const ListItemInfo = ({
|
|
|
99
101
|
|
|
100
102
|
const itemInfoTextComponent = useMemo(
|
|
101
103
|
() => (
|
|
102
|
-
<View
|
|
104
|
+
<View
|
|
105
|
+
accessible={Platform.OS === "ios"}
|
|
106
|
+
style={{ flexDirection: reversed ? "column-reverse" : "column" }}
|
|
107
|
+
>
|
|
103
108
|
<BodySmall weight="Regular" color={theme["textBody-tertiary"]}>
|
|
104
109
|
{label}
|
|
105
110
|
</BodySmall>
|
|
@@ -112,7 +117,7 @@ export const ListItemInfo = ({
|
|
|
112
117
|
)}
|
|
113
118
|
</View>
|
|
114
119
|
),
|
|
115
|
-
[label, value, numberOfLines, theme]
|
|
120
|
+
[label, value, numberOfLines, theme, reversed]
|
|
116
121
|
);
|
|
117
122
|
|
|
118
123
|
const listItemInfoAction = useCallback(() => {
|
|
@@ -140,6 +140,11 @@ exports[`Test List Item Components - Experimental Enabled ListItemInfo Snapshot
|
|
|
140
140
|
>
|
|
141
141
|
<View
|
|
142
142
|
accessible={true}
|
|
143
|
+
style={
|
|
144
|
+
{
|
|
145
|
+
"flexDirection": "column",
|
|
146
|
+
}
|
|
147
|
+
}
|
|
143
148
|
>
|
|
144
149
|
<Text
|
|
145
150
|
allowFontScaling={true}
|
|
@@ -1711,6 +1716,11 @@ exports[`Test List Item Components ListItemInfo Snapshot 1`] = `
|
|
|
1711
1716
|
>
|
|
1712
1717
|
<View
|
|
1713
1718
|
accessible={true}
|
|
1719
|
+
style={
|
|
1720
|
+
{
|
|
1721
|
+
"flexDirection": "column",
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1714
1724
|
>
|
|
1715
1725
|
<Text
|
|
1716
1726
|
allowFontScaling={true}
|
|
@@ -14,6 +14,7 @@ import Animated, {
|
|
|
14
14
|
withSpring,
|
|
15
15
|
withTiming
|
|
16
16
|
} from "react-native-reanimated";
|
|
17
|
+
import { useIOTheme } from "../../core";
|
|
17
18
|
import { IOSpringValues } from "../../core/IOAnimations";
|
|
18
19
|
import { IOColors } from "../../core/IOColors";
|
|
19
20
|
import { IOSelectionTickVisualParams } from "../../core/IOStyles";
|
|
@@ -50,10 +51,11 @@ export const AnimatedRadio = ({
|
|
|
50
51
|
onPress,
|
|
51
52
|
disabled
|
|
52
53
|
}: OwnProps) => {
|
|
54
|
+
const theme = useIOTheme();
|
|
53
55
|
const isChecked = checked ?? false;
|
|
54
56
|
|
|
55
|
-
const borderColor = IOColors[
|
|
56
|
-
const backgroundColor = IOColors[
|
|
57
|
+
const borderColor = IOColors[theme["selection-border-off"]];
|
|
58
|
+
const backgroundColor = IOColors[theme["selection-background-on"]];
|
|
57
59
|
|
|
58
60
|
const circleAnimationProgress = useSharedValue(checked ? 1 : 0);
|
|
59
61
|
const tickAnimationProgress = useSharedValue(checked ? 1 : 0);
|
|
@@ -116,7 +118,7 @@ export const AnimatedRadio = ({
|
|
|
116
118
|
<AnimatedTick
|
|
117
119
|
size={size}
|
|
118
120
|
progress={tickAnimationProgress}
|
|
119
|
-
stroke={IOColors[
|
|
121
|
+
stroke={IOColors[theme["selection-tick"]]}
|
|
120
122
|
/>
|
|
121
123
|
</View>
|
|
122
124
|
)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Switch, SwitchProps } from "react-native";
|
|
3
|
+
import { useIOTheme } from "../../core";
|
|
3
4
|
import { IOColors } from "../../core/IOColors";
|
|
4
|
-
import { IOSwitchVisualParams } from "../../core/IOStyles";
|
|
5
5
|
|
|
6
6
|
type OwnProps = Pick<
|
|
7
7
|
SwitchProps,
|
|
@@ -20,9 +20,11 @@ export const NativeSwitch = ({
|
|
|
20
20
|
value,
|
|
21
21
|
...accessibility
|
|
22
22
|
}: OwnProps) => {
|
|
23
|
+
const theme = useIOTheme();
|
|
24
|
+
|
|
23
25
|
const trackColor = {
|
|
24
|
-
false: IOColors[
|
|
25
|
-
true: IOColors[
|
|
26
|
+
false: IOColors[theme["switch-background-off"]],
|
|
27
|
+
true: IOColors[theme["switch-background-on"]]
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
return (
|
|
@@ -31,8 +33,8 @@ export const NativeSwitch = ({
|
|
|
31
33
|
accessibilityRole="switch"
|
|
32
34
|
accessibilityState={{ checked: value, disabled: accessibility.disabled }}
|
|
33
35
|
trackColor={trackColor}
|
|
34
|
-
thumbColor={IOColors[
|
|
35
|
-
ios_backgroundColor={IOColors[
|
|
36
|
+
thumbColor={IOColors[theme["switch-thumb-color"]]}
|
|
37
|
+
ios_backgroundColor={IOColors[theme["switch-background-off"]]}
|
|
36
38
|
onValueChange={onValueChange}
|
|
37
39
|
value={value}
|
|
38
40
|
/>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useCallback,
|
|
4
|
+
useMemo,
|
|
5
|
+
useState,
|
|
6
|
+
forwardRef,
|
|
7
|
+
useImperativeHandle
|
|
8
|
+
} from "react";
|
|
3
9
|
import { AccessibilityInfo, View } from "react-native";
|
|
4
10
|
import Animated from "react-native-reanimated";
|
|
5
11
|
import { useIOTheme } from "../../core";
|
|
@@ -28,6 +34,14 @@ type TextInputValidationProps = Omit<
|
|
|
28
34
|
* 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.
|
|
29
35
|
*/
|
|
30
36
|
errorMessage: string;
|
|
37
|
+
/**
|
|
38
|
+
* Determines the validation mode. If "onBlur", validation occurs on blur. If "onContinue", validation occurs when an external button is pressed.
|
|
39
|
+
*/
|
|
40
|
+
validationMode?: "onBlur" | "onContinue";
|
|
41
|
+
/**
|
|
42
|
+
* A string that will be read by screen readers when the field is not valid.
|
|
43
|
+
*/
|
|
44
|
+
accessibilityErrorLabel?: string;
|
|
31
45
|
};
|
|
32
46
|
|
|
33
47
|
function isValidationWithOptions(
|
|
@@ -42,107 +56,136 @@ function isValidationWithOptions(
|
|
|
42
56
|
|
|
43
57
|
const feedbackIconSize: IOIconSizeScale = 24;
|
|
44
58
|
|
|
45
|
-
export const TextInputValidation =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const labelError = useMemo(
|
|
89
|
-
() => (isValid === false && errMessage ? errMessage : bottomMessage),
|
|
90
|
-
[isValid, errMessage, bottomMessage]
|
|
91
|
-
);
|
|
59
|
+
export const TextInputValidation = forwardRef<
|
|
60
|
+
{
|
|
61
|
+
validateInput: () => void;
|
|
62
|
+
},
|
|
63
|
+
TextInputValidationProps
|
|
64
|
+
>(
|
|
65
|
+
(
|
|
66
|
+
{
|
|
67
|
+
onValidate,
|
|
68
|
+
errorMessage,
|
|
69
|
+
value,
|
|
70
|
+
bottomMessage,
|
|
71
|
+
onBlur,
|
|
72
|
+
onFocus,
|
|
73
|
+
validationMode = "onBlur",
|
|
74
|
+
accessibilityErrorLabel,
|
|
75
|
+
...props
|
|
76
|
+
},
|
|
77
|
+
ref
|
|
78
|
+
) => {
|
|
79
|
+
const theme = useIOTheme();
|
|
80
|
+
const [isValid, setIsValid] = useState<boolean | undefined>(undefined);
|
|
81
|
+
const [errMessage, setErrMessage] = useState(errorMessage);
|
|
82
|
+
|
|
83
|
+
const getErrorFeedback = useCallback(
|
|
84
|
+
(isValid: boolean, message: string) => {
|
|
85
|
+
setIsValid(isValid);
|
|
86
|
+
setErrMessage(message);
|
|
87
|
+
|
|
88
|
+
if (!isValid) {
|
|
89
|
+
triggerHaptic("notificationError");
|
|
90
|
+
AccessibilityInfo.announceForAccessibilityWithOptions(
|
|
91
|
+
accessibilityErrorLabel ?? message,
|
|
92
|
+
{
|
|
93
|
+
queue: true
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
triggerHaptic("notificationSuccess");
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[accessibilityErrorLabel]
|
|
101
|
+
);
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
[isValid, errMessage, theme.errorText]
|
|
96
|
-
);
|
|
103
|
+
const validateInput = useCallback(() => {
|
|
104
|
+
const validation = onValidate(value);
|
|
97
105
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
() => ({
|
|
103
|
-
valid: {
|
|
104
|
-
name: "success",
|
|
105
|
-
color: theme.successIcon
|
|
106
|
-
},
|
|
107
|
-
notValid: {
|
|
108
|
-
name: "errorFilled",
|
|
109
|
-
color: theme.errorIcon
|
|
106
|
+
if (isValidationWithOptions(validation)) {
|
|
107
|
+
getErrorFeedback(validation.isValid, validation.errorMessage);
|
|
108
|
+
} else {
|
|
109
|
+
getErrorFeedback(validation, errorMessage);
|
|
110
110
|
}
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
}, [value, errorMessage, onValidate, getErrorFeedback]);
|
|
112
|
+
|
|
113
|
+
// Expose the validateInput function to the parent component
|
|
114
|
+
useImperativeHandle(ref, () => ({
|
|
115
|
+
validateInput
|
|
116
|
+
}));
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<View style={{ width: feedbackIconSize, height: feedbackIconSize }} />
|
|
118
|
+
const onBlurHandler = useCallback(() => {
|
|
119
|
+
if (validationMode === "onBlur") {
|
|
120
|
+
validateInput();
|
|
121
|
+
}
|
|
122
|
+
onBlur?.();
|
|
123
|
+
}, [validationMode, validateInput, onBlur]);
|
|
124
|
+
|
|
125
|
+
const onFocusHandler = useCallback(() => {
|
|
126
|
+
setIsValid(undefined);
|
|
127
|
+
onFocus?.();
|
|
128
|
+
}, [onFocus]);
|
|
129
|
+
|
|
130
|
+
const labelError = useMemo(
|
|
131
|
+
() => (isValid === false && errMessage ? errMessage : bottomMessage),
|
|
132
|
+
[isValid, errMessage, bottomMessage]
|
|
131
133
|
);
|
|
132
|
-
}, [feedbackIconAttrMap, isValid]);
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
const labelErrorColor: IOColors | undefined = useMemo(
|
|
136
|
+
() => (isValid === false && errMessage ? theme.errorText : undefined),
|
|
137
|
+
[isValid, errMessage, theme.errorText]
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const feedbackIconAttrMap: Record<
|
|
141
|
+
string,
|
|
142
|
+
{ name: IOIcons; color: IOColors }
|
|
143
|
+
> = useMemo(
|
|
144
|
+
() => ({
|
|
145
|
+
valid: {
|
|
146
|
+
name: "success",
|
|
147
|
+
color: theme.successIcon
|
|
148
|
+
},
|
|
149
|
+
notValid: {
|
|
150
|
+
name: "errorFilled",
|
|
151
|
+
color: theme.errorIcon
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
[theme]
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const feedbackIcon = useMemo(() => {
|
|
158
|
+
const validationStatus = isValid ? "valid" : "notValid";
|
|
159
|
+
|
|
160
|
+
return isValid !== undefined ? (
|
|
161
|
+
<Animated.View
|
|
162
|
+
entering={enterTransitionInputIcon}
|
|
163
|
+
exiting={exitTransitionInputIcon}
|
|
164
|
+
>
|
|
165
|
+
<Icon
|
|
166
|
+
name={feedbackIconAttrMap[validationStatus].name}
|
|
167
|
+
color={feedbackIconAttrMap[validationStatus].color}
|
|
168
|
+
size={feedbackIconSize}
|
|
169
|
+
/>
|
|
170
|
+
</Animated.View>
|
|
171
|
+
) : (
|
|
172
|
+
<View style={{ width: feedbackIconSize, height: feedbackIconSize }} />
|
|
173
|
+
);
|
|
174
|
+
}, [feedbackIconAttrMap, isValid]);
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<TextInputBase
|
|
178
|
+
{...props}
|
|
179
|
+
value={value}
|
|
180
|
+
status={isValid === false ? "error" : undefined}
|
|
181
|
+
bottomMessage={labelError}
|
|
182
|
+
bottomMessageColor={labelErrorColor}
|
|
183
|
+
rightElement={feedbackIcon}
|
|
184
|
+
onBlur={onBlurHandler}
|
|
185
|
+
onFocus={onFocusHandler}
|
|
186
|
+
/>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
);
|
|
147
190
|
|
|
148
191
|
export default TextInputValidation;
|
|
@@ -6,7 +6,6 @@ import { IOText, IOTextProps, TypographicStyleProps } from "../IOText";
|
|
|
6
6
|
/**
|
|
7
7
|
* `MdH1` typographic style
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
9
|
export const MdH1 = forwardRef<View, TypographicStyleProps>(
|
|
11
10
|
({ color: customColor, ...props }, ref?: ForwardedRef<View>) => {
|
|
12
11
|
const theme = useIOTheme();
|
|
@@ -18,7 +17,7 @@ export const MdH1 = forwardRef<View, TypographicStyleProps>(
|
|
|
18
17
|
weight: "Semibold",
|
|
19
18
|
size: 20,
|
|
20
19
|
lineHeight: 24,
|
|
21
|
-
color: customColor ?? theme["textHeading-
|
|
20
|
+
color: customColor ?? theme["textHeading-default"]
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
return (
|
|
@@ -15,9 +15,9 @@ export const MdH2 = forwardRef<View, TypographicStyleProps>(
|
|
|
15
15
|
...props,
|
|
16
16
|
font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
|
|
17
17
|
weight: "Semibold",
|
|
18
|
-
size:
|
|
18
|
+
size: 18,
|
|
19
19
|
lineHeight: 24,
|
|
20
|
-
color: customColor ?? theme["textHeading-
|
|
20
|
+
color: customColor ?? theme["textHeading-default"]
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
return (
|
|
@@ -14,10 +14,10 @@ export const MdH3 = forwardRef<View, TypographicStyleProps>(
|
|
|
14
14
|
const MdH3Props: IOTextProps = {
|
|
15
15
|
...props,
|
|
16
16
|
font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
|
|
17
|
-
weight: "
|
|
17
|
+
weight: "Semibold",
|
|
18
18
|
size: 16,
|
|
19
19
|
lineHeight: 24,
|
|
20
|
-
color: customColor ?? theme["textHeading-
|
|
20
|
+
color: customColor ?? theme["textHeading-default"]
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
return (
|
package/src/core/IOColors.ts
CHANGED
|
@@ -40,6 +40,7 @@ export const IOColors = asIOColors({
|
|
|
40
40
|
"blueIO-600": "#0932B6",
|
|
41
41
|
"blueIO-500": "#0B3EE3",
|
|
42
42
|
"blueIO-400": "#3C65E9",
|
|
43
|
+
"blueIO-300": "#6D8BEE",
|
|
43
44
|
"blueIO-200": "#9DB2F4",
|
|
44
45
|
"blueIO-150": "#B6C5F7",
|
|
45
46
|
"blueIO-100": "#CED8F9",
|
|
@@ -134,6 +135,8 @@ export const IOColorsTints = asIOColors({
|
|
|
134
135
|
"blueIO-850": IOColors["blueIO-850"],
|
|
135
136
|
"blueIO-600": IOColors["blueIO-600"],
|
|
136
137
|
"blueIO-500": IOColors["blueIO-500"],
|
|
138
|
+
"blueIO-400": IOColors["blueIO-400"],
|
|
139
|
+
"blueIO-300": IOColors["blueIO-300"],
|
|
137
140
|
"blueIO-200": IOColors["blueIO-200"],
|
|
138
141
|
"blueIO-150": IOColors["blueIO-150"],
|
|
139
142
|
"blueIO-100": IOColors["blueIO-100"],
|
|
@@ -209,6 +212,7 @@ const themeKeys = [
|
|
|
209
212
|
"neutralButton-pressed",
|
|
210
213
|
"neutralButton-disabled",
|
|
211
214
|
"buttonText-default",
|
|
215
|
+
"buttonText-danger",
|
|
212
216
|
"buttonText-disabled",
|
|
213
217
|
"listItem-pressed",
|
|
214
218
|
// Typography
|
|
@@ -228,6 +232,13 @@ const themeKeys = [
|
|
|
228
232
|
"textInputLabel-default",
|
|
229
233
|
"textInputValue-default",
|
|
230
234
|
"textInputValue-disabled",
|
|
235
|
+
// Selection (Radio, Checkbox, Switch)
|
|
236
|
+
"switch-background-off",
|
|
237
|
+
"switch-background-on",
|
|
238
|
+
"switch-thumb-color",
|
|
239
|
+
"selection-border-off",
|
|
240
|
+
"selection-background-on",
|
|
241
|
+
"selection-tick",
|
|
231
242
|
// Layout
|
|
232
243
|
"divider-header",
|
|
233
244
|
"divider-default",
|
|
@@ -271,6 +282,7 @@ export const IOThemeLight: IOTheme = {
|
|
|
271
282
|
"neutralButton-pressed": "grey-850",
|
|
272
283
|
"neutralButton-disabled": "grey-450",
|
|
273
284
|
"buttonText-default": "white",
|
|
285
|
+
"buttonText-danger": "white",
|
|
274
286
|
"buttonText-disabled": "grey-700",
|
|
275
287
|
"listItem-pressed": "grey-50",
|
|
276
288
|
// Typography
|
|
@@ -289,6 +301,13 @@ export const IOThemeLight: IOTheme = {
|
|
|
289
301
|
"textInputLabel-default": "grey-700",
|
|
290
302
|
"textInputValue-default": "black",
|
|
291
303
|
"textInputValue-disabled": "grey-850",
|
|
304
|
+
// Selection (Radio, Checkbox, Switch)
|
|
305
|
+
"switch-background-off": "grey-700",
|
|
306
|
+
"switch-background-on": "blueIO-500",
|
|
307
|
+
"switch-thumb-color": "white",
|
|
308
|
+
"selection-border-off": "grey-650",
|
|
309
|
+
"selection-background-on": "blueIO-500",
|
|
310
|
+
"selection-tick": "white",
|
|
292
311
|
// Layout
|
|
293
312
|
"divider-header": "grey-100",
|
|
294
313
|
"divider-default": "grey-200",
|
|
@@ -319,14 +338,15 @@ export const IOThemeDark: IOTheme = {
|
|
|
319
338
|
"appBackground-primary": "black",
|
|
320
339
|
"appBackground-secondary": "grey-850",
|
|
321
340
|
"appBackground-tertiary": "grey-700",
|
|
322
|
-
"interactiveElem-default": "blueIO-
|
|
323
|
-
"interactiveElem-pressed": "blueIO-
|
|
341
|
+
"interactiveElem-default": "blueIO-300",
|
|
342
|
+
"interactiveElem-pressed": "blueIO-400",
|
|
324
343
|
"interactiveElem-disabled": "grey-700",
|
|
325
344
|
"interactiveOutline-disabled": "grey-450",
|
|
326
345
|
"neutralButton-default": "white",
|
|
327
346
|
"neutralButton-pressed": "grey-100",
|
|
328
347
|
"neutralButton-disabled": "grey-850",
|
|
329
|
-
"buttonText-default": "
|
|
348
|
+
"buttonText-default": "black",
|
|
349
|
+
"buttonText-danger": "white",
|
|
330
350
|
"buttonText-disabled": "grey-300",
|
|
331
351
|
"listItem-pressed": "grey-850",
|
|
332
352
|
// Typography
|
|
@@ -335,7 +355,7 @@ export const IOThemeDark: IOTheme = {
|
|
|
335
355
|
"textHeading-tertiary": "grey-450",
|
|
336
356
|
"textBody-default": "white",
|
|
337
357
|
"textBody-secondary": "grey-100",
|
|
338
|
-
"textBody-tertiary": "grey-
|
|
358
|
+
"textBody-tertiary": "grey-300",
|
|
339
359
|
// Design System related
|
|
340
360
|
"cardBorder-default": "grey-850",
|
|
341
361
|
"icon-default": "grey-450",
|
|
@@ -345,6 +365,13 @@ export const IOThemeDark: IOTheme = {
|
|
|
345
365
|
"textInputLabel-default": "grey-450",
|
|
346
366
|
"textInputValue-default": "white",
|
|
347
367
|
"textInputValue-disabled": "grey-100",
|
|
368
|
+
// Selection (Radio, Checkbox, Switch)
|
|
369
|
+
"switch-background-off": "grey-850",
|
|
370
|
+
"switch-background-on": "blueIO-300",
|
|
371
|
+
"switch-thumb-color": "white",
|
|
372
|
+
"selection-border-off": "grey-450",
|
|
373
|
+
"selection-background-on": "blueIO-300",
|
|
374
|
+
"selection-tick": "black",
|
|
348
375
|
// Tab Item
|
|
349
376
|
"tab-item-border-default": "grey-700",
|
|
350
377
|
"tab-item-foreground-default": "grey-200",
|
package/src/core/IOStyles.ts
CHANGED
|
@@ -270,38 +270,11 @@ export const IOModuleStyles = StyleSheet.create({
|
|
|
270
270
|
interface IOSelectionTickVisualParams {
|
|
271
271
|
size: IOIconSizeScale;
|
|
272
272
|
borderWidth: number;
|
|
273
|
-
borderColorOffState: IOColors;
|
|
274
|
-
bgColorOnState: IOColors;
|
|
275
|
-
tickColor: IOColors;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
interface IOSwitchVisualParams {
|
|
279
|
-
width: number;
|
|
280
|
-
height: number;
|
|
281
|
-
bgColorOffState: IOColors;
|
|
282
|
-
bgColorOnState: IOColors;
|
|
283
|
-
tickColor: IOColors;
|
|
284
|
-
bgCircle: IOColors;
|
|
285
|
-
padding: number;
|
|
286
273
|
}
|
|
287
274
|
|
|
288
275
|
export const IOSelectionTickVisualParams: IOSelectionTickVisualParams = {
|
|
289
276
|
size: 24,
|
|
290
|
-
borderWidth: 2
|
|
291
|
-
borderColorOffState: "grey-650",
|
|
292
|
-
bgColorOnState: "blueIO-500",
|
|
293
|
-
tickColor: "white"
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
export const IOSwitchVisualParams: IOSwitchVisualParams = {
|
|
297
|
-
width: 40,
|
|
298
|
-
height: 28,
|
|
299
|
-
bgColorOffState: "grey-700",
|
|
300
|
-
bgColorOnState: "blueIO-500",
|
|
301
|
-
tickColor: "blueIO-500",
|
|
302
|
-
bgCircle: "white",
|
|
303
|
-
// Space between the circle and the main shape
|
|
304
|
-
padding: 2
|
|
277
|
+
borderWidth: 2
|
|
305
278
|
};
|
|
306
279
|
|
|
307
280
|
interface IOSelectionListItemVisualParams {
|