@draftbit/core 48.4.5-c390a5.2 → 48.4.5-facee4.2
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/CodeInput/CodeInput.js +1 -0
- package/lib/commonjs/components/CodeInput/CodeInputCell.js +1 -0
- package/lib/commonjs/components/{PinInput/PinInputText.js → CodeInput/CodeInputText.js} +1 -1
- package/lib/commonjs/components/CodeInput/index.js +1 -0
- package/lib/commonjs/components/Picker/Picker.js +1 -1
- package/lib/commonjs/components/TextField.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/utilities.js +1 -1
- package/lib/typescript/src/components/CodeInput/CodeInput.d.ts +18 -0
- package/lib/typescript/src/components/CodeInput/CodeInput.js +30 -0
- package/lib/typescript/src/components/CodeInput/CodeInput.js.map +1 -0
- package/lib/typescript/src/components/CodeInput/CodeInputCell.d.ts +16 -0
- package/lib/typescript/src/components/CodeInput/CodeInputCell.js +43 -0
- package/lib/typescript/src/components/CodeInput/CodeInputCell.js.map +1 -0
- package/lib/typescript/src/components/{PinInput/PinInputText.d.ts → CodeInput/CodeInputText.d.ts} +3 -3
- package/{src/components/PinInput/PinInputText.js → lib/typescript/src/components/CodeInput/CodeInputText.js} +4 -4
- package/lib/typescript/src/components/CodeInput/CodeInputText.js.map +1 -0
- package/lib/typescript/src/components/CodeInput/index.d.ts +3 -0
- package/lib/typescript/src/components/CodeInput/index.js +4 -0
- package/lib/typescript/src/components/CodeInput/index.js.map +1 -0
- package/lib/typescript/src/components/Picker/Picker.d.ts +4 -10
- package/lib/typescript/src/components/Picker/Picker.js +84 -243
- package/lib/typescript/src/components/Picker/Picker.js.map +1 -1
- package/lib/typescript/src/components/TextField.d.ts +3 -3
- package/lib/typescript/src/components/TextField.js +9 -6
- package/lib/typescript/src/components/TextField.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.js +1 -1
- package/lib/typescript/src/index.js.map +1 -1
- package/lib/typescript/src/utilities.js +0 -6
- package/lib/typescript/src/utilities.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/CodeInput/CodeInput.js +30 -0
- package/src/components/CodeInput/CodeInput.js.map +1 -0
- package/src/components/CodeInput/CodeInput.tsx +95 -0
- package/src/components/CodeInput/CodeInputCell.js +43 -0
- package/src/components/CodeInput/CodeInputCell.js.map +1 -0
- package/src/components/CodeInput/CodeInputCell.tsx +73 -0
- package/{lib/typescript/src/components/PinInput/PinInputText.js → src/components/CodeInput/CodeInputText.js} +4 -4
- package/src/components/CodeInput/CodeInputText.js.map +1 -0
- package/src/components/{PinInput/PinInputText.tsx → CodeInput/CodeInputText.tsx} +4 -4
- package/src/components/CodeInput/index.js +4 -0
- package/src/components/CodeInput/index.js.map +1 -0
- package/src/components/CodeInput/index.tsx +3 -0
- package/src/components/Picker/Picker.js +84 -243
- package/src/components/Picker/Picker.js.map +1 -1
- package/src/components/Picker/Picker.tsx +134 -401
- package/src/components/TextField.js +9 -6
- package/src/components/TextField.js.map +1 -1
- package/src/components/TextField.tsx +14 -8
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/index.tsx +4 -4
- package/src/utilities.js +0 -6
- package/src/utilities.js.map +1 -1
- package/src/utilities.ts +0 -7
- package/lib/commonjs/components/Picker/PickerComponent.android.js +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +0 -1
- package/lib/commonjs/components/PinInput/CustomPinInputCell.js +0 -1
- package/lib/commonjs/components/PinInput/PinInput.js +0 -1
- package/lib/commonjs/components/PinInput/index.js +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +0 -6
- package/lib/typescript/src/components/Picker/PickerComponent.android.js +0 -70
- package/lib/typescript/src/components/Picker/PickerComponent.android.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +0 -7
- package/lib/typescript/src/components/Picker/PickerComponent.ios.js +0 -80
- package/lib/typescript/src/components/Picker/PickerComponent.ios.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +0 -6
- package/lib/typescript/src/components/Picker/PickerComponent.web.js +0 -71
- package/lib/typescript/src/components/Picker/PickerComponent.web.js.map +0 -1
- package/lib/typescript/src/components/PinInput/CustomPinInputCell.d.ts +0 -11
- package/lib/typescript/src/components/PinInput/CustomPinInputCell.js +0 -11
- package/lib/typescript/src/components/PinInput/CustomPinInputCell.js.map +0 -1
- package/lib/typescript/src/components/PinInput/PinInput.d.ts +0 -30
- package/lib/typescript/src/components/PinInput/PinInput.js +0 -70
- package/lib/typescript/src/components/PinInput/PinInput.js.map +0 -1
- package/lib/typescript/src/components/PinInput/PinInputText.js.map +0 -1
- package/lib/typescript/src/components/PinInput/index.d.ts +0 -3
- package/lib/typescript/src/components/PinInput/index.js +0 -4
- package/lib/typescript/src/components/PinInput/index.js.map +0 -1
- package/src/components/Picker/PickerComponent.android.js +0 -70
- package/src/components/Picker/PickerComponent.android.js.map +0 -1
- package/src/components/Picker/PickerComponent.android.tsx +0 -116
- package/src/components/Picker/PickerComponent.ios.js +0 -80
- package/src/components/Picker/PickerComponent.ios.js.map +0 -1
- package/src/components/Picker/PickerComponent.ios.tsx +0 -142
- package/src/components/Picker/PickerComponent.web.js +0 -71
- package/src/components/Picker/PickerComponent.web.js.map +0 -1
- package/src/components/Picker/PickerComponent.web.tsx +0 -117
- package/src/components/PinInput/CustomPinInputCell.js +0 -11
- package/src/components/PinInput/CustomPinInputCell.js.map +0 -1
- package/src/components/PinInput/CustomPinInputCell.tsx +0 -18
- package/src/components/PinInput/PinInput.js +0 -70
- package/src/components/PinInput/PinInput.js.map +0 -1
- package/src/components/PinInput/PinInput.tsx +0 -165
- package/src/components/PinInput/PinInputText.js.map +0 -1
- package/src/components/PinInput/index.js +0 -4
- package/src/components/PinInput/index.js.map +0 -1
- package/src/components/PinInput/index.tsx +0 -3
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
-
import omit from "lodash.omit";
|
|
5
|
-
import { withTheme } from "../../theming";
|
|
6
|
-
import { extractStyles } from "../../utilities";
|
|
7
|
-
|
|
8
|
-
import TextField from "../TextField";
|
|
9
|
-
import Touchable from "../Touchable";
|
|
10
|
-
import { PickerComponentProps } from "./PickerTypes";
|
|
11
|
-
|
|
12
|
-
const Picker: React.FC<PickerComponentProps> = ({
|
|
13
|
-
style,
|
|
14
|
-
options,
|
|
15
|
-
placeholder,
|
|
16
|
-
selectedValue,
|
|
17
|
-
disabled = false,
|
|
18
|
-
onValueChange: onValueChangeOverride = () => {},
|
|
19
|
-
...props
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
viewStyles: {
|
|
23
|
-
borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
-
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
25
|
-
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
26
|
-
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
27
|
-
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
|
-
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
|
-
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
30
|
-
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
31
|
-
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
|
-
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
|
-
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
34
|
-
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
35
|
-
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
36
|
-
...viewStyles
|
|
37
|
-
},
|
|
38
|
-
} = extractStyles(style);
|
|
39
|
-
|
|
40
|
-
const textField = React.useRef<typeof TextField | undefined>(undefined);
|
|
41
|
-
|
|
42
|
-
const onValueChange = (itemValue: string, itemIndex: number) => {
|
|
43
|
-
toggleFocus();
|
|
44
|
-
onValueChangeOverride(itemValue, itemIndex);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const toggleFocus = () => {
|
|
48
|
-
if (!disabled) {
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const stylesWithoutMargin =
|
|
55
|
-
style &&
|
|
56
|
-
omit(StyleSheet.flatten(style), [
|
|
57
|
-
"margin",
|
|
58
|
-
"marginTop",
|
|
59
|
-
"marginRight",
|
|
60
|
-
"marginBottom",
|
|
61
|
-
"marginLeft",
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
const selectedLabel =
|
|
65
|
-
selectedValue &&
|
|
66
|
-
(options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Touchable
|
|
70
|
-
disabled={disabled}
|
|
71
|
-
onPress={toggleFocus}
|
|
72
|
-
style={[styles.container, viewStyles]}
|
|
73
|
-
>
|
|
74
|
-
<View>
|
|
75
|
-
<NativePicker
|
|
76
|
-
enabled={!disabled}
|
|
77
|
-
selectedValue={selectedValue}
|
|
78
|
-
onValueChange={onValueChange}
|
|
79
|
-
style={{
|
|
80
|
-
flex: 1,
|
|
81
|
-
opacity: 0,
|
|
82
|
-
position: "absolute",
|
|
83
|
-
top: 0,
|
|
84
|
-
left: 0,
|
|
85
|
-
right: 0,
|
|
86
|
-
bottom: 0,
|
|
87
|
-
width: "100%",
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
{options.map((o) => (
|
|
91
|
-
<NativePicker.Item label={o.label} value={o.value} key={o.value} />
|
|
92
|
-
))}
|
|
93
|
-
</NativePicker>
|
|
94
|
-
<View pointerEvents="none">
|
|
95
|
-
<TextField
|
|
96
|
-
{...props}
|
|
97
|
-
value={selectedLabel}
|
|
98
|
-
placeholder={placeholder}
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
101
|
-
disabled={disabled}
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
style={stylesWithoutMargin}
|
|
104
|
-
/>
|
|
105
|
-
</View>
|
|
106
|
-
</View>
|
|
107
|
-
</Touchable>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const styles = StyleSheet.create({
|
|
112
|
-
container: {
|
|
113
|
-
alignSelf: "stretch",
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
export default withTheme(Picker);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
/**
|
|
4
|
-
* Simple View wrapper component to create a custom pin input cell
|
|
5
|
-
* Meant to be used in PinInput's renderItem
|
|
6
|
-
*/
|
|
7
|
-
const CustomPinInputCell = ({ style, children }) => {
|
|
8
|
-
return React.createElement(View, { style: style, children: children });
|
|
9
|
-
};
|
|
10
|
-
export default CustomPinInputCell;
|
|
11
|
-
//# sourceMappingURL=CustomPinInputCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPinInputCell.js","sourceRoot":"","sources":["CustomPinInputCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,IAAI,EAAE,MAAM,cAAc,CAAC;AAM1D;;;GAGG;AACH,MAAM,kBAAkB,GAEpB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC1B,OAAO,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACpD,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle, View } from "react-native";
|
|
3
|
-
|
|
4
|
-
interface CustomPinInputCellProps {
|
|
5
|
-
style?: StyleProp<ViewStyle>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Simple View wrapper component to create a custom pin input cell
|
|
10
|
-
* Meant to be used in PinInput's renderItem
|
|
11
|
-
*/
|
|
12
|
-
const CustomPinInputCell: React.FC<
|
|
13
|
-
React.PropsWithChildren<CustomPinInputCellProps>
|
|
14
|
-
> = ({ style, children }) => {
|
|
15
|
-
return <View style={style} children={children} />;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default CustomPinInputCell;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View, StyleSheet, } from "react-native";
|
|
3
|
-
import TextInput from "../TextInput";
|
|
4
|
-
import { CodeField, useClearByFocusCell, } from "react-native-confirmation-code-field";
|
|
5
|
-
import { withTheme } from "../../theming";
|
|
6
|
-
import PinInputText from "./PinInputText";
|
|
7
|
-
import { extractStyles } from "../../utilities";
|
|
8
|
-
const PinInput = React.forwardRef(({ theme, onInputFull, cellCount = 4, clearOnCellFocus = true, blurOnFull = true, renderItem, value, onChangeText, focusedBorderColor = theme.colors.primary, unFocusedBorderColor = theme.colors.disabled, focusedBackgroundColor, unFocusedBackgroundColor, focusedBorderWidth = 2, unFocusedBorderWidth = 1, focusedTextColor = theme.colors.strong, unFocusedTextColor = focusedTextColor, style, ...rest }, ref) => {
|
|
9
|
-
const newPinInputRef = React.useRef(null);
|
|
10
|
-
// Use the provided ref or default to new ref when not provided
|
|
11
|
-
const pinInputRef = ref
|
|
12
|
-
? ref
|
|
13
|
-
: newPinInputRef;
|
|
14
|
-
const { viewStyles, textStyles } = extractStyles(style);
|
|
15
|
-
// Clears input of a cell when focused, configured as explained here (https://github.com/retyui/react-native-confirmation-code-field/blob/master/API.md#useclearbyfocuscellvalue-string-setvalue-text-string--void)
|
|
16
|
-
const [codeFieldProps, getCellOnLayout] = useClearByFocusCell({
|
|
17
|
-
value,
|
|
18
|
-
setValue: (text) => onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text),
|
|
19
|
-
});
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
var _a;
|
|
22
|
-
if ((value === null || value === void 0 ? void 0 : value.length) === cellCount) {
|
|
23
|
-
if (blurOnFull) {
|
|
24
|
-
(_a = pinInputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
25
|
-
}
|
|
26
|
-
onInputFull === null || onInputFull === void 0 ? void 0 : onInputFull(value);
|
|
27
|
-
}
|
|
28
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
-
}, [value, cellCount, blurOnFull, pinInputRef]);
|
|
30
|
-
return (React.createElement(CodeField, { ref: pinInputRef, ...(clearOnCellFocus ? codeFieldProps : {}), value: value, onChangeText: onChangeText, textInputStyle: { height: "100%" }, InputComponent: TextInput, cellCount: cellCount, renderCell: ({ symbol: cellValue, index, isFocused }) => (React.createElement(View, { key: index, onLayout: clearOnCellFocus ? getCellOnLayout(index) : undefined, style: { flex: 1 } }, (renderItem === null || renderItem === void 0 ? void 0 : renderItem({ cellValue, index, isFocused })) || (React.createElement(View, { testID: "default-code-input-cell", style: [
|
|
31
|
-
styles.cell,
|
|
32
|
-
{
|
|
33
|
-
borderWidth: isFocused
|
|
34
|
-
? focusedBorderWidth
|
|
35
|
-
: unFocusedBorderWidth,
|
|
36
|
-
borderColor: isFocused
|
|
37
|
-
? focusedBorderColor
|
|
38
|
-
: unFocusedBorderColor,
|
|
39
|
-
backgroundColor: isFocused
|
|
40
|
-
? focusedBackgroundColor
|
|
41
|
-
: unFocusedBackgroundColor,
|
|
42
|
-
},
|
|
43
|
-
viewStyles,
|
|
44
|
-
] },
|
|
45
|
-
React.createElement(PinInputText, { style: [
|
|
46
|
-
styles.cellText,
|
|
47
|
-
{
|
|
48
|
-
color: isFocused ? focusedTextColor : unFocusedTextColor,
|
|
49
|
-
},
|
|
50
|
-
textStyles,
|
|
51
|
-
], isFocused: isFocused }, cellValue))))), ...rest }));
|
|
52
|
-
});
|
|
53
|
-
const styles = StyleSheet.create({
|
|
54
|
-
cell: {
|
|
55
|
-
marginStart: 5,
|
|
56
|
-
marginEnd: 5,
|
|
57
|
-
padding: 5,
|
|
58
|
-
borderRadius: 5,
|
|
59
|
-
justifyContent: "center",
|
|
60
|
-
alignItems: "center",
|
|
61
|
-
aspectRatio: 1,
|
|
62
|
-
maxWidth: 70,
|
|
63
|
-
maxHeight: 70,
|
|
64
|
-
},
|
|
65
|
-
cellText: {
|
|
66
|
-
fontSize: 25,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
export default withTheme(PinInput);
|
|
70
|
-
//# sourceMappingURL=PinInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PinInput.js","sourceRoot":"","sources":["PinInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAIL,IAAI,EACJ,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,SAA6B,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,SAAS,EACT,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA0BhD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAC/B,CACE,EACE,KAAK,EACL,WAAW,EACX,SAAS,GAAG,CAAC,E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V,CACR,CACI,CACR,KACG,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;KACd;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE;KACb;CACF,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
StyleProp,
|
|
4
|
-
ViewStyle,
|
|
5
|
-
TextInput as NativeTextInput,
|
|
6
|
-
View,
|
|
7
|
-
StyleSheet,
|
|
8
|
-
} from "react-native";
|
|
9
|
-
import TextInput, { TextInputProps } from "../TextInput";
|
|
10
|
-
import {
|
|
11
|
-
CodeField,
|
|
12
|
-
useClearByFocusCell,
|
|
13
|
-
} from "react-native-confirmation-code-field";
|
|
14
|
-
import type { Theme } from "../../styles/DefaultTheme";
|
|
15
|
-
import { withTheme } from "../../theming";
|
|
16
|
-
import PinInputText from "./PinInputText";
|
|
17
|
-
import { extractStyles } from "../../utilities";
|
|
18
|
-
|
|
19
|
-
interface CellItem {
|
|
20
|
-
cellValue: string;
|
|
21
|
-
index: number;
|
|
22
|
-
isFocused: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface PinInputProps extends TextInputProps {
|
|
26
|
-
onInputFull?: (value: string) => void;
|
|
27
|
-
cellCount?: number;
|
|
28
|
-
clearOnCellFocus?: boolean;
|
|
29
|
-
blurOnFull?: boolean;
|
|
30
|
-
renderItem?: ({ cellValue, index, isFocused }: CellItem) => JSX.Element;
|
|
31
|
-
focusedBorderColor?: string;
|
|
32
|
-
unFocusedBorderColor?: string;
|
|
33
|
-
focusedBackgroundColor?: string;
|
|
34
|
-
unFocusedBackgroundColor?: string;
|
|
35
|
-
focusedBorderWidth?: number;
|
|
36
|
-
unFocusedBorderWidth?: number;
|
|
37
|
-
focusedTextColor?: string;
|
|
38
|
-
unFocusedTextColor?: string;
|
|
39
|
-
style?: StyleProp<ViewStyle>;
|
|
40
|
-
theme: Theme;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const PinInput = React.forwardRef<NativeTextInput, PinInputProps>(
|
|
44
|
-
(
|
|
45
|
-
{
|
|
46
|
-
theme,
|
|
47
|
-
onInputFull,
|
|
48
|
-
cellCount = 4,
|
|
49
|
-
clearOnCellFocus = true,
|
|
50
|
-
blurOnFull = true,
|
|
51
|
-
renderItem,
|
|
52
|
-
value,
|
|
53
|
-
onChangeText,
|
|
54
|
-
focusedBorderColor = theme.colors.primary,
|
|
55
|
-
unFocusedBorderColor = theme.colors.disabled,
|
|
56
|
-
focusedBackgroundColor,
|
|
57
|
-
unFocusedBackgroundColor,
|
|
58
|
-
focusedBorderWidth = 2,
|
|
59
|
-
unFocusedBorderWidth = 1,
|
|
60
|
-
focusedTextColor = theme.colors.strong,
|
|
61
|
-
unFocusedTextColor = focusedTextColor,
|
|
62
|
-
style,
|
|
63
|
-
...rest
|
|
64
|
-
},
|
|
65
|
-
ref
|
|
66
|
-
) => {
|
|
67
|
-
const newPinInputRef = React.useRef<NativeTextInput>(null);
|
|
68
|
-
|
|
69
|
-
// Use the provided ref or default to new ref when not provided
|
|
70
|
-
const pinInputRef = ref
|
|
71
|
-
? (ref as React.RefObject<NativeTextInput>)
|
|
72
|
-
: newPinInputRef;
|
|
73
|
-
|
|
74
|
-
const { viewStyles, textStyles } = extractStyles(style);
|
|
75
|
-
|
|
76
|
-
// Clears input of a cell when focused, configured as explained here (https://github.com/retyui/react-native-confirmation-code-field/blob/master/API.md#useclearbyfocuscellvalue-string-setvalue-text-string--void)
|
|
77
|
-
const [codeFieldProps, getCellOnLayout] = useClearByFocusCell({
|
|
78
|
-
value,
|
|
79
|
-
setValue: (text) => onChangeText?.(text),
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
React.useEffect(() => {
|
|
83
|
-
if (value?.length === cellCount) {
|
|
84
|
-
if (blurOnFull) {
|
|
85
|
-
pinInputRef.current?.blur();
|
|
86
|
-
}
|
|
87
|
-
onInputFull?.(value);
|
|
88
|
-
}
|
|
89
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
-
}, [value, cellCount, blurOnFull, pinInputRef]);
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<CodeField
|
|
94
|
-
ref={pinInputRef}
|
|
95
|
-
{...(clearOnCellFocus ? codeFieldProps : {})}
|
|
96
|
-
value={value}
|
|
97
|
-
onChangeText={onChangeText}
|
|
98
|
-
textInputStyle={{ height: "100%" }} // addresses issue on firefox where the hidden input did not fill the height
|
|
99
|
-
InputComponent={TextInput}
|
|
100
|
-
cellCount={cellCount}
|
|
101
|
-
renderCell={({ symbol: cellValue, index, isFocused }) => (
|
|
102
|
-
<View
|
|
103
|
-
key={index}
|
|
104
|
-
onLayout={clearOnCellFocus ? getCellOnLayout(index) : undefined}
|
|
105
|
-
style={{ flex: 1 }}
|
|
106
|
-
>
|
|
107
|
-
{renderItem?.({ cellValue, index, isFocused }) || (
|
|
108
|
-
<View
|
|
109
|
-
testID="default-code-input-cell"
|
|
110
|
-
style={[
|
|
111
|
-
styles.cell,
|
|
112
|
-
{
|
|
113
|
-
borderWidth: isFocused
|
|
114
|
-
? focusedBorderWidth
|
|
115
|
-
: unFocusedBorderWidth,
|
|
116
|
-
borderColor: isFocused
|
|
117
|
-
? focusedBorderColor
|
|
118
|
-
: unFocusedBorderColor,
|
|
119
|
-
backgroundColor: isFocused
|
|
120
|
-
? focusedBackgroundColor
|
|
121
|
-
: unFocusedBackgroundColor,
|
|
122
|
-
},
|
|
123
|
-
viewStyles,
|
|
124
|
-
]}
|
|
125
|
-
>
|
|
126
|
-
<PinInputText
|
|
127
|
-
style={[
|
|
128
|
-
styles.cellText,
|
|
129
|
-
{
|
|
130
|
-
color: isFocused ? focusedTextColor : unFocusedTextColor,
|
|
131
|
-
},
|
|
132
|
-
textStyles,
|
|
133
|
-
]}
|
|
134
|
-
isFocused={isFocused}
|
|
135
|
-
>
|
|
136
|
-
{cellValue}
|
|
137
|
-
</PinInputText>
|
|
138
|
-
</View>
|
|
139
|
-
)}
|
|
140
|
-
</View>
|
|
141
|
-
)}
|
|
142
|
-
{...rest}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const styles = StyleSheet.create({
|
|
149
|
-
cell: {
|
|
150
|
-
marginStart: 5,
|
|
151
|
-
marginEnd: 5,
|
|
152
|
-
padding: 5,
|
|
153
|
-
borderRadius: 5,
|
|
154
|
-
justifyContent: "center",
|
|
155
|
-
alignItems: "center",
|
|
156
|
-
aspectRatio: 1,
|
|
157
|
-
maxWidth: 70,
|
|
158
|
-
maxHeight: 70,
|
|
159
|
-
},
|
|
160
|
-
cellText: {
|
|
161
|
-
fontSize: 25,
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
export default withTheme(PinInput);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PinInputText.js","sourceRoot":"","sources":["PinInputText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAS9D;;;GAGG;AACH,MAAM,kBAAkB,GAAsC,CAAC,EAC7D,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,EAAE;IACH,OAAO,CACL,oBAAC,IAAI,IAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,KAAM,IAAI,IAC3D,QAAQ;QACP,CAAC,SAAS,CAAC,CAAC,CAAC,CACX,oBAAC,MAAM,IAAC,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,GAAI,CACjE,CAAC,CAAC,CAAC,IAAI,CAAC,CACN,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|