Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogermax committed Jan 14, 2023
1 parent af5747a commit 20ecad4
Show file tree
Hide file tree
Showing 7 changed files with 1,368 additions and 889 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,93 @@
<mat-form-field [appearance]="appearance">
<mat-label *ngIf="label">{{label}}</mat-label>
<mat-icon *ngIf="this.value" [svgIcon]="this.value?.alpha2Code?.toLowerCase()" class="mr-12 s-20 secondary-text"
matSuffix></mat-icon>
<input (blur)="onBlur()" (input)="inputChanged($event?.target?.value)"
[class]="class"
[matAutocomplete]="this.countryAutocomplete"
[placeholder]="this.placeHolder"
[readonly]="this.readonly"
[tabIndex]="tabIndex"
[value]="showCallingCode ? (this.value ? (this.value?.name + ' (' + this.value?.callingCode + ')') : '') : this.value?.name"
[required]="this.required"
[disabled]="this.disabled || this.loadingDB"
[autocomplete]="this.autocomplete"
[name]="this.name"
aria-label="country"
matInput type="text"
#inputElement>
<mat-progress-bar *ngIf="this.loadingDB || this.loading" mode="buffer"></mat-progress-bar>
<mat-autocomplete #countryAutocomplete="matAutocomplete" (opened)="autocompleteScroll()"
(optionSelected)="onOptionsSelected($event)">
<mat-option *ngFor="let country of filteredOptions" [value]="country?.name">
<mat-icon [svgIcon]="country?.alpha2Code?.toLowerCase()"></mat-icon>
<small *ngIf="!showCallingCode">{{ [country?.name, country?.alpha3Code] | joinStrings }}</small>
<small *ngIf="showCallingCode">{{ [country?.name, '(' + country?.callingCode + ')'] | joinStrings:' ' }}</small>
</mat-option>
</mat-autocomplete>
<mat-label *ngIf="label">{{ label }}</mat-label>
<mat-icon
*ngIf="this.value"
[svgIcon]="this.value?.alpha2Code?.toLowerCase()"
class="mr-12 s-20 secondary-text"
matSuffix
></mat-icon>
<input
*ngIf="!!formControl"
(blur)="onBlur()"
(input)="inputChanged($event?.target?.value)"
[class]="class"
[matAutocomplete]="this.countryAutocomplete"
[placeholder]="this.placeHolder"
[readonly]="this.readonly"
[tabIndex]="tabIndex"
[value]="formControl.value?.name"
[formControl]="formControl"
[autocomplete]="this.autocomplete"
[name]="this.name"
aria-label="country"
matInput
type="text"
#inputElement
/>
<input
*ngIf="!formControl"
(blur)="onBlur()"
(input)="inputChanged($event?.target?.value)"
[class]="class"
[matAutocomplete]="this.countryAutocomplete"
[placeholder]="this.placeHolder"
[readonly]="this.readonly"
[tabIndex]="tabIndex"
[value]="
showCallingCode
? this.value
? this.value?.name + ' (' + this.value?.callingCode + ')'
: ''
: this.value?.name
"
[required]="this.required"
[disabled]="this.disabled || this.loadingDB"
[autocomplete]="this.autocomplete"
[name]="this.name"
aria-label="country"
matInput
type="text"
#inputElement
/>
<mat-progress-bar
*ngIf="this.loadingDB || this.loading"
mode="buffer"
></mat-progress-bar>
<mat-autocomplete
#countryAutocomplete="matAutocomplete"
(opened)="autocompleteScroll()"
(optionSelected)="onOptionsSelected($event)"
>
<mat-option *ngFor="let country of filteredOptions" [value]="country?.name">
<div class="d-flex">
<mat-icon [svgIcon]="country?.alpha2Code?.toLowerCase()"></mat-icon>
<small
class="country-list-item"
[title]="[country?.name, country?.alpha3Code] | joinStrings"
*ngIf="!showCallingCode"
>{{ [country?.name, country?.alpha3Code] | joinStrings }}</small
>
<small
class="country-list-item"
[title]="
[country?.name, '(' + country?.callingCode + ')']
| joinStrings : ' '
"
*ngIf="showCallingCode"
>{{
[country?.name, "(" + country?.callingCode + ")"]
| joinStrings : " "
}}</small
>
</div>
</mat-option>
</mat-autocomplete>
<mat-icon
class="cursor-pointer pos-rel"
matSuffix
*ngIf="cleareable && !!value"
(click)="clear()"
>cancel</mat-icon
>
<mat-error *ngIf="formControl && formControl.invalid">{{ error }}</mat-error>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.cursor-pointer {
cursor: pointer;
}
.pos-rel {
position: relative;
}
.country-list-item {
float: right;
margin-left: 0.5rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.d-flex {
display: flex;
width: 100%;
}
Loading

0 comments on commit 20ecad4

Please sign in to comment.