Skip to content

Commit

Permalink
feat(input): maxLength of 15
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Balet committed Jul 17, 2024
1 parent 821ae73 commit 79b4657
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ If you want to show the sample number for the country selected or errors , use m
| enableSearch | `boolean` | `false` | Whether to display a search bar to help filter down the list of countries |
| format | `string` | `default` | Format of "as you type" input. Possible values: national, international, default |
| inputPlaceholder | `string` | `undefined` | Placeholder for the input component. |
| maxLength | `number` | `15` | max length of the input. |
| onlyCountries | `string[]` | `[]` | List of manually selected country abbreviations, which will appear in the dropdown. |
| preferredCountries | `string[]` | `[]` | List of country abbreviations, which will appear at the top. |
| resetOnChange | `boolean` | `false` | Reset input on country change |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mat-input-tel",
"version": "18.1.2",
"version": "18.2.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
6 changes: 5 additions & 1 deletion projects/ngx-mat-input-tel-tester/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class AppComponent implements AfterViewInit {
@ViewChild(NgxMatInputTelComponent) phoneInput: NgxMatInputTelComponent | undefined

phoneForm = new FormGroup<PhoneForm>({
phone: new FormControl(null, [Validators.required]),
phone: new FormControl(null, [Validators.required, Validators.maxLength(9)]),
})

profileForm = new FormGroup<ProfileForm>({
Expand All @@ -65,5 +65,9 @@ export class AppComponent implements AfterViewInit {
if (this.phoneInput && this.phoneInput.matMenu) {
this.phoneInput.matMenu.panelClass = 'custom-panel'
}

this.phoneForm.valueChanges.subscribe((value) => {
console.log('phoneForm.valueChanges', value)
})
}
}
1 change: 1 addition & 0 deletions projects/ngx-mat-input-tel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ If you want to show the sample number for the country selected or errors , use m
| enableSearch | `boolean` | `false` | Whether to display a search bar to help filter down the list of countries |
| format | `string` | `default` | Format of "as you type" input. Possible values: national, international, default |
| inputPlaceholder | `string` | `undefined` | Placeholder for the input component. |
| maxLength | `number` | `15` | max length of the input. |
| onlyCountries | `string[]` | `[]` | List of manually selected country abbreviations, which will appear in the dropdown. |
| preferredCountries | `string[]` | `[]` | List of country abbreviations, which will appear at the top. |
| resetOnChange | `boolean` | `false` | Reset input on country change |
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-mat-input-tel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mat-input-tel",
"version": "18.1.2",
"version": "18.2.0",
"author": {
"name": "Raphaël Balet",
"email": "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
[placeholder]="inputPlaceholder"
[disabled]="disabled"
#focusable
[maxlength]="maxLength"
/>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ export class NgxMatInputTelComponent

@Input() autocomplete: 'off' | 'tel' = 'off'
@Input() cssClass?: string
@Input({ transform: booleanAttribute }) enablePlaceholder = true
@Input({ transform: booleanAttribute }) enableSearch = false
@Input() errorStateMatcher: ErrorStateMatcher = this._defaultErrorStateMatcher
@Input() inputPlaceholder: string = ''
@Input() maxLength: string | number = 15
@Input() name?: string
@Input() onlyCountries: string[] = []
@Input() preferredCountries: string[] = []
@Input({ transform: booleanAttribute }) resetOnChange = false
@Input() searchPlaceholder = 'Search ...'
@Input({ transform: booleanAttribute }) enablePlaceholder = true
@Input({ transform: booleanAttribute }) enableSearch = false
@Input({ transform: booleanAttribute }) resetOnChange = false
@Input()
set format(value: PhoneNumberFormat) {
this._format = value
Expand Down

0 comments on commit 79b4657

Please sign in to comment.