From 9fd30fb552531f362d16aa5f930b1841d58f5400 Mon Sep 17 00:00:00 2001 From: anday013 Date: Fri, 12 Jan 2024 23:44:04 +0100 Subject: [PATCH] build: release version 1.4.1 --- dist/src/OtpInput/OtpInput.js | 9 ++++++--- dist/src/OtpInput/OtpInput.test.js | 11 +++++++++++ dist/src/OtpInput/OtpInput.types.d.ts | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/dist/src/OtpInput/OtpInput.js b/dist/src/OtpInput/OtpInput.js index 48cbba5..4c8bc37 100644 --- a/dist/src/OtpInput/OtpInput.js +++ b/dist/src/OtpInput/OtpInput.js @@ -8,8 +8,8 @@ const VerticalStick_1 = require("./VerticalStick"); const useOtpInput_1 = require("./useOtpInput"); exports.OtpInput = (0, react_1.forwardRef)((props, ref) => { const { models: { text, inputRef, focusedInputIndex }, actions: { clear, handlePress, handleTextChange, focus }, forms: { setTextWithRef }, } = (0, useOtpInput_1.useOtpInput)(props); - const { numberOfDigits, autoFocus = true, hideStick, focusColor = "#A4D0A4", focusStickBlinkingDuration, secureTextEntry = false, autoComplete = "sms-otp", theme = {}, } = props; - const { containerStyle, inputsContainerStyle, pinCodeContainerStyle, pinCodeTextStyle, focusStickStyle, focusedPinCodeContainerStyle, } = theme; + const { numberOfDigits, autoFocus = true, hideStick, focusColor = "#A4D0A4", focusStickBlinkingDuration, secureTextEntry = false, theme = {}, } = props; + const { containerStyle, inputsContainerStyle, pinCodeContainerStyle, pinCodeTextStyle, focusStickStyle, focusedPinCodeContainerStyle, filledPinCodeContainerStyle, } = theme; (0, react_1.useImperativeHandle)(ref, () => ({ clear, focus, setValue: setTextWithRef })); return ( @@ -25,6 +25,9 @@ exports.OtpInput = (0, react_1.forwardRef)((props, ref) => { focusedPinCodeContainerStyle && isFocusedInput ? { ...focusedPinCodeContainerStyle } : {}, + filledPinCodeContainerStyle && Boolean(char) + ? { ...filledPinCodeContainerStyle } + : {}, ]} testID="otp-input"> {isFocusedInput && !hideStick ? () : ( {char && secureTextEntry ? "•" : char} @@ -32,6 +35,6 @@ exports.OtpInput = (0, react_1.forwardRef)((props, ref) => { ); })} - + ); }); diff --git a/dist/src/OtpInput/OtpInput.test.js b/dist/src/OtpInput/OtpInput.test.js index 78e7bd5..c5214b9 100644 --- a/dist/src/OtpInput/OtpInput.test.js +++ b/dist/src/OtpInput/OtpInput.test.js @@ -56,6 +56,17 @@ describe("OtpInput", () => { const inputs = react_native_1.screen.getAllByTestId("otp-input"); expect(inputs).toHaveLength(numberOfDigits); }); + test("filledPinCodeContainerStyle should allow for new style when digit is present", () => { + renderOtpInput({ + theme: { filledPinCodeContainerStyle: { borderBottomColor: "red" } }, + }); + const input = react_native_1.screen.getByTestId("otp-input-hidden"); + react_native_1.fireEvent.changeText(input, "12"); + const inputs = react_native_1.screen.getAllByTestId("otp-input"); + expect(inputs[0]).toHaveStyle({ borderBottomColor: "red" }); + expect(inputs[1]).toHaveStyle({ borderBottomColor: "red" }); + expect(inputs[2]).not.toHaveStyle({ borderBottomColor: "red" }); + }); }); describe("Logic", () => { test("should split text on screen from the text written in the hidden input", () => { diff --git a/dist/src/OtpInput/OtpInput.types.d.ts b/dist/src/OtpInput/OtpInput.types.d.ts index d5d383b..282728f 100644 --- a/dist/src/OtpInput/OtpInput.types.d.ts +++ b/dist/src/OtpInput/OtpInput.types.d.ts @@ -1,4 +1,4 @@ -import { ColorValue, TextInputProps, TextStyle, ViewStyle } from "react-native"; +import { ColorValue, TextStyle, ViewStyle } from "react-native"; export interface OtpInputProps { numberOfDigits: number; autoFocus?: boolean; @@ -9,7 +9,6 @@ export interface OtpInputProps { focusStickBlinkingDuration?: number; secureTextEntry?: boolean; theme?: Theme; - autoComplete?: TextInputProps["autoComplete"]; } export interface OtpInputRef { clear: () => void; @@ -20,6 +19,7 @@ export interface Theme { containerStyle?: ViewStyle; inputsContainerStyle?: ViewStyle; pinCodeContainerStyle?: ViewStyle; + filledPinCodeContainerStyle?: ViewStyle; pinCodeTextStyle?: TextStyle; focusStickStyle?: ViewStyle; focusedPinCodeContainerStyle?: ViewStyle; diff --git a/package-lock.json b/package-lock.json index 9ac6e84..0a74beb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-otp-entry", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-native-otp-entry", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "devDependencies": { "@testing-library/jest-native": "^5.4.3", diff --git a/package.json b/package.json index ba0c542..d40237f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-otp-entry", - "version": "1.4.0", + "version": "1.4.1", "description": "A fully modifiable OTP input Component for React Native", "main": "dist/src/index.js", "types": "dist/src/index.d.ts",