@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.
Files changed (181) hide show
  1. package/lib/commonjs/components/accordion/AccordionItem.js +20 -56
  2. package/lib/commonjs/components/accordion/AccordionItem.js.map +1 -1
  3. package/lib/commonjs/components/buttons/ButtonLink.js +1 -1
  4. package/lib/commonjs/components/buttons/ButtonSolid.js +1 -1
  5. package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
  6. package/lib/commonjs/components/checkbox/AnimatedCheckbox.js +6 -4
  7. package/lib/commonjs/components/checkbox/AnimatedCheckbox.js.map +1 -1
  8. package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js +4 -2
  9. package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js.map +1 -1
  10. package/lib/commonjs/components/claimsSelector/ClaimsSelector.js +119 -0
  11. package/lib/commonjs/components/claimsSelector/ClaimsSelector.js.map +1 -0
  12. package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js +46 -0
  13. package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js.map +1 -0
  14. package/lib/commonjs/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +1270 -0
  15. package/lib/commonjs/components/claimsSelector/index.js +17 -0
  16. package/lib/commonjs/components/claimsSelector/index.js.map +1 -0
  17. package/lib/commonjs/components/index.js +11 -0
  18. package/lib/commonjs/components/index.js.map +1 -1
  19. package/lib/commonjs/components/listitems/ListItemCheckbox.js +1 -1
  20. package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -1
  21. package/lib/commonjs/components/listitems/ListItemInfo.js +6 -2
  22. package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
  23. package/lib/commonjs/components/listitems/ListItemRadio.js +1 -1
  24. package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -1
  25. package/lib/commonjs/components/listitems/ListItemSwitch.js +1 -1
  26. package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
  27. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +10 -0
  28. package/lib/commonjs/components/radio/AnimatedRadio.js +5 -3
  29. package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
  30. package/lib/commonjs/components/switch/NativeSwitch.js +6 -5
  31. package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
  32. package/lib/commonjs/components/switch/index.js +0 -22
  33. package/lib/commonjs/components/switch/index.js.map +1 -1
  34. package/lib/commonjs/components/textInput/TextInputValidation.js +19 -7
  35. package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
  36. package/lib/commonjs/components/typography/markdown/MdH1.js +1 -2
  37. package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
  38. package/lib/commonjs/components/typography/markdown/MdH2.js +2 -2
  39. package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
  40. package/lib/commonjs/components/typography/markdown/MdH3.js +2 -2
  41. package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
  42. package/lib/commonjs/core/IOColors.js +26 -5
  43. package/lib/commonjs/core/IOColors.js.map +1 -1
  44. package/lib/commonjs/core/IOStyles.js +2 -16
  45. package/lib/commonjs/core/IOStyles.js.map +1 -1
  46. package/lib/commonjs/hooks/useAccordionAnimation.js +83 -0
  47. package/lib/commonjs/hooks/useAccordionAnimation.js.map +1 -0
  48. package/lib/commonjs/index.js +11 -0
  49. package/lib/commonjs/index.js.map +1 -1
  50. package/lib/module/components/accordion/AccordionItem.js +19 -52
  51. package/lib/module/components/accordion/AccordionItem.js.map +1 -1
  52. package/lib/module/components/buttons/ButtonLink.js +1 -1
  53. package/lib/module/components/buttons/ButtonSolid.js +1 -1
  54. package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
  55. package/lib/module/components/checkbox/AnimatedCheckbox.js +6 -4
  56. package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
  57. package/lib/module/components/checkbox/AnimatedMessageCheckbox.js +5 -3
  58. package/lib/module/components/checkbox/AnimatedMessageCheckbox.js.map +1 -1
  59. package/lib/module/components/claimsSelector/ClaimsSelector.js +109 -0
  60. package/lib/module/components/claimsSelector/ClaimsSelector.js.map +1 -0
  61. package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js +41 -0
  62. package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js.map +1 -0
  63. package/lib/module/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +1270 -0
  64. package/lib/module/components/claimsSelector/index.js +2 -0
  65. package/lib/module/components/claimsSelector/index.js.map +1 -0
  66. package/lib/module/components/index.js +1 -0
  67. package/lib/module/components/index.js.map +1 -1
  68. package/lib/module/components/listitems/ListItemCheckbox.js +1 -1
  69. package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -1
  70. package/lib/module/components/listitems/ListItemInfo.js +6 -2
  71. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  72. package/lib/module/components/listitems/ListItemRadio.js +1 -1
  73. package/lib/module/components/listitems/ListItemRadio.js.map +1 -1
  74. package/lib/module/components/listitems/ListItemSwitch.js +1 -1
  75. package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
  76. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +10 -0
  77. package/lib/module/components/radio/AnimatedRadio.js +5 -3
  78. package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
  79. package/lib/module/components/switch/NativeSwitch.js +6 -5
  80. package/lib/module/components/switch/NativeSwitch.js.map +1 -1
  81. package/lib/module/components/switch/index.js +0 -2
  82. package/lib/module/components/switch/index.js.map +1 -1
  83. package/lib/module/components/textInput/TextInputValidation.js +20 -8
  84. package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
  85. package/lib/module/components/typography/markdown/MdH1.js +1 -2
  86. package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
  87. package/lib/module/components/typography/markdown/MdH2.js +2 -2
  88. package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
  89. package/lib/module/components/typography/markdown/MdH3.js +2 -2
  90. package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
  91. package/lib/module/core/IOColors.js +26 -5
  92. package/lib/module/core/IOColors.js.map +1 -1
  93. package/lib/module/core/IOStyles.js +1 -14
  94. package/lib/module/core/IOStyles.js.map +1 -1
  95. package/lib/module/hooks/useAccordionAnimation.js +76 -0
  96. package/lib/module/hooks/useAccordionAnimation.js.map +1 -0
  97. package/lib/module/index.js +1 -0
  98. package/lib/module/index.js.map +1 -1
  99. package/lib/typescript/components/accordion/AccordionItem.d.ts +0 -6
  100. package/lib/typescript/components/accordion/AccordionItem.d.ts.map +1 -1
  101. package/lib/typescript/components/checkbox/AnimatedCheckbox.d.ts.map +1 -1
  102. package/lib/typescript/components/checkbox/AnimatedMessageCheckbox.d.ts.map +1 -1
  103. package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts +42 -0
  104. package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts.map +1 -0
  105. package/lib/typescript/components/claimsSelector/__test__/ClaimsSelector.test.d.ts +2 -0
  106. package/lib/typescript/components/claimsSelector/__test__/ClaimsSelector.test.d.ts.map +1 -0
  107. package/lib/typescript/components/claimsSelector/index.d.ts +2 -0
  108. package/lib/typescript/components/claimsSelector/index.d.ts.map +1 -0
  109. package/lib/typescript/components/index.d.ts +1 -0
  110. package/lib/typescript/components/index.d.ts.map +1 -1
  111. package/lib/typescript/components/listitems/ListItemInfo.d.ts +2 -1
  112. package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
  113. package/lib/typescript/components/radio/AnimatedRadio.d.ts.map +1 -1
  114. package/lib/typescript/components/switch/NativeSwitch.d.ts.map +1 -1
  115. package/lib/typescript/components/switch/index.d.ts +0 -2
  116. package/lib/typescript/components/switch/index.d.ts.map +1 -1
  117. package/lib/typescript/components/textInput/TextInputValidation.d.ts +31 -4
  118. package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
  119. package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
  120. package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
  121. package/lib/typescript/components/typography/Caption.d.ts +1 -1
  122. package/lib/typescript/components/typography/H1.d.ts +1 -1
  123. package/lib/typescript/components/typography/H2.d.ts +1 -1
  124. package/lib/typescript/components/typography/H3.d.ts +1 -1
  125. package/lib/typescript/components/typography/H4.d.ts +1 -1
  126. package/lib/typescript/components/typography/H5.d.ts +1 -1
  127. package/lib/typescript/components/typography/H6.d.ts +1 -1
  128. package/lib/typescript/components/typography/Hero.d.ts +1 -1
  129. package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
  130. package/lib/typescript/components/typography/markdown/MdH1.d.ts.map +1 -1
  131. package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
  132. package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
  133. package/lib/typescript/core/IOColors.d.ts +4 -1
  134. package/lib/typescript/core/IOColors.d.ts.map +1 -1
  135. package/lib/typescript/core/IOStyles.d.ts +0 -14
  136. package/lib/typescript/core/IOStyles.d.ts.map +1 -1
  137. package/lib/typescript/hooks/useAccordionAnimation.d.ts +41 -0
  138. package/lib/typescript/hooks/useAccordionAnimation.d.ts.map +1 -0
  139. package/lib/typescript/index.d.ts +1 -0
  140. package/lib/typescript/index.d.ts.map +1 -1
  141. package/package.json +1 -1
  142. package/src/components/accordion/AccordionItem.tsx +21 -82
  143. package/src/components/buttons/ButtonLink.tsx +1 -1
  144. package/src/components/buttons/ButtonSolid.tsx +1 -1
  145. package/src/components/checkbox/AnimatedCheckbox.tsx +6 -4
  146. package/src/components/checkbox/AnimatedMessageCheckbox.tsx +5 -6
  147. package/src/components/claimsSelector/ClaimsSelector.tsx +185 -0
  148. package/src/components/claimsSelector/__test__/ClaimsSelector.test.tsx +55 -0
  149. package/src/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +1270 -0
  150. package/src/components/claimsSelector/index.tsx +1 -0
  151. package/src/components/index.tsx +1 -0
  152. package/src/components/listitems/ListItemCheckbox.tsx +1 -1
  153. package/src/components/listitems/ListItemInfo.tsx +7 -2
  154. package/src/components/listitems/ListItemRadio.tsx +1 -1
  155. package/src/components/listitems/ListItemSwitch.tsx +1 -1
  156. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +10 -0
  157. package/src/components/radio/AnimatedRadio.tsx +5 -3
  158. package/src/components/switch/NativeSwitch.tsx +7 -5
  159. package/src/components/switch/index.tsx +0 -2
  160. package/src/components/textInput/TextInputValidation.tsx +140 -97
  161. package/src/components/typography/markdown/MdH1.tsx +1 -2
  162. package/src/components/typography/markdown/MdH2.tsx +2 -2
  163. package/src/components/typography/markdown/MdH3.tsx +2 -2
  164. package/src/core/IOColors.ts +31 -4
  165. package/src/core/IOStyles.ts +1 -28
  166. package/src/hooks/useAccordionAnimation.tsx +106 -0
  167. package/src/index.tsx +1 -0
  168. package/lib/commonjs/components/switch/AnimatedSwitch.js +0 -94
  169. package/lib/commonjs/components/switch/AnimatedSwitch.js.map +0 -1
  170. package/lib/commonjs/components/switch/SwitchLabel.js +0 -76
  171. package/lib/commonjs/components/switch/SwitchLabel.js.map +0 -1
  172. package/lib/module/components/switch/AnimatedSwitch.js +0 -85
  173. package/lib/module/components/switch/AnimatedSwitch.js.map +0 -1
  174. package/lib/module/components/switch/SwitchLabel.js +0 -68
  175. package/lib/module/components/switch/SwitchLabel.js.map +0 -1
  176. package/lib/typescript/components/switch/AnimatedSwitch.d.ts +0 -13
  177. package/lib/typescript/components/switch/AnimatedSwitch.d.ts.map +0 -1
  178. package/lib/typescript/components/switch/SwitchLabel.d.ts +0 -18
  179. package/lib/typescript/components/switch/SwitchLabel.d.ts.map +0 -1
  180. package/src/components/switch/AnimatedSwitch.tsx +0 -126
  181. package/src/components/switch/SwitchLabel.tsx +0 -80
