Skip to content

Commit 9f2f1dc

Browse files
Merge pull request #7 from keyurparalkar/chore/chore-updates
Chore/chore updates
2 parents c790dcb + 42d8ce5 commit 9f2f1dc

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
![headless-otp-header-image](media/otp-doc-header.001.jpeg)
1+
![headless-passcode-header-image](media/react-headless-passcode.001.jpeg)
22

3-
# react-headless-otp
3+
# react-headless-passcode
44

5-
A headless UI for building easy to use OTP component.
5+
A headless UI for building easy to use passcode component.
66

7-
*What is an OTP component?*
7+
*What is an passcode component?*
88
It is a group of input elements with each element only accepting one character. This component is generally used in authentication flows.
99

1010
* [Installation](#installation)
@@ -16,23 +16,23 @@ It is a group of input elements with each element only accepting one character.
1616
## Installation
1717

1818
```shell
19-
yarn add react-headless-otp
19+
yarn add react-headless-passcode
2020
```
2121

2222

2323
## Usage
2424

2525
```tsx
26-
import { useOtp } from "react-headless-otp";
26+
import { usePasscode } from "react-headless-passcode";
2727
```
2828

29-
With the `useOtp` hook you just need to pass the `arrayValue` default property and in return you get the `array` in which the actual otp value is stored, various event hanlders that handles the focus management between multiple inputs and `refs` that references each input element.
29+
With the `usePasscode` hook you just need to pass the `arrayValue` default property and in return you get the `array` in which the actual passcode value is stored, various event hanlders that handles the focus management between multiple inputs and `refs` that references each input element.
3030

3131
For example:
3232

3333
```tsx
34-
const OTPComponent = () => {
35-
const { array, getEventHandlers, refs } = useOtp({
34+
const PasscodeComponent = () => {
35+
const { array, getEventHandlers, refs } = usePasscode({
3636
arrayValue: [0, 0, 0, 0, 0, 0],
3737
});
3838

@@ -62,25 +62,25 @@ const OTPComponent = () => {
6262
```
6363

6464
>**NOTE:**
65-
> It is important to initialize the `refs` object with the current input element because this is how the `useOtp` is able to track the current index and manage the focused state across multiple inputs. Make sure to assign this element to the `refs` or else the focus won't change!!
65+
> It is important to initialize the `refs` object with the current input element because this is how the `usepasscode` is able to track the current index and manage the focused state across multiple inputs. Make sure to assign this element to the `refs` or else the focus won't change!!
6666
```tsx
6767
ref={(el) => el && (refs.current[index] = el)}
6868
```
6969

7070
## Features
7171
- Allow entering alpha numeric characters
7272
- Expose a flag: `isComplete` that tells whether all the input boxes are filled or not
73-
- Expose a state variable: `currentFocusedIndex`. It tells us the currently focused index of the OTP component.
73+
- Expose a state variable: `currentFocusedIndex`. It tells us the currently focused index of the passcode component.
7474
- Exposes event handlers that can be seamlessly used with the input element.
75-
- OTP value can be pasted partially, fully, from start, or from middle.
75+
- Passcode value can be pasted partially, fully, from start, or from middle.
7676

7777
## API
7878

79-
The `useOtp` hook accepts following props
80-
| Prop Name | Type | Description | | |
81-
|---------------- |------------------------ |----------------------------------------------------------------------- |--- |--- |
82-
| arrayValue | `(number \| string)[]` | Default array value that helps to determine the size of the component | | |
83-
| isAlphaNumeric | `boolean` | If `true`, allows to enter alpha numeric value in the component | | |
79+
The `usePasscode` hook accepts following props
80+
| Prop Name | Type | Description |
81+
|---------------- |------------------------ |----------------------------------------------------------------------- |
82+
| arrayValue | `(number \| string)[]` | Default array value that helps to determine the size of the component |
83+
| isAlphaNumeric | `boolean` | If `true`, allows to enter alpha numeric value in the component |
8484

8585
The hook returns an object that consists of:
8686

media/otp-doc-header.001.jpeg

-162 KB
Binary file not shown.
198 KB
Loading

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "react-headless-otp",
2+
"name": "react-headless-passcode",
33
"version": "0.1.4",
4-
"description": "A headless UI for building easy to use OTP component",
4+
"description": "A headless UI for building easy to use passcode component",
55
"keywords": [
6-
"otp",
6+
"passcode",
77
"headless-ui",
88
"react"
99
],
@@ -13,13 +13,13 @@
1313
"email": "[email protected]"
1414
}
1515
],
16-
"homepage": "https://github.com/keyurparalkar/react-headless-otp",
16+
"homepage": "https://github.com/keyurparalkar/react-headless-passcode",
1717
"repository": {
18-
"url": "https://github.com/keyurparalkar/react-headless-otp",
18+
"url": "https://github.com/keyurparalkar/react-headless-passcode",
1919
"type": "git"
2020
},
2121
"bugs": {
22-
"url": "https://github.com/keyurparalkar/react-headless-otp/issues"
22+
"url": "https://github.com/keyurparalkar/react-headless-passcode/issues"
2323
},
2424
"main": "build/index.js",
2525
"module": "build/index.js",
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import {
1313
shouldPreventDefault,
1414
} from "../utils";
1515

16-
type OtpProps = {
16+
type PasscodeProps = {
1717
arrayValue: (number | string)[];
1818
isAlphaNumeric?: boolean;
1919
};
2020

21-
const useOtp = (props: OtpProps) => {
21+
const usePasscode = (props: PasscodeProps) => {
2222
const { arrayValue, isAlphaNumeric = false } = props;
2323
const [array, setArray] = useState(arrayValue);
2424
const [currentForcusedIndex, setCurrentFocusedIndex] = useState(0);
@@ -157,4 +157,4 @@ import {
157157
};
158158
};
159159

160-
export default useOtp;
160+
export default usePasscode;

package/lib/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import useOtp from "./hook/useOtp";
1+
import usePasscode from "./hook/usePasscode";
22

3-
export { useOtp };
3+
export { usePasscode };

0 commit comments

Comments
 (0)