@pagopa/io-app-design-system 7.0.2 → 7.1.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/alert/Alert.js +6 -5
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +7 -6
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/buttons/IOButton/IOButton.js +10 -8
- package/lib/commonjs/components/buttons/IOButton/IOButton.js.map +1 -1
- package/lib/commonjs/components/layout/ContentWrapper.js +5 -4
- package/lib/commonjs/components/layout/ContentWrapper.js.map +1 -1
- package/lib/commonjs/components/otpInput/OTPInput.js +6 -4
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/searchInput/SearchInput.js +8 -6
- package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +6 -4
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +5 -3
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/components/typography/Body.js +8 -5
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/BodyMonospace.js +4 -5
- package/lib/commonjs/components/typography/BodyMonospace.js.map +1 -1
- package/lib/commonjs/components/typography/BodySmall.js +8 -5
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/commonjs/components/typography/ButtonText.js +4 -5
- package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
- package/lib/commonjs/components/typography/Caption.js +4 -5
- package/lib/commonjs/components/typography/Caption.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js +4 -5
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js +4 -5
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +4 -5
- package/lib/commonjs/components/typography/H3.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js +4 -5
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js +4 -5
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js +4 -5
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Hero.js +4 -5
- package/lib/commonjs/components/typography/Hero.js.map +1 -1
- package/lib/commonjs/components/typography/IOText.js +16 -14
- package/lib/commonjs/components/typography/IOText.js.map +1 -1
- package/lib/commonjs/components/typography/LabelMini.js +8 -5
- package/lib/commonjs/components/typography/LabelMini.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH1.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH2.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH3.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/commonjs/context/IOThemeContextProvider.js +3 -4
- package/lib/commonjs/context/IOThemeContextProvider.js.map +1 -1
- package/lib/module/components/alert/Alert.js +5 -5
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/banner/Banner.js +6 -6
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/buttons/IOButton/IOButton.js +10 -9
- package/lib/module/components/buttons/IOButton/IOButton.js.map +1 -1
- package/lib/module/components/layout/ContentWrapper.js +4 -4
- package/lib/module/components/layout/ContentWrapper.js.map +1 -1
- package/lib/module/components/otpInput/OTPInput.js +6 -5
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/searchInput/SearchInput.js +8 -7
- package/lib/module/components/searchInput/SearchInput.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +6 -5
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +5 -4
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/components/typography/Body.js +7 -5
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/BodyMonospace.js +3 -5
- package/lib/module/components/typography/BodyMonospace.js.map +1 -1
- package/lib/module/components/typography/BodySmall.js +7 -5
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/typography/ButtonText.js +3 -5
- package/lib/module/components/typography/ButtonText.js.map +1 -1
- package/lib/module/components/typography/Caption.js +3 -5
- package/lib/module/components/typography/Caption.js.map +1 -1
- package/lib/module/components/typography/H1.js +3 -5
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js +3 -5
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H3.js +3 -5
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/H4.js +3 -5
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js +3 -5
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js +3 -5
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Hero.js +3 -5
- package/lib/module/components/typography/Hero.js.map +1 -1
- package/lib/module/components/typography/IOText.js +16 -15
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/components/typography/LabelMini.js +7 -5
- package/lib/module/components/typography/LabelMini.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH1.js +3 -5
- package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH2.js +3 -5
- package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH3.js +3 -5
- package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/module/context/IOThemeContextProvider.js +3 -4
- package/lib/module/context/IOThemeContextProvider.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts +3 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts +3 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IOButton/IOButton.d.ts +3 -2
- package/lib/typescript/components/buttons/IOButton/IOButton.d.ts.map +1 -1
- package/lib/typescript/components/layout/ContentWrapper.d.ts +10 -6
- package/lib/typescript/components/layout/ContentWrapper.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts +3 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts +3 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
- package/lib/typescript/components/tabs/TabItem.d.ts +3 -11
- package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +7 -24
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts +4 -2
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +2 -8
- package/lib/typescript/components/typography/BodyMonospace.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts +4 -2
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts +2 -8
- package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +2 -8
- package/lib/typescript/components/typography/Caption.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts +2 -8
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts +6 -10
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H3.d.ts +2 -8
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts +2 -8
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts +2 -8
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts +2 -8
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +2 -8
- package/lib/typescript/components/typography/Hero.d.ts.map +1 -1
- package/lib/typescript/components/typography/IOText.d.ts +5 -5
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelMini.d.ts +4 -2
- package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH1.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH2.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH3.d.ts.map +1 -1
- package/lib/typescript/context/IOThemeContextProvider.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/components/alert/Alert.tsx +108 -112
- package/src/components/banner/Banner.tsx +121 -125
- package/src/components/buttons/IOButton/IOButton.tsx +204 -216
- package/src/components/layout/ContentWrapper.tsx +21 -24
- package/src/components/otpInput/OTPInput.tsx +156 -167
- package/src/components/searchInput/SearchInput.tsx +208 -217
- package/src/components/tabs/TabItem.tsx +143 -146
- package/src/components/textInput/TextInputValidation.tsx +116 -122
- package/src/components/typography/Body.tsx +51 -52
- package/src/components/typography/BodyMonospace.tsx +19 -24
- package/src/components/typography/BodySmall.tsx +51 -52
- package/src/components/typography/ButtonText.tsx +14 -20
- package/src/components/typography/Caption.tsx +18 -23
- package/src/components/typography/H1.tsx +12 -20
- package/src/components/typography/H2.tsx +16 -23
- package/src/components/typography/H3.tsx +12 -20
- package/src/components/typography/H4.tsx +12 -20
- package/src/components/typography/H5.tsx +16 -24
- package/src/components/typography/H6.tsx +13 -21
- package/src/components/typography/Hero.tsx +14 -19
- package/src/components/typography/IOText.tsx +54 -59
- package/src/components/typography/LabelMini.tsx +45 -49
- package/src/components/typography/markdown/MdH1.tsx +14 -19
- package/src/components/typography/markdown/MdH2.tsx +14 -19
- package/src/components/typography/markdown/MdH3.tsx +14 -19
- package/src/context/IOThemeContextProvider.tsx +4 -12
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRef,
|
|
3
|
-
forwardRef,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useRef,
|
|
7
|
-
useState
|
|
8
|
-
} from "react";
|
|
1
|
+
import { Ref, createRef, useEffect, useMemo, useRef, useState } from "react";
|
|
9
2
|
import {
|
|
10
3
|
AccessibilityInfo,
|
|
11
4
|
Platform,
|
|
@@ -26,6 +19,7 @@ import { BoxedInput } from "./BoxedInput";
|
|
|
26
19
|
const OTP_ITEMS_GAP = 8;
|
|
27
20
|
|
|
28
21
|
type Props = {
|
|
22
|
+
ref?: Ref<View>;
|
|
29
23
|
value: string;
|
|
30
24
|
onValueChange: (value: string) => void;
|
|
31
25
|
length: number;
|
|
@@ -57,175 +51,170 @@ type Props = {
|
|
|
57
51
|
* @param errorMessage - The error message to display
|
|
58
52
|
* @returns
|
|
59
53
|
*/
|
|
60
|
-
export const OTPInput =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
) => {
|
|
79
|
-
const [hasFocus, setHasFocus] = useState(autoFocus);
|
|
80
|
-
const [hasError, setHasError] = useState(false);
|
|
54
|
+
export const OTPInput = ({
|
|
55
|
+
value,
|
|
56
|
+
onValueChange,
|
|
57
|
+
length,
|
|
58
|
+
accessibilityLabel,
|
|
59
|
+
accessibilityHint,
|
|
60
|
+
accessibilityValueText,
|
|
61
|
+
onValidate,
|
|
62
|
+
errorMessage = "",
|
|
63
|
+
secret = false,
|
|
64
|
+
autocomplete = false,
|
|
65
|
+
inputAccessoryViewID,
|
|
66
|
+
autoFocus = false,
|
|
67
|
+
deleteButtonAccessibilityLabel,
|
|
68
|
+
ref
|
|
69
|
+
}: Props) => {
|
|
70
|
+
const [hasFocus, setHasFocus] = useState(autoFocus);
|
|
71
|
+
const [hasError, setHasError] = useState(false);
|
|
81
72
|
|
|
82
|
-
|
|
73
|
+
const theme = useIOTheme();
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
useErrorShakeAnimation();
|
|
75
|
+
const { translate, animatedStyle, shakeAnimation } = useErrorShakeAnimation();
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
const inputRef = createRef<TextInput>();
|
|
78
|
+
const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
const handleValidate = (val: string) => {
|
|
81
|
+
if (!onValidate || val.length < length) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const isValid = onValidate(val);
|
|
85
|
+
if (!isValid) {
|
|
86
|
+
setHasError(true);
|
|
87
|
+
triggerHaptic("notificationError");
|
|
88
|
+
// eslint-disable-next-line functional/immutable-data
|
|
89
|
+
translate.value = shakeAnimation();
|
|
100
90
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
// eslint-disable-next-line functional/immutable-data
|
|
105
|
-
timerRef.current = setTimeout(() => {
|
|
106
|
-
setHasError(false);
|
|
107
|
-
onValueChange("");
|
|
108
|
-
}, 500);
|
|
91
|
+
if (timerRef.current) {
|
|
92
|
+
clearTimeout(timerRef.current);
|
|
109
93
|
}
|
|
110
|
-
|
|
94
|
+
// eslint-disable-next-line functional/immutable-data
|
|
95
|
+
timerRef.current = setTimeout(() => {
|
|
96
|
+
setHasError(false);
|
|
97
|
+
onValueChange("");
|
|
98
|
+
}, 500);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
111
101
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
[]
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const handleChange = (value: string) => {
|
|
122
|
-
if (value.length > length) {
|
|
123
|
-
return;
|
|
102
|
+
useEffect(
|
|
103
|
+
() => () => {
|
|
104
|
+
if (timerRef.current) {
|
|
105
|
+
clearTimeout(timerRef.current);
|
|
124
106
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
},
|
|
108
|
+
[]
|
|
109
|
+
);
|
|
128
110
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
111
|
+
const handleChange = (value: string) => {
|
|
112
|
+
if (value.length > length) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
onValueChange(value);
|
|
116
|
+
handleValidate(value);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const handleKeyPress = (e: TextInputKeyPressEvent) => {
|
|
120
|
+
switch (e.nativeEvent.key) {
|
|
121
|
+
case "Backspace":
|
|
122
|
+
if (deleteButtonAccessibilityLabel && value.length > 0) {
|
|
123
|
+
AccessibilityInfo.announceForAccessibility(
|
|
124
|
+
deleteButtonAccessibilityLabel
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
AccessibilityInfo.announceForAccessibility(e.nativeEvent.key);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
143
133
|
|
|
144
|
-
|
|
134
|
+
const cells = useMemo(() => Array.from({ length }), [length]);
|
|
145
135
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
return (
|
|
137
|
+
<Animated.View style={[{ flexGrow: 1 }, animatedStyle]}>
|
|
138
|
+
<Pressable
|
|
139
|
+
onPress={() => {
|
|
140
|
+
inputRef.current?.focus();
|
|
141
|
+
setHasFocus(true);
|
|
142
|
+
}}
|
|
143
|
+
ref={ref}
|
|
144
|
+
accessible={false}
|
|
145
|
+
>
|
|
146
|
+
<TextInput
|
|
147
|
+
value={value}
|
|
148
|
+
onChangeText={handleChange}
|
|
149
|
+
onKeyPress={handleKeyPress}
|
|
150
|
+
caretHidden={Platform.OS === "ios"}
|
|
151
|
+
style={[
|
|
152
|
+
StyleSheet.absoluteFillObject,
|
|
153
|
+
Platform.select({
|
|
154
|
+
ios: { opacity: 0.01 },
|
|
155
|
+
android: { opacity: 0 }
|
|
156
|
+
})
|
|
157
|
+
]}
|
|
158
|
+
maxLength={length}
|
|
159
|
+
ref={inputRef}
|
|
160
|
+
onBlur={() => setHasFocus(false)}
|
|
161
|
+
keyboardType="numeric"
|
|
162
|
+
inputMode="numeric"
|
|
163
|
+
returnKeyType="done"
|
|
164
|
+
textContentType="oneTimeCode"
|
|
165
|
+
autoComplete={autocomplete ? "sms-otp" : undefined}
|
|
166
|
+
inputAccessoryViewID={inputAccessoryViewID}
|
|
167
|
+
accessible={true}
|
|
168
|
+
accessibilityLabel={accessibilityLabel}
|
|
169
|
+
accessibilityHint={accessibilityHint}
|
|
170
|
+
// Ensure the screen reader pronounces the code digit by digit
|
|
171
|
+
accessibilityValue={{
|
|
172
|
+
text:
|
|
173
|
+
accessibilityValueText?.({
|
|
174
|
+
valueLength: value.length,
|
|
175
|
+
length
|
|
176
|
+
}) ?? value.split("").join(" ")
|
|
152
177
|
}}
|
|
153
|
-
|
|
154
|
-
|
|
178
|
+
autoFocus={autoFocus}
|
|
179
|
+
secureTextEntry={secret}
|
|
180
|
+
/>
|
|
181
|
+
<View
|
|
182
|
+
style={{
|
|
183
|
+
flexDirection: "row",
|
|
184
|
+
justifyContent: "space-between",
|
|
185
|
+
columnGap: OTP_ITEMS_GAP,
|
|
186
|
+
flexGrow: 1,
|
|
187
|
+
zIndex: 10
|
|
188
|
+
}}
|
|
189
|
+
accessibilityElementsHidden={true}
|
|
190
|
+
importantForAccessibility="no-hide-descendants"
|
|
191
|
+
>
|
|
192
|
+
{cells.map((_, i) => (
|
|
193
|
+
<BoxedInput
|
|
194
|
+
key={i}
|
|
195
|
+
status={
|
|
196
|
+
hasError
|
|
197
|
+
? "error"
|
|
198
|
+
: hasFocus && value.length === i
|
|
199
|
+
? "focus"
|
|
200
|
+
: "default"
|
|
201
|
+
}
|
|
202
|
+
secret={secret}
|
|
203
|
+
value={value[i]}
|
|
204
|
+
/>
|
|
205
|
+
))}
|
|
206
|
+
</View>
|
|
207
|
+
</Pressable>
|
|
208
|
+
<VSpacer size={4} />
|
|
209
|
+
{hasError && errorMessage && (
|
|
210
|
+
<BodySmall
|
|
211
|
+
weight="Semibold"
|
|
212
|
+
color={theme.errorText}
|
|
213
|
+
style={{ textAlign: "center" }}
|
|
155
214
|
>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
StyleSheet.absoluteFillObject,
|
|
163
|
-
Platform.select({
|
|
164
|
-
ios: { opacity: 0.01 },
|
|
165
|
-
android: { opacity: 0 }
|
|
166
|
-
})
|
|
167
|
-
]}
|
|
168
|
-
maxLength={length}
|
|
169
|
-
ref={inputRef}
|
|
170
|
-
onBlur={() => setHasFocus(false)}
|
|
171
|
-
keyboardType="numeric"
|
|
172
|
-
inputMode="numeric"
|
|
173
|
-
returnKeyType="done"
|
|
174
|
-
textContentType="oneTimeCode"
|
|
175
|
-
autoComplete={autocomplete ? "sms-otp" : undefined}
|
|
176
|
-
inputAccessoryViewID={inputAccessoryViewID}
|
|
177
|
-
accessible={true}
|
|
178
|
-
accessibilityLabel={accessibilityLabel}
|
|
179
|
-
accessibilityHint={accessibilityHint}
|
|
180
|
-
// Ensure the screen reader pronounces the code digit by digit
|
|
181
|
-
accessibilityValue={{
|
|
182
|
-
text:
|
|
183
|
-
accessibilityValueText?.({
|
|
184
|
-
valueLength: value.length,
|
|
185
|
-
length
|
|
186
|
-
}) ?? value.split("").join(" ")
|
|
187
|
-
}}
|
|
188
|
-
autoFocus={autoFocus}
|
|
189
|
-
secureTextEntry={secret}
|
|
190
|
-
/>
|
|
191
|
-
<View
|
|
192
|
-
style={{
|
|
193
|
-
flexDirection: "row",
|
|
194
|
-
justifyContent: "space-between",
|
|
195
|
-
columnGap: OTP_ITEMS_GAP,
|
|
196
|
-
flexGrow: 1,
|
|
197
|
-
zIndex: 10
|
|
198
|
-
}}
|
|
199
|
-
accessibilityElementsHidden={true}
|
|
200
|
-
importantForAccessibility="no-hide-descendants"
|
|
201
|
-
>
|
|
202
|
-
{cells.map((_, i) => (
|
|
203
|
-
<BoxedInput
|
|
204
|
-
key={i}
|
|
205
|
-
status={
|
|
206
|
-
hasError
|
|
207
|
-
? "error"
|
|
208
|
-
: hasFocus && value.length === i
|
|
209
|
-
? "focus"
|
|
210
|
-
: "default"
|
|
211
|
-
}
|
|
212
|
-
secret={secret}
|
|
213
|
-
value={value[i]}
|
|
214
|
-
/>
|
|
215
|
-
))}
|
|
216
|
-
</View>
|
|
217
|
-
</Pressable>
|
|
218
|
-
<VSpacer size={4} />
|
|
219
|
-
{hasError && errorMessage && (
|
|
220
|
-
<BodySmall
|
|
221
|
-
weight="Semibold"
|
|
222
|
-
color={theme.errorText}
|
|
223
|
-
style={{ textAlign: "center" }}
|
|
224
|
-
>
|
|
225
|
-
{errorMessage}
|
|
226
|
-
</BodySmall>
|
|
227
|
-
)}
|
|
228
|
-
</Animated.View>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
);
|
|
215
|
+
{errorMessage}
|
|
216
|
+
</BodySmall>
|
|
217
|
+
)}
|
|
218
|
+
</Animated.View>
|
|
219
|
+
);
|
|
220
|
+
};
|