ng-otp-box 0.0.1 → 0.0.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/README.md +62 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,24 +1,74 @@
|
|
|
1
1
|
# NgOtpBox
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ng-otp-box is a flexible, reusable OTP (One-Time Password) input component for Angular applications.
|
|
4
|
+
It supports numeric, text, mixed, and password OTP, with built-in validation, paste handling, masking/unmasking, and Angular Reactive Forms support.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Installation
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
#### This library supports Angular version 15 and above
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save ng-otp-box
|
|
11
|
+
```
|
|
9
12
|
|
|
10
|
-
##
|
|
13
|
+
## Usage
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
### Import the Module
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
For **Modules**:
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
```typescript
|
|
20
|
+
import { NgOtpBoxModule } from 'ng-otp-box';
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
@NgModule({
|
|
23
|
+
imports: [
|
|
24
|
+
...otherModules,
|
|
25
|
+
NgOtpBoxModule,
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
export class AppModule {}
|
|
29
|
+
```
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
For **Standalone Components**:
|
|
21
32
|
|
|
22
|
-
|
|
33
|
+
```typescript
|
|
34
|
+
import { NgOtpBoxComponent } from 'ng-otp-box';
|
|
35
|
+
|
|
36
|
+
@Component({
|
|
37
|
+
standalone: true,
|
|
38
|
+
imports: [NgOtpBoxComponent],
|
|
39
|
+
})
|
|
40
|
+
export class YourComponent {}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<ng-otp-input (otpChange)="onOtpChange($event)" [otpLength]="6" type="masked"></ng-otp-input>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Component Inputs/Outputs
|
|
49
|
+
|
|
50
|
+
Name | Type | Required | Default | Description |
|
|
51
|
+
|-----------------|----------|----------|---------|-----------------------------------------------------------------------------|
|
|
52
|
+
| `onOtpChange` | `Output` | No | -- | Emits the OTP value on change it will give your message value and otp form valid state so. Not required if using `formControl`
|
|
53
|
+
| `pastValue` | function | No | -- | Allows to paste the value. |
|
|
54
|
+
| `config` | object | NO | `6` | Configuration object for customization it will take default otp length as 6 (see **Config Options** below). |
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Config Options
|
|
58
|
+
|
|
59
|
+
Name | Type | Required | Default | Description |
|
|
60
|
+
|-----------------|----------|----------|---------|-----------------------------------------------------------------------------|
|
|
61
|
+
| `otpLength` | number | No | 6 | Number of OTP input fields. |
|
|
62
|
+
| `inputType` |'number' | 'text' | 'mixed' | 'masked' | No | `number` | Determines the allowed input type:-
|
|
63
|
+
`• number → digits only
|
|
64
|
+
• text → uppercase letters
|
|
65
|
+
• mixed → alphanumeric
|
|
66
|
+
• masked → password/masked input with checkbox to unmask` |
|
|
67
|
+
| `pasteAllowed` | boolean | No | 6 | Allows pasting a full OTP value. |
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
Show your support by starring the repo!
|
|
23
74
|
|
|
24
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
package/package.json
CHANGED