libs/upp-wdgt/src/components/upp-address/upp-address.ts
Component for address input with an integrated modal picker.
ControlValueAccessor
OnInit
AfterViewInit
OnDestroy
| changeDetection | ChangeDetectionStrategy.OnPush |
| providers |
{
provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UppAddressComponent), multi: true
}
|
| selector | upp-address |
| styleUrls | ./upp-address.scss |
| templateUrl | ./upp-address.html |
Properties |
|
Methods |
Inputs |
Outputs |
Accessors |
constructor(controlContainer: ControlContainer, change: ChangeDetectorRef, modalCtrl: ModalController)
|
||||||||||||||||
|
Constructor for dependency injection.
Parameters :
|
| auto |
Type : boolean
|
Default value : false
|
|
Whether the address picker should open automatically. |
| errornfo |
Type : ErrorInfo
|
Default value : {}
|
|
A mapping of error keys to their respective error messages. |
| formControlName |
Type : string
|
Default value : ''
|
|
Form control name for integration with Angular forms. |
| placeholder |
Type : string
|
Default value : ''
|
|
Placeholder text for the input field. |
| title |
Type : string
|
Default value : ''
|
|
Title of the input field. |
| value |
Type : string | MapAddress | null
|
|
/ |
| Changed |
Type : EventEmitter
|
|
Emits when the input value changes. |
| ngAfterViewInit |
ngAfterViewInit()
|
|
Lifecycle hook: Called after view initialization.
Returns :
void
|
| ngOnDestroy |
ngOnDestroy()
|
|
Lifecycle hook: Cleans up resources on destroy.
Returns :
void
|
| ngOnInit |
ngOnInit()
|
|
Lifecycle hook: Initializes the component.
Returns :
void
|
| onChange |
onChange()
|
|
Handles value changes.
Returns :
void
|
| registerOnChange | ||||||||
registerOnChange(fn: any)
|
||||||||
|
Registers a callback function to be called when the input value changes.
Required by
Parameters :
Returns :
void
|
| registerOnTouched | ||||||||
registerOnTouched(fn: any)
|
||||||||
|
Registers a callback function to be called when the input is touched.
Required by
Parameters :
Returns :
void
|
| Async showPicker |
showPicker()
|
|
Shows the address picker modal.
Returns :
unknown
|
| writeValue | ||||||
writeValue(value: string | MapAddress | null)
|
||||||
|
Writes a value to the input. Required by
Parameters :
Returns :
void
|
| Public formControl |
Type : AbstractControl | null
|
Default value : null
|
|
Form control instance. |
| Public formGroup |
Type : FormGroup | null
|
Default value : null
|
|
Associated form group (if used within a form). |
| ShowTitle |
getShowTitle()
|
|
Determines whether the title should be displayed.
Returns :
boolean
|
| viewTitle |
getviewTitle()
|
|
Gets the displayed title.
Returns :
string
|
| viewValue |
getviewValue()
|
|
Gets the displayed value.
Returns :
string
|
| value | ||||||||
getvalue()
|
||||||||
|
/
Returns :
string | MapAddress | null
|
||||||||
setvalue(v: string | MapAddress | null)
|
||||||||
|
Sets a new value for the input.
This updates the internal state, triggers the
Parameters :
Returns :
void
|
<div class="address-box" [ngClass]="{ 'has-title': ShowTitle } " tabindex="0" (click)="showPicker()" (keydown.enter)="showPicker()" (keydown.space)="showPicker()">
<ion-label [ngClass]="ShowTitle ? 'input-title': 'placeholder'">
{{viewTitle}}<ion-icon *ngIf="!value" name="location-outline"></ion-icon>
</ion-label>
<ion-label [ngClass]="{'hide': !ShowTitle}">
{{viewValue}}
</ion-label>
</div>
<upp-er-address *ngIf="formGroup"
[form]="formGroup"
[name]="formControlName"
[value]="value"
[errornfo]="errornfo"
></upp-er-address>
./upp-address.scss
:host {
width: 100%;
.address-box {
position: relative;
height: 32px;
padding: 7px 10px;
margin-top: 10px;
margin-bottom: 10px;
background-color: rgba(var(--ion-color-dark-rgb), .1);
border-radius: 5px;
&.has-title {
margin-top: 25px;
}
}
ion-label {
cursor: pointer;
width: 100%;
margin: 0px;
padding: 0px;
--color: var(--ion-color-dark);
transition: all 0.3s;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
&.placeholder {
padding: 0px;
color: var(--ion-color-medium);
--color: var(--ion-color-medium);
opacity: 0.75;
}
&.hide {
position: absolute;
top: 25px;
opacity: 0;
pointer-events: none;
}
ion-icon {
position: absolute;
top: 5px;
right: 5px;
color: var(--ion-color-medium);
font-size: 22px;
}
&.input-title {
position: absolute;
top: -20px;
left: 0px;
font-size: 12px;
padding: 0px;
color: var(--ion-color-medium);
--color: var(--ion-color-medium);
}
}
}