libs/upp-base/src/modules/alert.ts
A custom Angular component for keyboard-based input.
Supports integration with Angular Forms through ControlValueAccessor.
Provides custom behavior for price and number types, and supports kiosk mode.
ControlValueAccessor
OnInit
AfterViewInit
OnChanges
OnDestroy
| changeDetection | ChangeDetectionStrategy.OnPush |
| providers |
{
provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => modalInputComponent), multi: true
}
|
| selector | upp-modal-input |
| styleUrls | ./input/modal-input.scss |
| templateUrl | ./input/modal-input.html |
Properties |
|
Methods |
Inputs |
Outputs |
Accessors |
constructor(change: ChangeDetectorRef, platform: platformService)
|
||||||||||||
|
Constructs an instance of
Parameters :
|
| autocomplete |
Type : string
|
Default value : 'do-not-autofill'
|
|
Configures autocomplete behavior for the input. |
| disabled |
Type : boolean
|
Default value : false
|
|
Disables the input when set to true. |
| kiosk |
Type : boolean
|
Default value : true
|
|
Enables or disables kiosk mode for the input. |
| name |
Type : string
|
Default value : 'none'
|
|
Name of the input control. |
| placeholder |
Type : string
|
Default value : ''
|
|
Placeholder text for the input. |
| readonly |
Type : boolean
|
Default value : false
|
|
Indicates if the input should be readonly. |
| type |
Type : string
|
Default value : ''
|
|
Type of the input (e.g., |
| value |
Type : string
|
|
/ |
| Changed |
Type : EventEmitter
|
|
Emits the current value when it changes. |
| Focus |
Type : EventEmitter
|
|
Emits an event when the input gains focus. |
| ngAfterViewInit |
ngAfterViewInit()
|
|
Lifecycle hook. Called after the view is initialized. Configures kiosk mode and subscribes to platform changes.
Returns :
void
|
| ngOnChanges |
ngOnChanges()
|
|
Lifecycle hook. Updates the component when inputs change.
Returns :
void
|
| ngOnDestroy |
ngOnDestroy()
|
|
Lifecycle hook. Cleans up subscriptions on destroy.
Returns :
void
|
| ngOnInit |
ngOnInit()
|
|
Lifecycle hook. Initializes the component and configures initial values.
Returns :
void
|
| onFocus | ||||||||
onFocus(value: boolean)
|
||||||||
|
Handles focus events and emits
Parameters :
Returns :
void
|
| onInput | ||||||||
onInput(event: Event)
|
||||||||
|
Handles the
Parameters :
Returns :
void
|
| OnKeyPress | ||||||||
OnKeyPress(key: string)
|
||||||||
|
Simulates a key press for the input element.
Parameters :
Returns :
void
|
| onKeyUp | ||||||||
onKeyUp(event: KeyboardEvent)
|
||||||||
|
Handles the
Parameters :
Returns :
void
|
| onKiosk | ||||||||
onKiosk(event: Event)
|
||||||||
|
Handles changes when in kiosk mode.
Parameters :
Returns :
void
|
| OnShowPassword |
OnShowPassword()
|
|
Toggles the visibility of the password input field.
Changes the input type between
Returns :
void
|
| registerOnChange | ||||||||
registerOnChange(fn: any)
|
||||||||
|
Registers a callback function to be called when the value changes.
Parameters :
Returns :
void
|
| registerOnTouched | ||||||||
registerOnTouched(fn: any)
|
||||||||
|
Registers a callback function to be called when the input is touched.
Parameters :
Returns :
void
|
| setDisabledState | ||||||||
setDisabledState(isDisabled: boolean)
|
||||||||
|
Sets the disabled state of the input.
Parameters :
Returns :
void
|
| SetFocus |
SetFocus()
|
|
Sets focus on the input element.
Returns :
void
|
| writeValue | ||||||
writeValue(value: any)
|
||||||
|
Writes a value to the component. Required by
Parameters :
Returns :
void
|
| Public _focus |
Default value : false
|
|
Tracks if the input currently has focus. |
| _input |
Type : any
|
Decorators :
@ViewChild('input', {static: false})
|
|
Reference to the native input element. |
| Public _kiosk |
Default value : false
|
|
Indicates if the component is in kiosk mode. |
| Public _price |
Type : string
|
Default value : ''
|
| Public isDisabled |
Default value : false
|
|
Internal flag indicating if the input is disabled. |
| nativeElement |
getnativeElement()
|
|
Native element reference for the input.
Returns :
any
|
| Price |
getPrice()
|
|
Gets the formatted price value.
Returns :
string
|
| _text |
get_text()
|
|
Determines the type of the input field.
Returns
Returns :
string
|
| ShowPassword |
getShowPassword()
|
|
Indicates whether the password input is visible ( |
| value | ||||||||
getvalue()
|
||||||||
|
/
Returns :
string
|
||||||||
setvalue(v: string)
|
||||||||
|
Sets a new value for the input.
This updates the internal state, triggers the
Parameters :
Returns :
void
|
<div class="input-container">
<ng-container *ngIf="type === 'price'">
<span class="price">
<ng-container *ngIf="_kiosk !== true">
<input #input
class="form-control"
type="number"
[name]="name"
[placeholder]="placeholder"
[value]="value"
[readonly]="readonly"
[disabled]="disabled"
[ngClass]="{ 'disabled': disabled }"
(input)="onInput($event)"
(keyup)="onKeyUp($event)"
(focus)="onFocus(true)"
(blur)="onFocus(false)"
role="presentation"
[autocomplete]="autocomplete">
<div class="label" [ngClass]="{ 'placeholder': (!value && !_focus), 'focus': _focus, 'disabled': disabled }">
{{Price}}
</div>
</ng-container>
<ng-container *ngIf="_kiosk === true">
<input #input
uppNgkiosk
class="form-control"
data-kioskboard-type="price"
type="text"
[name]="name"
[placeholder]="placeholder"
[value]="_price"
[readonly]="readonly"
[disabled]="disabled"
[ngClass]="{ 'disabled': disabled }"
(change)="onKiosk($event)"
(focus)="onFocus(true)"
(blur)="onFocus(false)"
role="presentation"
[autocomplete]="autocomplete">
<div class="label" [ngClass]="{ 'placeholder': (!value && !_focus), 'focus': _focus, 'disabled': disabled }">
{{Price}}
</div>
</ng-container>
</span>
</ng-container>
<ng-container *ngIf="type !== 'price'">
<ng-container *ngIf="_kiosk !== true">
<input #input
class="form-control"
[type]="_text"
[name]="name"
[placeholder]="placeholder"
[value]="value"
[readonly]="readonly"
[disabled]="disabled"
[ngClass]="{ 'disabled': disabled }"
(input)="onInput($event)"
(keyup)="onKeyUp($event)"
(focus)="onFocus(true)"
(blur)="onFocus(false)"
role="presentation"
[autocomplete]="autocomplete">
</ng-container>
<ng-container *ngIf="_kiosk === true">
<input *ngIf="type === 'number'" #input
uppNgkiosk
class="form-control"
data-kioskboard-type="num"
type="text"
[name]="name"
[value]="value"
[placeholder]="placeholder"
[readonly]="readonly"
[disabled]="disabled"
[ngClass]="{ 'disabled': disabled }"
(change)="onKiosk($event)"
(focus)="onFocus(true)"
(blur)="onFocus(false)"
role="presentation"
[autocomplete]="autocomplete">
<input *ngIf="type !== 'number'" #input
uppNgkiosk
class="form-control"
data-kioskboard-type="all"
data-kioskboard-specialcharacters="true"
[type]="_text"
[name]="name"
[value]="value"
[placeholder]="placeholder"
[readonly]="readonly"
[disabled]="disabled"
[ngClass]="{ 'disabled': disabled }"
(change)="onKiosk($event)"
(focus)="onFocus(true)"
(blur)="onFocus(false)"
role="presentation"
[autocomplete]="autocomplete">
</ng-container>
</ng-container>
<div *ngIf="type === 'password'" class="password-toggle" tabindex="0" (click)="OnShowPassword()" (keydown.enter)="OnShowPassword()" (keydown.space)="OnShowPassword()" role="button" aria-label="Toggle password visibility">
<ion-icon [hidden]="ShowPassword === true" color="medium" name="eye-outline"></ion-icon>
<ion-icon [hidden]="ShowPassword !== true" color="medium" name="eye-off-outline" x></ion-icon>
</div>
</div>
./input/modal-input.scss
/* The animation code */
@keyframes inputcursor {
0% { border-right: 1px solid white; }
50% { border-right: 1px solid transparent; }
100% { border-right: 1px solid white; }
}
[hidden] {
display: none !important;
}
:host {
width: 100%;
display: inline-block;
::placeholder {
color: var(--upp-input-placeholder, grey);
opacity: 0.75;
}
input, input:focus, input:active {
width: 100%;
background: transparent;
border: none;
outline: none;
text-align: inherit;
padding: 6px 0px;
&:disabled{
opacity: .6;
}
}
input[type=number],
input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
margin: 0;
}
.price {
position: relative;
input {
opacity: 0 !important;
z-index: 2;
}
.label {
position: absolute;
height: 100%;
width: fit-content;
top: 0px;
left: 8px;
text-align: inherit;
pointer-events: none;
z-index: 1;
animation-name: none;
&.focus {
animation-name: inputcursor;
animation-duration: 1.5s;
animation-iteration-count: infinite;
}
&.placeholder {
color: var(--ion-color-dark);
opacity: .4;
}
&.disabled {
opacity: .6;
}
}
}
.input-container {
display: flex;
align-items: center;
position: relative;
width: 100%;
.password-toggle {
position: absolute;
margin-top: 2px;
right: 10px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
}
}
}