@logo-software/timepicker
Version:
Timepicker helps users select and set a specific time in your timesheet in 24-hour format.
141 lines (140 loc) • 4.92 kB
TypeScript
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
import { ElementRef, OnInit } from '@angular/core';
export interface MaskConditions {
cases: {
position: number;
regexp: string;
}[];
placeholder: string;
}
/**
* An input mask is a string of characters that indicates the format of valid input values. You can help
* people enter data correctly into input by providing input masks for fields that contain data that is
* always formatted a certain way. For example, you can use an input mask to make
* sure that people enter correctly formatted phone numbers into a phone number field.
*
* __Usage Example:__
*
* <input [(ngModel)]="tourDate" masker />
*
* For __Time__ correction example, this will be check for HH:mm format:
* ```html
* <input
* logoMask
* [regexp]="'^[0-2]{1}$|^[0-2]{1}[0-9]{1}$|^[0-2]{1}[0-9]{1}[0-5]{1}$|^[0-2]{1}[0-9]{1}[0-5]{1}[0-9]{1}$'"
* [placeholder]="HH:mm"
* />
* ```
* @stacked-example(MaskDirective, logo/core-sample/mask-directive-showcase/mask-directive-showcase.component)
* For __Date__ correction example, this will be check for YYYY-MM-DD format:
* ```html
* <input
* logoMask
* [placeholder]="'YYYY-MM-DD'"
* [regexp]="'^\\d+$'"
* />
* ```
*
* Full usage example with contains conditions:
*
* ```html
* <input
* logoMask
* [(ngModel)]="value"
* (change)="onDateChangeHandler($event)"
* (click)="onInputClick($event)"
* [placeholder]="'XX-00000'"
* [conditions]="[{cases: [{position: 2, regexp:'^[0-9]$'}], placeholder: 'X-0000000000'}]"
* [case]="'lower'"
* [regexp]="'^X{1,2}$|^X{1,2}[0-9]*$'"
* [maskType]="'date'"
* #dateRef
* />
* ```
*
* __Another Example:__
* ```html
* <input
* logoMask
* [placeholder]="'XX-0000000000'"
* [conditions]="[{cases: [{position: 2, regexp: '^[0-9]$'}], placeholder: 'X-0000000000'}]"
* [regexp]="'^[A-ZĞÜŞİÖÇ]{1,2}$|^[A-ZĞÜŞİÖÇ]{1,2}[0-9]*$'"
* [case]="'upper'"
* />
* ```
*/
export declare class MaskDirective implements OnInit {
private elementRef;
ngModel: string;
/**
* This input set to date if will be use for date formatted
*/
private maskType;
/**
* Case use for upper or lower case selection
* For example [case]="'lower'" it makes all char to lowercase
*/
private case;
/**
* Conditions uses for set special status different than defined placeholder.
* If placeholder set to 'XX-00000' and 'X-00000' also acceptable you need this property
* For example [conditions]="[{cases: [{position: 2, regexp:'^[0-9]$'}], placeholder: 'X-0000000000'}]"
* With this at 2 position if inserted char is a digit (regexp) then placeholder will be redefine to 'X-0000000000'
*/
private conditions;
private ngModelChange;
private list;
private oldValue;
private input;
private defaultChars;
private acceptedChars;
constructor(elementRef: ElementRef);
private _regexp;
/**
* This propert removes inserted char if format not same with defined pattern.
* For example [regexp]="'^9{1,3}$|^9{3}[0-9]*$'"
* Above example just accepts beginning 999 then accept digits like 999123456
*/
get regexp(): string;
set regexp(value: string);
private _placeholder;
/**
* Used for format check. What format will be used for display text.
* if need some special chars like "- / or space" this will be looks their position
* and will be added automatically
* For example : [placeholder] = {TK-1234} This format will be add "-" char automatically to third cursor position.
* And also will restrict insert more than char length to textbox.
*/
get placeholder(): string;
set placeholder(value: string);
private _maxLength;
/**
* This property used for definition of acceptable max char length of the input field
* For example, [maxLength]='13' it sets the input file's acceptable chars length to max 13
*/
get maxLength(): number;
set maxLength(value: number);
private _extendedChars;
get extendedChars(): string;
set extendedChars(value: string);
ngOnInit(): void;
setPlaceholder(placeholder: string): void;
setInputAttributes(): void;
clear(value: any): any;
isValid(value: any): boolean;
onFocus($event: KeyboardEvent): void;
onBlur($event: KeyboardEvent): void;
onKeyDown($event: KeyboardEvent): void;
emit(value: any): void;
conditionCheck(): void;
mask(value: any): any;
onInput($event: any): void;
}