@hero-design/rn 8.64.4 → 8.64.6-alpha.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/CHANGELOG.md +6 -0
- package/es/index.js +21 -9
- package/lib/index.js +21 -9
- package/package.json +3 -2
- package/sonar-project.properties +0 -2
- package/src/components/PinInput/StyledPinInput.tsx +5 -0
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +284 -8
- package/src/components/PinInput/__tests__/index.spec.tsx +26 -0
- package/src/components/PinInput/index.tsx +18 -4
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -0
- package/src/theme/components/pinInput.ts +3 -0
- package/stats/8.64.4/rn-stats.html +2 -0
- package/stats/8.64.5/rn-stats.html +4844 -0
- package/types/components/PinInput/index.d.ts +10 -1
- package/types/theme/components/pinInput.d.ts +3 -0
- package/.turbo/turbo-build.log +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.64.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3322](https://github.com/Thinkei/hero-design/pull/3322) [`7539669a0361a390a19b05b3ad6bd2e5cb55964e`](https://github.com/Thinkei/hero-design/commit/7539669a0361a390a19b05b3ad6bd2e5cb55964e) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [PinInput] Support long press, autoComplete and textContentType props
|
|
8
|
+
|
|
3
9
|
## 8.64.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/es/index.js
CHANGED
|
@@ -2870,7 +2870,8 @@ var getPinInputTheme = function getPinInputTheme(theme) {
|
|
|
2870
2870
|
};
|
|
2871
2871
|
var fontSizes = {
|
|
2872
2872
|
cellText: theme.fontSizes.xxxxlarge,
|
|
2873
|
-
errorMessage: theme.fontSizes.small
|
|
2873
|
+
errorMessage: theme.fontSizes.small,
|
|
2874
|
+
hiddenInputText: theme.fontSizes['7xlarge']
|
|
2874
2875
|
};
|
|
2875
2876
|
var lineHeights = {
|
|
2876
2877
|
cellText: theme.lineHeights.xxxxlarge,
|
|
@@ -2883,7 +2884,9 @@ var getPinInputTheme = function getPinInputTheme(theme) {
|
|
|
2883
2884
|
};
|
|
2884
2885
|
var space = {
|
|
2885
2886
|
spacer: theme.space.medium,
|
|
2886
|
-
errorMessagePadding: theme.space.xsmall
|
|
2887
|
+
errorMessagePadding: theme.space.xsmall,
|
|
2888
|
+
hiddenInputText: theme.space.xlarge,
|
|
2889
|
+
hiddenInputHorrizontalPadding: theme.space.small
|
|
2887
2890
|
};
|
|
2888
2891
|
var radii = {
|
|
2889
2892
|
cell: theme.radii.medium,
|
|
@@ -15521,8 +15524,12 @@ var StyledHiddenInput = index$9(TextInput$1)(function (_ref6) {
|
|
|
15521
15524
|
opacity: 0,
|
|
15522
15525
|
left: 0,
|
|
15523
15526
|
top: 0,
|
|
15527
|
+
right: 0,
|
|
15524
15528
|
width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
|
|
15525
|
-
height: '100%'
|
|
15529
|
+
height: '100%',
|
|
15530
|
+
fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
|
|
15531
|
+
letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
|
|
15532
|
+
paddingHorizontal: theme.__hd__.pinInput.space.hiddenInputHorrizontalPadding
|
|
15526
15533
|
};
|
|
15527
15534
|
});
|
|
15528
15535
|
var StyledErrorContainer = index$9(View)(function (_ref7) {
|
|
@@ -15590,7 +15597,9 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15590
15597
|
autoFocus = _ref2$autoFocus === void 0 ? false : _ref2$autoFocus,
|
|
15591
15598
|
error = _ref2.error,
|
|
15592
15599
|
style = _ref2.style,
|
|
15593
|
-
testID = _ref2.testID
|
|
15600
|
+
testID = _ref2.testID,
|
|
15601
|
+
textContentType = _ref2.textContentType,
|
|
15602
|
+
autoComplete = _ref2.autoComplete;
|
|
15594
15603
|
var inputRef = useRef(null);
|
|
15595
15604
|
var _useState = useState(autoFocus),
|
|
15596
15605
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -15600,6 +15609,7 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15600
15609
|
disabled: disabled,
|
|
15601
15610
|
error: error
|
|
15602
15611
|
});
|
|
15612
|
+
var maskedValueWithExtraSpace = !value ? '*' : value;
|
|
15603
15613
|
var focus = useCallback(function () {
|
|
15604
15614
|
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
15605
15615
|
inputRef.current.focus();
|
|
@@ -15651,7 +15661,7 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15651
15661
|
}), /*#__PURE__*/React__default.createElement(StyledErrorMessage, null, error)), /*#__PURE__*/React__default.createElement(StyledHiddenInput, {
|
|
15652
15662
|
themePinLength: length,
|
|
15653
15663
|
ref: inputRef,
|
|
15654
|
-
value:
|
|
15664
|
+
value: maskedValueWithExtraSpace,
|
|
15655
15665
|
onChangeText: changeText,
|
|
15656
15666
|
secureTextEntry: secure,
|
|
15657
15667
|
editable: !disabled,
|
|
@@ -15659,11 +15669,13 @@ var PinInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
15659
15669
|
onFocus: focus,
|
|
15660
15670
|
onBlur: blur,
|
|
15661
15671
|
maxLength: length,
|
|
15662
|
-
keyboardType: "numeric",
|
|
15663
|
-
contextMenuHidden: true,
|
|
15664
15672
|
caretHidden: true,
|
|
15665
|
-
pointerEvents: "box-
|
|
15666
|
-
|
|
15673
|
+
pointerEvents: "box-none",
|
|
15674
|
+
keyboardType: "numeric",
|
|
15675
|
+
testID: "pin-hidden-input",
|
|
15676
|
+
textContentType: textContentType,
|
|
15677
|
+
autoComplete: autoComplete,
|
|
15678
|
+
selectTextOnFocus: false
|
|
15667
15679
|
}));
|
|
15668
15680
|
});
|
|
15669
15681
|
PinInput.displayName = 'PinInput';
|
package/lib/index.js
CHANGED
|
@@ -2900,7 +2900,8 @@ var getPinInputTheme = function getPinInputTheme(theme) {
|
|
|
2900
2900
|
};
|
|
2901
2901
|
var fontSizes = {
|
|
2902
2902
|
cellText: theme.fontSizes.xxxxlarge,
|
|
2903
|
-
errorMessage: theme.fontSizes.small
|
|
2903
|
+
errorMessage: theme.fontSizes.small,
|
|
2904
|
+
hiddenInputText: theme.fontSizes['7xlarge']
|
|
2904
2905
|
};
|
|
2905
2906
|
var lineHeights = {
|
|
2906
2907
|
cellText: theme.lineHeights.xxxxlarge,
|
|
@@ -2913,7 +2914,9 @@ var getPinInputTheme = function getPinInputTheme(theme) {
|
|
|
2913
2914
|
};
|
|
2914
2915
|
var space = {
|
|
2915
2916
|
spacer: theme.space.medium,
|
|
2916
|
-
errorMessagePadding: theme.space.xsmall
|
|
2917
|
+
errorMessagePadding: theme.space.xsmall,
|
|
2918
|
+
hiddenInputText: theme.space.xlarge,
|
|
2919
|
+
hiddenInputHorrizontalPadding: theme.space.small
|
|
2917
2920
|
};
|
|
2918
2921
|
var radii = {
|
|
2919
2922
|
cell: theme.radii.medium,
|
|
@@ -15551,8 +15554,12 @@ var StyledHiddenInput = index$9(reactNative.TextInput)(function (_ref6) {
|
|
|
15551
15554
|
opacity: 0,
|
|
15552
15555
|
left: 0,
|
|
15553
15556
|
top: 0,
|
|
15557
|
+
right: 0,
|
|
15554
15558
|
width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
|
|
15555
|
-
height: '100%'
|
|
15559
|
+
height: '100%',
|
|
15560
|
+
fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
|
|
15561
|
+
letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
|
|
15562
|
+
paddingHorizontal: theme.__hd__.pinInput.space.hiddenInputHorrizontalPadding
|
|
15556
15563
|
};
|
|
15557
15564
|
});
|
|
15558
15565
|
var StyledErrorContainer = index$9(reactNative.View)(function (_ref7) {
|
|
@@ -15620,7 +15627,9 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15620
15627
|
autoFocus = _ref2$autoFocus === void 0 ? false : _ref2$autoFocus,
|
|
15621
15628
|
error = _ref2.error,
|
|
15622
15629
|
style = _ref2.style,
|
|
15623
|
-
testID = _ref2.testID
|
|
15630
|
+
testID = _ref2.testID,
|
|
15631
|
+
textContentType = _ref2.textContentType,
|
|
15632
|
+
autoComplete = _ref2.autoComplete;
|
|
15624
15633
|
var inputRef = React.useRef(null);
|
|
15625
15634
|
var _useState = React.useState(autoFocus),
|
|
15626
15635
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -15630,6 +15639,7 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15630
15639
|
disabled: disabled,
|
|
15631
15640
|
error: error
|
|
15632
15641
|
});
|
|
15642
|
+
var maskedValueWithExtraSpace = !value ? '*' : value;
|
|
15633
15643
|
var focus = React.useCallback(function () {
|
|
15634
15644
|
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
15635
15645
|
inputRef.current.focus();
|
|
@@ -15681,7 +15691,7 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15681
15691
|
}), /*#__PURE__*/React__default["default"].createElement(StyledErrorMessage, null, error)), /*#__PURE__*/React__default["default"].createElement(StyledHiddenInput, {
|
|
15682
15692
|
themePinLength: length,
|
|
15683
15693
|
ref: inputRef,
|
|
15684
|
-
value:
|
|
15694
|
+
value: maskedValueWithExtraSpace,
|
|
15685
15695
|
onChangeText: changeText,
|
|
15686
15696
|
secureTextEntry: secure,
|
|
15687
15697
|
editable: !disabled,
|
|
@@ -15689,11 +15699,13 @@ var PinInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
15689
15699
|
onFocus: focus,
|
|
15690
15700
|
onBlur: blur,
|
|
15691
15701
|
maxLength: length,
|
|
15692
|
-
keyboardType: "numeric",
|
|
15693
|
-
contextMenuHidden: true,
|
|
15694
15702
|
caretHidden: true,
|
|
15695
|
-
pointerEvents: "box-
|
|
15696
|
-
|
|
15703
|
+
pointerEvents: "box-none",
|
|
15704
|
+
keyboardType: "numeric",
|
|
15705
|
+
testID: "pin-hidden-input",
|
|
15706
|
+
textContentType: textContentType,
|
|
15707
|
+
autoComplete: autoComplete,
|
|
15708
|
+
selectTextOnFocus: false
|
|
15697
15709
|
}));
|
|
15698
15710
|
});
|
|
15699
15711
|
PinInput.displayName = 'PinInput';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.64.
|
|
3
|
+
"version": "8.64.6-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -93,5 +93,6 @@
|
|
|
93
93
|
"ts-jest": "^29.1.1",
|
|
94
94
|
"typescript": "4.8.4"
|
|
95
95
|
},
|
|
96
|
-
"prettier": "prettier-config-hd"
|
|
96
|
+
"prettier": "prettier-config-hd",
|
|
97
|
+
"react-native": "src/index.ts"
|
|
97
98
|
}
|
package/sonar-project.properties
CHANGED
|
@@ -68,8 +68,13 @@ export const StyledHiddenInput = styled(TextInput)<{ themePinLength: number }>(
|
|
|
68
68
|
opacity: 0,
|
|
69
69
|
left: 0,
|
|
70
70
|
top: 0,
|
|
71
|
+
right: 0,
|
|
71
72
|
width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
|
|
72
73
|
height: '100%',
|
|
74
|
+
fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
|
|
75
|
+
letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
|
|
76
|
+
paddingHorizontal:
|
|
77
|
+
theme.__hd__.pinInput.space.hiddenInputHorrizontalPadding,
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
);
|
|
@@ -204,22 +204,26 @@ exports[`rendering renders correctly 1`] = `
|
|
|
204
204
|
<TextInput
|
|
205
205
|
autoFocus={false}
|
|
206
206
|
caretHidden={true}
|
|
207
|
-
contextMenuHidden={true}
|
|
208
207
|
editable={true}
|
|
209
208
|
keyboardType="numeric"
|
|
210
209
|
maxLength={4}
|
|
211
210
|
onBlur={[Function]}
|
|
212
211
|
onChangeText={[Function]}
|
|
213
212
|
onFocus={[Function]}
|
|
214
|
-
pointerEvents="box-
|
|
213
|
+
pointerEvents="box-none"
|
|
215
214
|
secureTextEntry={true}
|
|
215
|
+
selectTextOnFocus={false}
|
|
216
216
|
style={
|
|
217
217
|
[
|
|
218
218
|
{
|
|
219
|
+
"fontSize": 42,
|
|
219
220
|
"height": "100%",
|
|
220
221
|
"left": 0,
|
|
222
|
+
"letterSpacing": 32,
|
|
221
223
|
"opacity": 0,
|
|
224
|
+
"paddingHorizontal": 8,
|
|
222
225
|
"position": "absolute",
|
|
226
|
+
"right": 0,
|
|
223
227
|
"top": 0,
|
|
224
228
|
"width": 208,
|
|
225
229
|
},
|
|
@@ -458,22 +462,26 @@ exports[`rendering renders correctly when disabled 1`] = `
|
|
|
458
462
|
<TextInput
|
|
459
463
|
autoFocus={false}
|
|
460
464
|
caretHidden={true}
|
|
461
|
-
contextMenuHidden={true}
|
|
462
465
|
editable={false}
|
|
463
466
|
keyboardType="numeric"
|
|
464
467
|
maxLength={4}
|
|
465
468
|
onBlur={[Function]}
|
|
466
469
|
onChangeText={[Function]}
|
|
467
470
|
onFocus={[Function]}
|
|
468
|
-
pointerEvents="box-
|
|
471
|
+
pointerEvents="box-none"
|
|
469
472
|
secureTextEntry={true}
|
|
473
|
+
selectTextOnFocus={false}
|
|
470
474
|
style={
|
|
471
475
|
[
|
|
472
476
|
{
|
|
477
|
+
"fontSize": 42,
|
|
473
478
|
"height": "100%",
|
|
474
479
|
"left": 0,
|
|
480
|
+
"letterSpacing": 32,
|
|
475
481
|
"opacity": 0,
|
|
482
|
+
"paddingHorizontal": 8,
|
|
476
483
|
"position": "absolute",
|
|
484
|
+
"right": 0,
|
|
477
485
|
"top": 0,
|
|
478
486
|
"width": 208,
|
|
479
487
|
},
|
|
@@ -830,22 +838,26 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
|
|
|
830
838
|
<TextInput
|
|
831
839
|
autoFocus={false}
|
|
832
840
|
caretHidden={true}
|
|
833
|
-
contextMenuHidden={true}
|
|
834
841
|
editable={true}
|
|
835
842
|
keyboardType="numeric"
|
|
836
843
|
maxLength={6}
|
|
837
844
|
onBlur={[Function]}
|
|
838
845
|
onChangeText={[Function]}
|
|
839
846
|
onFocus={[Function]}
|
|
840
|
-
pointerEvents="box-
|
|
847
|
+
pointerEvents="box-none"
|
|
841
848
|
secureTextEntry={false}
|
|
849
|
+
selectTextOnFocus={false}
|
|
842
850
|
style={
|
|
843
851
|
[
|
|
844
852
|
{
|
|
853
|
+
"fontSize": 42,
|
|
845
854
|
"height": "100%",
|
|
846
855
|
"left": 0,
|
|
856
|
+
"letterSpacing": 32,
|
|
847
857
|
"opacity": 0,
|
|
858
|
+
"paddingHorizontal": 8,
|
|
848
859
|
"position": "absolute",
|
|
860
|
+
"right": 0,
|
|
849
861
|
"top": 0,
|
|
850
862
|
"width": 320,
|
|
851
863
|
},
|
|
@@ -1137,22 +1149,26 @@ exports[`rendering renders correctly when there is error 1`] = `
|
|
|
1137
1149
|
<TextInput
|
|
1138
1150
|
autoFocus={false}
|
|
1139
1151
|
caretHidden={true}
|
|
1140
|
-
contextMenuHidden={true}
|
|
1141
1152
|
editable={true}
|
|
1142
1153
|
keyboardType="numeric"
|
|
1143
1154
|
maxLength={4}
|
|
1144
1155
|
onBlur={[Function]}
|
|
1145
1156
|
onChangeText={[Function]}
|
|
1146
1157
|
onFocus={[Function]}
|
|
1147
|
-
pointerEvents="box-
|
|
1158
|
+
pointerEvents="box-none"
|
|
1148
1159
|
secureTextEntry={true}
|
|
1160
|
+
selectTextOnFocus={false}
|
|
1149
1161
|
style={
|
|
1150
1162
|
[
|
|
1151
1163
|
{
|
|
1164
|
+
"fontSize": 42,
|
|
1152
1165
|
"height": "100%",
|
|
1153
1166
|
"left": 0,
|
|
1167
|
+
"letterSpacing": 32,
|
|
1154
1168
|
"opacity": 0,
|
|
1169
|
+
"paddingHorizontal": 8,
|
|
1155
1170
|
"position": "absolute",
|
|
1171
|
+
"right": 0,
|
|
1156
1172
|
"top": 0,
|
|
1157
1173
|
"width": 208,
|
|
1158
1174
|
},
|
|
@@ -1186,3 +1202,263 @@ exports[`rendering renders correctly when there is error 1`] = `
|
|
|
1186
1202
|
/>
|
|
1187
1203
|
</View>
|
|
1188
1204
|
`;
|
|
1205
|
+
|
|
1206
|
+
exports[`rendering renders correctly with textContentType and autoComplete 1`] = `
|
|
1207
|
+
<View
|
|
1208
|
+
style={
|
|
1209
|
+
{
|
|
1210
|
+
"flex": 1,
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
>
|
|
1214
|
+
<View
|
|
1215
|
+
style={
|
|
1216
|
+
[
|
|
1217
|
+
{
|
|
1218
|
+
"alignContent": "flex-start",
|
|
1219
|
+
},
|
|
1220
|
+
undefined,
|
|
1221
|
+
]
|
|
1222
|
+
}
|
|
1223
|
+
>
|
|
1224
|
+
<View
|
|
1225
|
+
style={
|
|
1226
|
+
[
|
|
1227
|
+
{
|
|
1228
|
+
"flexDirection": "row",
|
|
1229
|
+
},
|
|
1230
|
+
undefined,
|
|
1231
|
+
]
|
|
1232
|
+
}
|
|
1233
|
+
>
|
|
1234
|
+
<View
|
|
1235
|
+
style={
|
|
1236
|
+
[
|
|
1237
|
+
{
|
|
1238
|
+
"alignItems": "center",
|
|
1239
|
+
"borderColor": "#001f23",
|
|
1240
|
+
"borderRadius": 8,
|
|
1241
|
+
"borderWidth": 1,
|
|
1242
|
+
"height": 48,
|
|
1243
|
+
"justifyContent": "center",
|
|
1244
|
+
"width": 40,
|
|
1245
|
+
},
|
|
1246
|
+
undefined,
|
|
1247
|
+
]
|
|
1248
|
+
}
|
|
1249
|
+
themeFocused={false}
|
|
1250
|
+
themeState="default"
|
|
1251
|
+
>
|
|
1252
|
+
<View
|
|
1253
|
+
style={
|
|
1254
|
+
[
|
|
1255
|
+
{
|
|
1256
|
+
"backgroundColor": "#001f23",
|
|
1257
|
+
"borderColor": "#001f23",
|
|
1258
|
+
"borderRadius": 999,
|
|
1259
|
+
"borderWidth": 1,
|
|
1260
|
+
"height": 16,
|
|
1261
|
+
"width": 16,
|
|
1262
|
+
},
|
|
1263
|
+
undefined,
|
|
1264
|
+
]
|
|
1265
|
+
}
|
|
1266
|
+
testID="pin-cell-filled-mask"
|
|
1267
|
+
themeState="default"
|
|
1268
|
+
/>
|
|
1269
|
+
</View>
|
|
1270
|
+
<View
|
|
1271
|
+
style={
|
|
1272
|
+
[
|
|
1273
|
+
{
|
|
1274
|
+
"marginLeft": 16,
|
|
1275
|
+
},
|
|
1276
|
+
undefined,
|
|
1277
|
+
]
|
|
1278
|
+
}
|
|
1279
|
+
/>
|
|
1280
|
+
<View
|
|
1281
|
+
style={
|
|
1282
|
+
[
|
|
1283
|
+
{
|
|
1284
|
+
"alignItems": "center",
|
|
1285
|
+
"borderColor": "#001f23",
|
|
1286
|
+
"borderRadius": 8,
|
|
1287
|
+
"borderWidth": 1,
|
|
1288
|
+
"height": 48,
|
|
1289
|
+
"justifyContent": "center",
|
|
1290
|
+
"width": 40,
|
|
1291
|
+
},
|
|
1292
|
+
undefined,
|
|
1293
|
+
]
|
|
1294
|
+
}
|
|
1295
|
+
themeFocused={false}
|
|
1296
|
+
themeState="default"
|
|
1297
|
+
>
|
|
1298
|
+
<View
|
|
1299
|
+
style={
|
|
1300
|
+
[
|
|
1301
|
+
{
|
|
1302
|
+
"backgroundColor": "#001f23",
|
|
1303
|
+
"borderColor": "#001f23",
|
|
1304
|
+
"borderRadius": 999,
|
|
1305
|
+
"borderWidth": 1,
|
|
1306
|
+
"height": 16,
|
|
1307
|
+
"width": 16,
|
|
1308
|
+
},
|
|
1309
|
+
undefined,
|
|
1310
|
+
]
|
|
1311
|
+
}
|
|
1312
|
+
testID="pin-cell-filled-mask"
|
|
1313
|
+
themeState="default"
|
|
1314
|
+
/>
|
|
1315
|
+
</View>
|
|
1316
|
+
<View
|
|
1317
|
+
style={
|
|
1318
|
+
[
|
|
1319
|
+
{
|
|
1320
|
+
"marginLeft": 16,
|
|
1321
|
+
},
|
|
1322
|
+
undefined,
|
|
1323
|
+
]
|
|
1324
|
+
}
|
|
1325
|
+
/>
|
|
1326
|
+
<View
|
|
1327
|
+
style={
|
|
1328
|
+
[
|
|
1329
|
+
{
|
|
1330
|
+
"alignItems": "center",
|
|
1331
|
+
"borderColor": "#001f23",
|
|
1332
|
+
"borderRadius": 8,
|
|
1333
|
+
"borderWidth": 1,
|
|
1334
|
+
"height": 48,
|
|
1335
|
+
"justifyContent": "center",
|
|
1336
|
+
"width": 40,
|
|
1337
|
+
},
|
|
1338
|
+
undefined,
|
|
1339
|
+
]
|
|
1340
|
+
}
|
|
1341
|
+
themeFocused={false}
|
|
1342
|
+
themeState="default"
|
|
1343
|
+
>
|
|
1344
|
+
<View
|
|
1345
|
+
style={
|
|
1346
|
+
[
|
|
1347
|
+
{
|
|
1348
|
+
"borderColor": "#001f23",
|
|
1349
|
+
"borderRadius": 999,
|
|
1350
|
+
"borderWidth": 1,
|
|
1351
|
+
"height": 16,
|
|
1352
|
+
"width": 16,
|
|
1353
|
+
},
|
|
1354
|
+
undefined,
|
|
1355
|
+
]
|
|
1356
|
+
}
|
|
1357
|
+
testID="pin-cell-mask"
|
|
1358
|
+
themeState="default"
|
|
1359
|
+
/>
|
|
1360
|
+
</View>
|
|
1361
|
+
<View
|
|
1362
|
+
style={
|
|
1363
|
+
[
|
|
1364
|
+
{
|
|
1365
|
+
"marginLeft": 16,
|
|
1366
|
+
},
|
|
1367
|
+
undefined,
|
|
1368
|
+
]
|
|
1369
|
+
}
|
|
1370
|
+
/>
|
|
1371
|
+
<View
|
|
1372
|
+
style={
|
|
1373
|
+
[
|
|
1374
|
+
{
|
|
1375
|
+
"alignItems": "center",
|
|
1376
|
+
"borderColor": "#001f23",
|
|
1377
|
+
"borderRadius": 8,
|
|
1378
|
+
"borderWidth": 1,
|
|
1379
|
+
"height": 48,
|
|
1380
|
+
"justifyContent": "center",
|
|
1381
|
+
"width": 40,
|
|
1382
|
+
},
|
|
1383
|
+
undefined,
|
|
1384
|
+
]
|
|
1385
|
+
}
|
|
1386
|
+
themeFocused={false}
|
|
1387
|
+
themeState="default"
|
|
1388
|
+
>
|
|
1389
|
+
<View
|
|
1390
|
+
style={
|
|
1391
|
+
[
|
|
1392
|
+
{
|
|
1393
|
+
"borderColor": "#001f23",
|
|
1394
|
+
"borderRadius": 999,
|
|
1395
|
+
"borderWidth": 1,
|
|
1396
|
+
"height": 16,
|
|
1397
|
+
"width": 16,
|
|
1398
|
+
},
|
|
1399
|
+
undefined,
|
|
1400
|
+
]
|
|
1401
|
+
}
|
|
1402
|
+
testID="pin-cell-mask"
|
|
1403
|
+
themeState="default"
|
|
1404
|
+
/>
|
|
1405
|
+
</View>
|
|
1406
|
+
</View>
|
|
1407
|
+
<TextInput
|
|
1408
|
+
autoComplete="one-time-code"
|
|
1409
|
+
autoFocus={false}
|
|
1410
|
+
caretHidden={true}
|
|
1411
|
+
editable={true}
|
|
1412
|
+
keyboardType="numeric"
|
|
1413
|
+
maxLength={4}
|
|
1414
|
+
onBlur={[Function]}
|
|
1415
|
+
onChangeText={[Function]}
|
|
1416
|
+
onFocus={[Function]}
|
|
1417
|
+
pointerEvents="box-none"
|
|
1418
|
+
secureTextEntry={true}
|
|
1419
|
+
selectTextOnFocus={false}
|
|
1420
|
+
style={
|
|
1421
|
+
[
|
|
1422
|
+
{
|
|
1423
|
+
"fontSize": 42,
|
|
1424
|
+
"height": "100%",
|
|
1425
|
+
"left": 0,
|
|
1426
|
+
"letterSpacing": 32,
|
|
1427
|
+
"opacity": 0,
|
|
1428
|
+
"paddingHorizontal": 8,
|
|
1429
|
+
"position": "absolute",
|
|
1430
|
+
"right": 0,
|
|
1431
|
+
"top": 0,
|
|
1432
|
+
"width": 208,
|
|
1433
|
+
},
|
|
1434
|
+
undefined,
|
|
1435
|
+
]
|
|
1436
|
+
}
|
|
1437
|
+
testID="pin-hidden-input"
|
|
1438
|
+
textContentType="oneTimeCode"
|
|
1439
|
+
themePinLength={4}
|
|
1440
|
+
value="12"
|
|
1441
|
+
/>
|
|
1442
|
+
</View>
|
|
1443
|
+
<View
|
|
1444
|
+
pointerEvents="box-none"
|
|
1445
|
+
position="bottom"
|
|
1446
|
+
style={
|
|
1447
|
+
[
|
|
1448
|
+
{
|
|
1449
|
+
"bottom": 0,
|
|
1450
|
+
"elevation": 9999,
|
|
1451
|
+
"flexDirection": "column-reverse",
|
|
1452
|
+
"left": 0,
|
|
1453
|
+
"paddingHorizontal": 24,
|
|
1454
|
+
"paddingVertical": 16,
|
|
1455
|
+
"position": "absolute",
|
|
1456
|
+
"right": 0,
|
|
1457
|
+
"top": 0,
|
|
1458
|
+
},
|
|
1459
|
+
undefined,
|
|
1460
|
+
]
|
|
1461
|
+
}
|
|
1462
|
+
/>
|
|
1463
|
+
</View>
|
|
1464
|
+
`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
3
4
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
5
|
import PinInput, { getState } from '..';
|
|
5
6
|
|
|
@@ -14,6 +15,21 @@ describe('rendering', () => {
|
|
|
14
15
|
expect(wrapper.queryAllByTestId('pin-cell-mask')).toHaveLength(2);
|
|
15
16
|
});
|
|
16
17
|
|
|
18
|
+
it('renders correctly with textContentType and autoComplete', () => {
|
|
19
|
+
const wrapper = renderWithTheme(
|
|
20
|
+
<PinInput
|
|
21
|
+
value="12"
|
|
22
|
+
onChangeText={jest.fn()}
|
|
23
|
+
textContentType="oneTimeCode"
|
|
24
|
+
autoComplete="one-time-code"
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
29
|
+
expect(wrapper.queryAllByTestId('pin-cell-filled-mask')).toHaveLength(2);
|
|
30
|
+
expect(wrapper.queryAllByTestId('pin-cell-mask')).toHaveLength(2);
|
|
31
|
+
});
|
|
32
|
+
|
|
17
33
|
it('renders correctly when length is 6 and secure is false', () => {
|
|
18
34
|
const wrapper = renderWithTheme(
|
|
19
35
|
<PinInput
|
|
@@ -52,6 +68,16 @@ describe('rendering', () => {
|
|
|
52
68
|
|
|
53
69
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
54
70
|
});
|
|
71
|
+
|
|
72
|
+
it('renders a placeholder if the value is empty on android', () => {
|
|
73
|
+
Platform.OS = 'android';
|
|
74
|
+
|
|
75
|
+
const wrapper = renderWithTheme(
|
|
76
|
+
<PinInput value="" onChangeText={jest.fn()} />
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(wrapper.getByDisplayValue('*')).toBeTruthy();
|
|
80
|
+
});
|
|
55
81
|
});
|
|
56
82
|
|
|
57
83
|
describe('behaviors', () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, {
|
|
2
|
+
ComponentProps,
|
|
2
3
|
forwardRef,
|
|
3
4
|
useCallback,
|
|
4
5
|
useEffect,
|
|
@@ -62,6 +63,14 @@ interface PinInputProps {
|
|
|
62
63
|
* Testing id of the component.
|
|
63
64
|
*/
|
|
64
65
|
testID?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The text content type of the input.
|
|
68
|
+
*/
|
|
69
|
+
textContentType?: ComponentProps<typeof TextInput>['textContentType'];
|
|
70
|
+
/**
|
|
71
|
+
* The autofill type of the input.
|
|
72
|
+
*/
|
|
73
|
+
autoComplete?: ComponentProps<typeof TextInput>['autoComplete'];
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
export function getState({
|
|
@@ -104,12 +113,15 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
104
113
|
error,
|
|
105
114
|
style,
|
|
106
115
|
testID,
|
|
116
|
+
textContentType,
|
|
117
|
+
autoComplete,
|
|
107
118
|
},
|
|
108
119
|
ref
|
|
109
120
|
) => {
|
|
110
121
|
const inputRef = useRef<TextInput>(null);
|
|
111
122
|
const [focused, setFocused] = useState(autoFocus);
|
|
112
123
|
const state = getState({ disabled, error });
|
|
124
|
+
const maskedValueWithExtraSpace = !value ? '*' : value;
|
|
113
125
|
|
|
114
126
|
const focus = useCallback(() => {
|
|
115
127
|
if (inputRef?.current) {
|
|
@@ -179,7 +191,7 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
179
191
|
<StyledHiddenInput
|
|
180
192
|
themePinLength={length}
|
|
181
193
|
ref={inputRef}
|
|
182
|
-
value={
|
|
194
|
+
value={maskedValueWithExtraSpace}
|
|
183
195
|
onChangeText={changeText}
|
|
184
196
|
secureTextEntry={secure}
|
|
185
197
|
editable={!disabled}
|
|
@@ -187,11 +199,13 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
|
|
|
187
199
|
onFocus={focus}
|
|
188
200
|
onBlur={blur}
|
|
189
201
|
maxLength={length}
|
|
190
|
-
keyboardType="numeric"
|
|
191
|
-
contextMenuHidden
|
|
192
202
|
caretHidden
|
|
193
|
-
pointerEvents="box-
|
|
203
|
+
pointerEvents="box-none"
|
|
204
|
+
keyboardType="numeric"
|
|
194
205
|
testID="pin-hidden-input"
|
|
206
|
+
textContentType={textContentType}
|
|
207
|
+
autoComplete={autoComplete}
|
|
208
|
+
selectTextOnFocus={false}
|
|
195
209
|
/>
|
|
196
210
|
</StyledWrapper>
|
|
197
211
|
);
|