Skip to content

Commit 9fd30fb

Browse files
committed
build: release version 1.4.1
1 parent a156eb9 commit 9fd30fb

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

dist/src/OtpInput/OtpInput.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const VerticalStick_1 = require("./VerticalStick");
88
const useOtpInput_1 = require("./useOtpInput");
99
exports.OtpInput = (0, react_1.forwardRef)((props, ref) => {
1010
const { models: { text, inputRef, focusedInputIndex }, actions: { clear, handlePress, handleTextChange, focus }, forms: { setTextWithRef }, } = (0, useOtpInput_1.useOtpInput)(props);
11-
const { numberOfDigits, autoFocus = true, hideStick, focusColor = "#A4D0A4", focusStickBlinkingDuration, secureTextEntry = false, autoComplete = "sms-otp", theme = {}, } = props;
12-
const { containerStyle, inputsContainerStyle, pinCodeContainerStyle, pinCodeTextStyle, focusStickStyle, focusedPinCodeContainerStyle, } = theme;
11+
const { numberOfDigits, autoFocus = true, hideStick, focusColor = "#A4D0A4", focusStickBlinkingDuration, secureTextEntry = false, theme = {}, } = props;
12+
const { containerStyle, inputsContainerStyle, pinCodeContainerStyle, pinCodeTextStyle, focusStickStyle, focusedPinCodeContainerStyle, filledPinCodeContainerStyle, } = theme;
1313
(0, react_1.useImperativeHandle)(ref, () => ({ clear, focus, setValue: setTextWithRef }));
1414
return (<react_native_1.View style={[OtpInput_styles_1.styles.container, containerStyle]}>
1515
<react_native_1.View style={[OtpInput_styles_1.styles.inputsContainer, inputsContainerStyle]}>
@@ -25,13 +25,16 @@ exports.OtpInput = (0, react_1.forwardRef)((props, ref) => {
2525
focusedPinCodeContainerStyle && isFocusedInput
2626
? { ...focusedPinCodeContainerStyle }
2727
: {},
28+
filledPinCodeContainerStyle && Boolean(char)
29+
? { ...filledPinCodeContainerStyle }
30+
: {},
2831
]} testID="otp-input">
2932
{isFocusedInput && !hideStick ? (<VerticalStick_1.VerticalStick focusColor={focusColor} style={focusStickStyle} focusStickBlinkingDuration={focusStickBlinkingDuration}/>) : (<react_native_1.Text style={[OtpInput_styles_1.styles.codeText, pinCodeTextStyle]}>
3033
{char && secureTextEntry ? "•" : char}
3134
</react_native_1.Text>)}
3235
</react_native_1.Pressable>);
3336
})}
3437
</react_native_1.View>
35-
<react_native_1.TextInput value={text} onChangeText={handleTextChange} maxLength={numberOfDigits} inputMode="numeric" textContentType="oneTimeCode" ref={inputRef} autoFocus={autoFocus} style={OtpInput_styles_1.styles.hiddenInput} secureTextEntry={secureTextEntry} autoComplete={autoComplete} testID="otp-input-hidden"/>
38+
<react_native_1.TextInput value={text} onChangeText={handleTextChange} maxLength={numberOfDigits} inputMode="numeric" textContentType="oneTimeCode" ref={inputRef} autoFocus={autoFocus} style={OtpInput_styles_1.styles.hiddenInput} secureTextEntry={secureTextEntry} autoComplete="one-time-code" testID="otp-input-hidden"/>
3639
</react_native_1.View>);
3740
});

dist/src/OtpInput/OtpInput.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ describe("OtpInput", () => {
5656
const inputs = react_native_1.screen.getAllByTestId("otp-input");
5757
expect(inputs).toHaveLength(numberOfDigits);
5858
});
59+
test("filledPinCodeContainerStyle should allow for new style when digit is present", () => {
60+
renderOtpInput({
61+
theme: { filledPinCodeContainerStyle: { borderBottomColor: "red" } },
62+
});
63+
const input = react_native_1.screen.getByTestId("otp-input-hidden");
64+
react_native_1.fireEvent.changeText(input, "12");
65+
const inputs = react_native_1.screen.getAllByTestId("otp-input");
66+
expect(inputs[0]).toHaveStyle({ borderBottomColor: "red" });
67+
expect(inputs[1]).toHaveStyle({ borderBottomColor: "red" });
68+
expect(inputs[2]).not.toHaveStyle({ borderBottomColor: "red" });
69+
});
5970
});
6071
describe("Logic", () => {
6172
test("should split text on screen from the text written in the hidden input", () => {

dist/src/OtpInput/OtpInput.types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ColorValue, TextInputProps, TextStyle, ViewStyle } from "react-native";
1+
import { ColorValue, TextStyle, ViewStyle } from "react-native";
22
export interface OtpInputProps {
33
numberOfDigits: number;
44
autoFocus?: boolean;
@@ -9,7 +9,6 @@ export interface OtpInputProps {
99
focusStickBlinkingDuration?: number;
1010
secureTextEntry?: boolean;
1111
theme?: Theme;
12-
autoComplete?: TextInputProps["autoComplete"];
1312
}
1413
export interface OtpInputRef {
1514
clear: () => void;
@@ -20,6 +19,7 @@ export interface Theme {
2019
containerStyle?: ViewStyle;
2120
inputsContainerStyle?: ViewStyle;
2221
pinCodeContainerStyle?: ViewStyle;
22+
filledPinCodeContainerStyle?: ViewStyle;
2323
pinCodeTextStyle?: TextStyle;
2424
focusStickStyle?: ViewStyle;
2525
focusedPinCodeContainerStyle?: ViewStyle;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-otp-entry",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "A fully modifiable OTP input Component for React Native",
55
"main": "dist/src/index.js",
66
"types": "dist/src/index.d.ts",

0 commit comments

Comments
 (0)