@@ -0,0 +1 @@
1
+ export * from "./ClaimsSelector";
@@ -5,6 +5,7 @@ export * from "./badge";
5
5
  export * from "./banner";
6
6
  export * from "./buttons";
7
7
  export * from "./checkbox";
8
+ export * from "./claimsSelector";
8
9
  export * from "./codeInput";
9
10
  export * from "./contentWrapper";
10
11
  export * from "./divider";
@@ -119,7 +119,7 @@ export const ListItemCheckbox = ({
119
119
  <Icon
120
120
  allowFontScaling
121
121
  name={icon}
122
- color="grey-300"
122
+ color={theme["icon-decorative"]}
123
123
  size={IOSelectionListItemVisualParams.iconSize}
124
124
  />
125
125
  )}
@@ -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 accessible={Platform.OS === "ios"}>
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(() => {
@@ -198,7 +198,7 @@ export const ListItemRadio = ({
198
198
  <Icon
199
199
  allowFontScaling
200
200
  name={startImage.icon}
201
- color="grey-300"
201
+ color={theme["icon-decorative"]}
202
202
  size={IOSelectionListItemVisualParams.iconSize}
203
203
  />
204
204
  )}
@@ -115,7 +115,7 @@ export const ListItemSwitch = React.memo(
115
115
  <Icon
116
116
  allowFontScaling
117
117
  name={icon}
118
- color="grey-300"
118
+ color={theme["icon-decorative"]}
119
119
  size={IOSelectionListItemVisualParams.iconSize}
120
120
  />
121
121
  )}
@@ -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[IOSelectionTickVisualParams.borderColorOffState];
56
- const backgroundColor = IOColors[IOSelectionTickVisualParams.bgColorOnState];
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[IOSelectionTickVisualParams.tickColor]}
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[IOSwitchVisualParams.bgColorOffState],
25
- true: IOColors[IOSwitchVisualParams.bgColorOnState]
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[IOSwitchVisualParams.bgCircle]}
35
- ios_backgroundColor={IOColors[IOSwitchVisualParams.bgColorOffState]}
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,3 +1 @@
1
- export * from "./SwitchLabel";
2
- export * from "./AnimatedSwitch";
3
1
  export * from "./NativeSwitch";
