@pagopa/io-app-design-system 4.5.5 → 4.6.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/banner/Banner.js +3 -2
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +56 -0
- 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 +8 -5
- 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 +8 -5
- package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/commonjs/components/switch/NativeSwitch.js +5 -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 +28 -6
- 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/module/components/accordion/AccordionItem.js +19 -52
- package/lib/module/components/accordion/AccordionItem.js.map +1 -1
- package/lib/module/components/banner/Banner.js +3 -2
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +56 -0
- 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 +9 -6
- package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js +6 -4
- 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 +9 -6
- package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/module/components/switch/NativeSwitch.js +6 -6
- 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 +28 -6
- 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/typescript/components/accordion/AccordionItem.d.ts +0 -6
- package/lib/typescript/components/accordion/AccordionItem.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.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/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 -13
- 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/package.json +1 -1
- package/src/components/accordion/AccordionItem.tsx +21 -82
- package/src/components/banner/Banner.tsx +3 -2
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +56 -0
- package/src/components/buttons/ButtonLink.tsx +1 -1
- package/src/components/buttons/ButtonSolid.tsx +1 -1
- package/src/components/checkbox/AnimatedCheckbox.tsx +9 -10
- package/src/components/checkbox/AnimatedMessageCheckbox.tsx +5 -5
- 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 +10 -10
- package/src/components/switch/NativeSwitch.tsx +6 -6
- 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 +33 -5
- package/src/core/IOStyles.ts +1 -28
- package/src/hooks/useAccordionAnimation.tsx +106 -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(() => {
|
|
@@ -239,6 +239,11 @@ exports[`Test List Item Components - Experimental Enabled ListItemInfo Snapshot
|
|
|
239
239
|
>
|
|
240
240
|
<View
|
|
241
241
|
accessible={true}
|
|
242
|
+
style={
|
|
243
|
+
{
|
|
244
|
+
"flexDirection": "column",
|
|
245
|
+
}
|
|
246
|
+
}
|
|
242
247
|
>
|
|
243
248
|
<Text
|
|
244
249
|
allowFontScaling={true}
|
|
@@ -1909,6 +1914,11 @@ exports[`Test List Item Components ListItemInfo Snapshot 1`] = `
|
|
|
1909
1914
|
>
|
|
1910
1915
|
<View
|
|
1911
1916
|
accessible={true}
|
|
1917
|
+
style={
|
|
1918
|
+
{
|
|
1919
|
+
"flexDirection": "column",
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1912
1922
|
>
|
|
1913
1923
|
<Text
|
|
1914
1924
|
allowFontScaling={true}
|
|
@@ -14,7 +14,7 @@ import Animated, {
|
|
|
14
14
|
withSpring,
|
|
15
15
|
withTiming
|
|
16
16
|
} from "react-native-reanimated";
|
|
17
|
-
import { useIOExperimentalDesign } from "../../core";
|
|
17
|
+
import { useIOExperimentalDesign, useIOTheme } from "../../core";
|
|
18
18
|
import { IOSpringValues } from "../../core/IOAnimations";
|
|
19
19
|
import { IOColors } from "../../core/IOColors";
|
|
20
20
|
import {
|
|
@@ -54,11 +54,12 @@ export const AnimatedRadio = ({
|
|
|
54
54
|
onPress,
|
|
55
55
|
disabled
|
|
56
56
|
}: OwnProps) => {
|
|
57
|
+
const theme = useIOTheme();
|
|
57
58
|
const isChecked = checked ?? false;
|
|
58
59
|
|
|
59
60
|
const { isExperimental } = useIOExperimentalDesign();
|
|
60
|
-
const borderColorOffState =
|
|
61
|
-
|
|
61
|
+
const borderColorOffState = IOColors[theme["selection-border-off"]];
|
|
62
|
+
|
|
62
63
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
63
64
|
const legacyBorderColorOffState =
|
|
64
65
|
IOColors[IOSelectionTickLegacyVisualParams.borderColorOffState];
|
|
@@ -66,12 +67,13 @@ export const AnimatedRadio = ({
|
|
|
66
67
|
? borderColorOffState
|
|
67
68
|
: legacyBorderColorOffState;
|
|
68
69
|
|
|
69
|
-
const backgroundColorOnState =
|
|
70
|
-
|
|
70
|
+
const backgroundColorOnState = IOColors[theme["selection-background-on"]];
|
|
71
|
+
|
|
71
72
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
72
73
|
const legacyBackgroundColorOnState =
|
|
73
74
|
IOColors[IOSelectionTickLegacyVisualParams.bgColorOnState];
|
|
74
|
-
|
|
75
|
+
|
|
76
|
+
const backgroundColor = isExperimental
|
|
75
77
|
? backgroundColorOnState
|
|
76
78
|
: legacyBackgroundColorOnState;
|
|
77
79
|
|
|
@@ -133,9 +135,7 @@ export const AnimatedRadio = ({
|
|
|
133
135
|
style={[
|
|
134
136
|
styles.radioCircle,
|
|
135
137
|
radioButtonSizeStyle,
|
|
136
|
-
{
|
|
137
|
-
backgroundColor: backgroundColorProp
|
|
138
|
-
},
|
|
138
|
+
{ backgroundColor },
|
|
139
139
|
animatedCheckboxSquare
|
|
140
140
|
]}
|
|
141
141
|
/>
|
|
@@ -144,7 +144,7 @@ export const AnimatedRadio = ({
|
|
|
144
144
|
<AnimatedTick
|
|
145
145
|
size={size}
|
|
146
146
|
progress={tickAnimationProgress}
|
|
147
|
-
stroke={IOColors[
|
|
147
|
+
stroke={IOColors[theme["selection-tick"]]}
|
|
148
148
|
/>
|
|
149
149
|
</View>
|
|
150
150
|
)}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Platform, Switch, SwitchProps } from "react-native";
|
|
3
|
-
import { useIOExperimentalDesign } from "../../core";
|
|
3
|
+
import { useIOExperimentalDesign, useIOTheme } from "../../core";
|
|
4
4
|
import { IOColors } from "../../core/IOColors";
|
|
5
|
-
import { IOSwitchVisualParams } from "../../core/IOStyles";
|
|
6
5
|
|
|
7
6
|
type OwnProps = Pick<
|
|
8
7
|
SwitchProps,
|
|
@@ -25,10 +24,11 @@ export const NativeSwitch = ({
|
|
|
25
24
|
value,
|
|
26
25
|
...accessibility
|
|
27
26
|
}: OwnProps) => {
|
|
27
|
+
const theme = useIOTheme();
|
|
28
28
|
const { isExperimental } = useIOExperimentalDesign();
|
|
29
29
|
const trackColor = {
|
|
30
|
-
false: IOColors[
|
|
31
|
-
true: IOColors[
|
|
30
|
+
false: IOColors[theme["switch-background-off"]],
|
|
31
|
+
true: IOColors[theme["switch-background-on"]]
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
@@ -45,10 +45,10 @@ export const NativeSwitch = ({
|
|
|
45
45
|
accessibilityRole="switch"
|
|
46
46
|
accessibilityState={{ checked: value, disabled: accessibility.disabled }}
|
|
47
47
|
trackColor={trackColorComponent}
|
|
48
|
-
thumbColor={IOColors[
|
|
48
|
+
thumbColor={IOColors[theme["switch-thumb-color"]]}
|
|
49
49
|
ios_backgroundColor={
|
|
50
50
|
isExperimental
|
|
51
|
-
? IOColors[
|
|
51
|
+
? IOColors[theme["switch-background-off"]]
|
|
52
52
|
: bgLegacyTrackColorAndroid
|
|
53
53
|
}
|
|
54
54
|
onValueChange={onValueChange}
|
|
@@ -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: isExperimental ? "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: isExperimental ? "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",
|
|
@@ -152,6 +153,8 @@ export const IOColorsTints = asIOColors({
|
|
|
152
153
|
"blueIO-850": IOColors["blueIO-850"],
|
|
153
154
|
"blueIO-600": IOColors["blueIO-600"],
|
|
154
155
|
"blueIO-500": IOColors["blueIO-500"],
|
|
156
|
+
"blueIO-400": IOColors["blueIO-400"],
|
|
157
|
+
"blueIO-300": IOColors["blueIO-300"],
|
|
155
158
|
"blueIO-200": IOColors["blueIO-200"],
|
|
156
159
|
"blueIO-150": IOColors["blueIO-150"],
|
|
157
160
|
"blueIO-100": IOColors["blueIO-100"],
|
|
@@ -227,6 +230,7 @@ const themeKeys = [
|
|
|
227
230
|
"neutralButton-pressed",
|
|
228
231
|
"neutralButton-disabled",
|
|
229
232
|
"buttonText-default",
|
|
233
|
+
"buttonText-danger",
|
|
230
234
|
"buttonText-disabled",
|
|
231
235
|
"listItem-pressed",
|
|
232
236
|
// Typography
|
|
@@ -246,6 +250,13 @@ const themeKeys = [
|
|
|
246
250
|
"textInputLabel-default",
|
|
247
251
|
"textInputValue-default",
|
|
248
252
|
"textInputValue-disabled",
|
|
253
|
+
// Selection (Radio, Checkbox, Switch)
|
|
254
|
+
"switch-background-off",
|
|
255
|
+
"switch-background-on",
|
|
256
|
+
"switch-thumb-color",
|
|
257
|
+
"selection-border-off",
|
|
258
|
+
"selection-background-on",
|
|
259
|
+
"selection-tick",
|
|
249
260
|
// Layout
|
|
250
261
|
"divider-header",
|
|
251
262
|
"divider-default",
|
|
@@ -289,6 +300,7 @@ export const IOThemeLight: IOTheme = {
|
|
|
289
300
|
"neutralButton-pressed": "grey-850",
|
|
290
301
|
"neutralButton-disabled": "grey-450",
|
|
291
302
|
"buttonText-default": "white",
|
|
303
|
+
"buttonText-danger": "white",
|
|
292
304
|
"buttonText-disabled": "grey-700",
|
|
293
305
|
"listItem-pressed": "grey-50",
|
|
294
306
|
// Typography
|
|
@@ -307,6 +319,13 @@ export const IOThemeLight: IOTheme = {
|
|
|
307
319
|
"textInputLabel-default": "grey-700",
|
|
308
320
|
"textInputValue-default": "black",
|
|
309
321
|
"textInputValue-disabled": "grey-850",
|
|
322
|
+
// Selection (Radio, Checkbox, Switch)
|
|
323
|
+
"switch-background-off": "grey-700",
|
|
324
|
+
"switch-background-on": "blueIO-500",
|
|
325
|
+
"switch-thumb-color": "white",
|
|
326
|
+
"selection-border-off": "grey-650",
|
|
327
|
+
"selection-background-on": "blueIO-500",
|
|
328
|
+
"selection-tick": "white",
|
|
310
329
|
// Layout
|
|
311
330
|
"divider-header": "grey-100",
|
|
312
331
|
"divider-default": "grey-200",
|
|
@@ -335,7 +354,8 @@ export const IOThemeLightLegacy: IOTheme = {
|
|
|
335
354
|
...IOThemeLight,
|
|
336
355
|
"appBackground-accent": "blue-500",
|
|
337
356
|
"interactiveElem-default": "blue-500",
|
|
338
|
-
"pictogram-hands": "blue-500"
|
|
357
|
+
"pictogram-hands": "blue-500",
|
|
358
|
+
"selection-tick": "white"
|
|
339
359
|
};
|
|
340
360
|
|
|
341
361
|
export const IOThemeDark: IOTheme = {
|
|
@@ -344,14 +364,15 @@ export const IOThemeDark: IOTheme = {
|
|
|
344
364
|
"appBackground-primary": "black",
|
|
345
365
|
"appBackground-secondary": "grey-850",
|
|
346
366
|
"appBackground-tertiary": "grey-700",
|
|
347
|
-
"interactiveElem-default": "blueIO-
|
|
348
|
-
"interactiveElem-pressed": "blueIO-
|
|
367
|
+
"interactiveElem-default": "blueIO-300",
|
|
368
|
+
"interactiveElem-pressed": "blueIO-400",
|
|
349
369
|
"interactiveElem-disabled": "grey-700",
|
|
350
370
|
"interactiveOutline-disabled": "grey-450",
|
|
351
371
|
"neutralButton-default": "white",
|
|
352
372
|
"neutralButton-pressed": "grey-100",
|
|
353
373
|
"neutralButton-disabled": "grey-850",
|
|
354
|
-
"buttonText-default": "
|
|
374
|
+
"buttonText-default": "black",
|
|
375
|
+
"buttonText-danger": "white",
|
|
355
376
|
"buttonText-disabled": "grey-300",
|
|
356
377
|
"listItem-pressed": "grey-850",
|
|
357
378
|
// Typography
|
|
@@ -360,7 +381,7 @@ export const IOThemeDark: IOTheme = {
|
|
|
360
381
|
"textHeading-tertiary": "grey-450",
|
|
361
382
|
"textBody-default": "white",
|
|
362
383
|
"textBody-secondary": "grey-100",
|
|
363
|
-
"textBody-tertiary": "grey-
|
|
384
|
+
"textBody-tertiary": "grey-300",
|
|
364
385
|
// Design System related
|
|
365
386
|
"cardBorder-default": "grey-850",
|
|
366
387
|
"icon-default": "grey-450",
|
|
@@ -370,6 +391,13 @@ export const IOThemeDark: IOTheme = {
|
|
|
370
391
|
"textInputLabel-default": "grey-450",
|
|
371
392
|
"textInputValue-default": "white",
|
|
372
393
|
"textInputValue-disabled": "grey-100",
|
|
394
|
+
// Selection (Radio, Checkbox, Switch)
|
|
395
|
+
"switch-background-off": "grey-850",
|
|
396
|
+
"switch-background-on": "blueIO-300",
|
|
397
|
+
"switch-thumb-color": "white",
|
|
398
|
+
"selection-border-off": "grey-450",
|
|
399
|
+
"selection-background-on": "blueIO-300",
|
|
400
|
+
"selection-tick": "black",
|
|
373
401
|
// Tab Item
|
|
374
402
|
"tab-item-border-default": "grey-700",
|
|
375
403
|
"tab-item-foreground-default": "grey-200",
|
package/src/core/IOStyles.ts
CHANGED
|
@@ -311,19 +311,6 @@ export const IOModuleStyles = StyleSheet.create({
|
|
|
311
311
|
interface IOSelectionTickVisualParams {
|
|
312
312
|
size: IOIconSizeScale;
|
|
313
313
|
borderWidth: number;
|
|
314
|
-
borderColorOffState: IOColors;
|
|
315
|
-
bgColorOnState: IOColors;
|
|
316
|
-
tickColor: IOColors;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
interface IOSwitchVisualParams {
|
|
320
|
-
width: number;
|
|
321
|
-
height: number;
|
|
322
|
-
bgColorOffState: IOColors;
|
|
323
|
-
bgColorOnState: IOColors;
|
|
324
|
-
tickColor: IOColors;
|
|
325
|
-
bgCircle: IOColors;
|
|
326
|
-
padding: number;
|
|
327
314
|
}
|
|
328
315
|
|
|
329
316
|
interface IOSelectionTickLegacyVisualParams {
|
|
@@ -333,21 +320,7 @@ interface IOSelectionTickLegacyVisualParams {
|
|
|
333
320
|
|
|
334
321
|
export const IOSelectionTickVisualParams: IOSelectionTickVisualParams = {
|
|
335
322
|
size: 24,
|
|
336
|
-
borderWidth: 2
|
|
337
|
-
borderColorOffState: "grey-650",
|
|
338
|
-
bgColorOnState: "blueIO-500",
|
|
339
|
-
tickColor: "white"
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
export const IOSwitchVisualParams: IOSwitchVisualParams = {
|
|
343
|
-
width: 40,
|
|
344
|
-
height: 28,
|
|
345
|
-
bgColorOffState: "grey-700",
|
|
346
|
-
bgColorOnState: "blueIO-500",
|
|
347
|
-
tickColor: "blueIO-500",
|
|
348
|
-
bgCircle: "white",
|
|
349
|
-
// Space between the circle and the main shape
|
|
350
|
-
padding: 2
|
|
323
|
+
borderWidth: 2
|
|
351
324
|
};
|
|
352
325
|
|
|
353
326
|
export const IOSelectionTickLegacyVisualParams: IOSelectionTickLegacyVisualParams =
|