Skip to content

Commit fe7b81a

Browse files
committed
Release v 1.4.0:
- Have fixed the issue #26 - Have implemented the feature #27 - Have added the method for an input field focusing
1 parent f9660d5 commit fe7b81a

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed

README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,48 @@ Example with only bottom borders:
137137
| <b>`isCharsCode`</b> | boolean | false | When `true` inputted code can contain any char and not only digits from 0 to 9. If the input parameter <b>`code`</b> contains non digits chars and `isCharsCode` is `false` the value will be ignored |
138138
| <b>`isPrevFocusableAfterClearing`</b> | boolean | true | When `true` after the input value deletion the caret will be moved to the previous input immediately. If `false` then after the input value deletion the caret will stay on the current input and be moved to the previous input only if the current input is empty |
139139
| <b>`isFocusingOnLastByClickIfFilled`</b> | boolean | false | When `true` and the code is filled then the focus will be moved to the last input element when clicked |
140-
| <b>`initialFocusField`</b> | number | - | The index of the input box for initial focusing. When the component will appear the focus will be placed on the input with this index. <br/> Note: If you need to dynamically hide the component it is needed to use <b>*ngIf</b> directive instead of the `[hidden]` attribute. |
141-
| <b>`code`</b> | string / number | - | The input code value for the component. If the parameter contains non digits chars and `isCharsCode` is `false` the value will be <b>ignored |
140+
| <b>`initialFocusField`</b> | number | - | The index of the input box for initial focusing. When the component will appear the focus will be placed on the input with this index. <br/> Note: If you need to dynamically hide the component it is needed to use <b>*ngIf</b> directive instead of the `[hidden]` attribute |
141+
| <b>`code`</b> | string / number | - | The input code value for the component. If the parameter contains non digits chars and `isCharsCode` is `false` the value will be <b>ignored</b> |
142142

143143
#### Events
144144

145145
| Event | Description |
146146
|----------|--------------------|
147147
| `codeChanged` | Will be called every time when a user changed the code |
148148
| `codeCompleted` | Will be called only if a user entered full code |
149+
150+
## Methods
151+
152+
For calling the component's methods it is required to access the component inside the template or page script.
153+
It can be reached as follows.
154+
155+
Inside the page template HTML add a template ref:
156+
157+
```html
158+
<code-input
159+
...
160+
#codeInput
161+
...
162+
>
163+
</code-input>
164+
```
165+
166+
Inside a page script attach the component:
167+
168+
```ts
169+
...
170+
// adding to the imports
171+
import {CodeInputComponent} from 'angular-code-input';
172+
...
173+
// adding to the page props
174+
@ViewChild('codeInput') codeInput !: CodeInputComponent;
175+
...
176+
// calling the component's methods somewhere in the page.
177+
// IMPORTANT: it will be accessible only after the view initialization!
178+
this.codeInput.reset();
179+
```
180+
181+
| Method | Description |
182+
|----------------|--------------------|
183+
| <b>`focusOnField(index: number): void`</b> | Focuses the input caret on the input box with the passed index |
184+
| <b>`reset(isChangesEmitting = false): void`</b> | <p>Resets the component values in the following way:</p><p>if the `code` option is supplied then the value will be reset to the `code` option value. If the `code` option is not supplied then the component will be reset to empty values.</p><p>if the `initialFocusField` option is supplied then the caret will be focused in that filed after reset.</p><p>if the `isChangesEmitting` param is passed then changes will be emitted</p>|

angular-code-input/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.4.0 (09.02.2021)
2+
**Note:** The following changes have been made:
3+
- Have fixed the issue 'initialFocusField not working for 0 as index bug' [#26](https://github.com/AlexMiniApps/angular-code-input/issues/26)
4+
- Have implemented the feature 'Clear the inputs?' [#27](https://github.com/AlexMiniApps/angular-code-input/issues/27)
5+
- Have added the method for an input field focusing
6+
17
# 1.3.3 (21.01.2021)
28
**Note:** Have implemented the feature:
39

angular-code-input/README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,48 @@ Example with only bottom borders:
137137
| <b>`isCharsCode`</b> | boolean | false | When `true` inputted code can contain any char and not only digits from 0 to 9. If the input parameter <b>`code`</b> contains non digits chars and `isCharsCode` is `false` the value will be ignored |
138138
| <b>`isPrevFocusableAfterClearing`</b> | boolean | true | When `true` after the input value deletion the caret will be moved to the previous input immediately. If `false` then after the input value deletion the caret will stay on the current input and be moved to the previous input only if the current input is empty |
139139
| <b>`isFocusingOnLastByClickIfFilled`</b> | boolean | false | When `true` and the code is filled then the focus will be moved to the last input element when clicked |
140-
| <b>`initialFocusField`</b> | number | - | The index of the input box for initial focusing. When the component will appear the focus will be placed on the input with this index. <br/> Note: If you need to dynamically hide the component it is needed to use <b>*ngIf</b> directive instead of the `[hidden]` attribute. |
141-
| <b>`code`</b> | string / number | - | The input code value for the component. If the parameter contains non digits chars and `isCharsCode` is `false` the value will be <b>ignored |
140+
| <b>`initialFocusField`</b> | number | - | The index of the input box for initial focusing. When the component will appear the focus will be placed on the input with this index. <br/> Note: If you need to dynamically hide the component it is needed to use <b>*ngIf</b> directive instead of the `[hidden]` attribute |
141+
| <b>`code`</b> | string / number | - | The input code value for the component. If the parameter contains non digits chars and `isCharsCode` is `false` the value will be <b>ignored</b> |
142142

143143
#### Events
144144

145145
| Event | Description |
146146
|----------|--------------------|
147147
| `codeChanged` | Will be called every time when a user changed the code |
148148
| `codeCompleted` | Will be called only if a user entered full code |
149+
150+
## Methods
151+
152+
For calling the component's methods it is required to access the component inside the template or page script.
153+
It can be reached as follows.
154+
155+
Inside the page template HTML add a template ref:
156+
157+
```html
158+
<code-input
159+
...
160+
#codeInput
161+
...
162+
>
163+
</code-input>
164+
```
165+
166+
Inside a page script attach the component:
167+
168+
```ts
169+
...
170+
// adding to the imports
171+
import {CodeInputComponent} from 'angular-code-input';
172+
...
173+
// adding to the page props
174+
@ViewChild('codeInput') codeInput !: CodeInputComponent;
175+
...
176+
// calling the component's methods somewhere in the page.
177+
// IMPORTANT: it will be accessible only after the view initialization!
178+
this.codeInput.reset();
179+
```
180+
181+
| Method | Description |
182+
|----------------|--------------------|
183+
| <b>`focusOnField(index: number): void`</b> | Focuses the input caret on the input box with the passed index |
184+
| <b>`reset(isChangesEmitting = false): void`</b> | <p>Resets the component values in the following way:</p><p>if the `code` option is supplied then the value will be reset to the `code` option value. If the `code` option is not supplied then the component will be reset to empty values.</p><p>if the `initialFocusField` option is supplied then the caret will be focused in that filed after reset.</p><p>if the `isChangesEmitting` param is passed then changes will be emitted</p>|

angular-code-input/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-code-input",
3-
"version": "1.3.3",
3+
"version": "1.4.0",
44
"description": "Code or pin code input for Angular 7 - 11+ / Ionic 4, 5 + projects",
55
"keywords": ["angular", "pincode", "angular-pincode", "otp", "code-input", "angular-otp", "ionic-otp", "ionic-code-input", "ionic-pincode"],
66
"author": "Alexander Dmitrenko",

0 commit comments

Comments
 (0)