@@ -1,5 +1,11 @@
1
1
  import * as React from "react";
2
- import { useCallback, useMemo, useState } from "react";
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
- onValidate,
47
- errorMessage,
48
- value,
49
- bottomMessage,
50
- onBlur,
51
- onFocus,
52
- ...props
53
- }: TextInputValidationProps) => {
54
- const theme = useIOTheme();
55
- const [isValid, setIsValid] = useState<boolean | undefined>(undefined);
56
- const [errMessage, setErrMessage] = useState(errorMessage);
57
-
58
- const getErrorFeedback = useCallback((isValid: boolean, message: string) => {
59
- setIsValid(isValid);
60
- setErrMessage(message);
61
-
62
- if (!isValid) {
63
- triggerHaptic("notificationError");
64
- AccessibilityInfo.announceForAccessibilityWithOptions(message, {
65
- queue: true
66
- });
67
- } else {
68
- triggerHaptic("notificationSuccess");
69
- }
70
- }, []);
71
-
72
- const onBlurHandler = useCallback(() => {
73
- const validation = onValidate(value);
74
-
75
- if (isValidationWithOptions(validation)) {
76
- getErrorFeedback(validation.isValid, validation.errorMessage);
77
- } else {
78
- getErrorFeedback(validation, errorMessage);
79
- }
80
- onBlur?.();
81
- }, [value, errorMessage, onBlur, onValidate, getErrorFeedback]);
82
-
83
- const onFocusHandler = useCallback(() => {
84
- setIsValid(undefined);
85
- onFocus?.();
86
- }, [onFocus]);
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
- const labelErrorColor: IOColors | undefined = useMemo(
94
- () => (isValid === false && errMessage ? theme.errorText : undefined),
95
- [isValid, errMessage, theme.errorText]
96
- );
103
+ const validateInput = useCallback(() => {
104
+ const validation = onValidate(value);
97
105
 
98
- const feedbackIconAttrMap: Record<
99
- string,
100
- { name: IOIcons; color: IOColors }
101
- > = useMemo(
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
- [theme]
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
- const feedbackIcon = useMemo(() => {
116
- const validationStatus = isValid ? "valid" : "notValid";
117
-
118
- return isValid !== undefined ? (
119
- <Animated.View
120
- entering={enterTransitionInputIcon}
121
- exiting={exitTransitionInputIcon}
122
- >
123
- <Icon
124
- name={feedbackIconAttrMap[validationStatus].name}
125
- color={feedbackIconAttrMap[validationStatus].color}
126
- size={feedbackIconSize}
127
- />
128
- </Animated.View>
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
- return (
135
- <TextInputBase
136
- {...props}
137
- value={value}
138
- status={isValid === false ? "error" : undefined}
139
- bottomMessage={labelError}
140
- bottomMessageColor={labelErrorColor}
141
- rightElement={feedbackIcon}
142
- onBlur={onBlurHandler}
143
- onFocus={onFocusHandler}
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-tertiary"]
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: 16,
18
+ size: 18,
19
19
  lineHeight: 24,
20
- color: customColor ?? theme["textHeading-tertiary"]
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: "Regular",
17
+ weight: "Semibold",
18
18
  size: 16,
19
19
  lineHeight: 24,
20
- color: customColor ?? theme["textHeading-tertiary"]
20
+ color: customColor ?? theme["textHeading-default"]
21
21
  };
22
22
 
23
23
  return (
@@ -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-400",
323
- "interactiveElem-pressed": "blueIO-500",
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": "white",
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-450",
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",
@@ -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 {