File

libs/upp-wdgt/src/components/upp-address/upp-address.ts

Description

Component for address input with an integrated modal picker.

Implements

ControlValueAccessor OnInit AfterViewInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

constructor(controlContainer: ControlContainer, change: ChangeDetectorRef, modalCtrl: ModalController)

Constructor for dependency injection.

Parameters :
Name Type Optional Description
controlContainer ControlContainer No

Optional control container for form integration.

change ChangeDetectorRef No

Change detection service.

modalCtrl ModalController No

Controller for managing modals.

Inputs

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

/

Outputs

Changed
Type : EventEmitter

Emits when the input value changes.

Methods

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 ControlValueAccessor.

Parameters :
Name Type Optional Description
fn any No
  • The callback function.
Returns : void
registerOnTouched
registerOnTouched(fn: any)

Registers a callback function to be called when the input is touched. Required by ControlValueAccessor.

Parameters :
Name Type Optional Description
fn any No
  • The callback function.
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 ControlValueAccessor.

Parameters :
Name Type Optional
value string | MapAddress | null No
Returns : void

Properties

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).

Accessors

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()

/

setvalue(v: string | MapAddress | null)

Sets a new value for the input. This updates the internal state, triggers the onChange and onTouch callbacks, and emits the uppChanged event.

Parameters :
Name Type Optional Description
v string | MapAddress | null No
  • The new value to set.
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);
        }    
    }    
}

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""