ecabs-components 0.0.60 → 0.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/nothing-here.svg +22 -0
- package/esm2020/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.mjs +9 -5
- package/esm2020/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.mjs +1 -1
- package/esm2020/lib/ecabs-increment/ecabs-increment.component.mjs +2 -2
- package/esm2020/lib/ecabs-picker-header/ecabs-picker-header.component.mjs +2 -2
- package/fesm2015/ecabs-components.mjs +13 -9
- package/fesm2015/ecabs-components.mjs.map +1 -1
- package/fesm2020/ecabs-components.mjs +13 -9
- package/fesm2020/ecabs-components.mjs.map +1 -1
- package/lib/base/consts/date-mask.consts.ts +70 -0
- package/lib/base/directives/date-mask.directive.module.ts +15 -0
- package/lib/base/directives/date-mask.directive.ts +58 -0
- package/lib/base/directives/digits-only.directive.module.ts +15 -0
- package/lib/base/directives/digits-only.directive.ts +129 -0
- package/lib/base/directives/number-border.directive.module.ts +14 -0
- package/lib/base/directives/number-border.directive.ts +57 -0
- package/lib/base/element-base.ts +72 -0
- package/lib/base/element-wrapper/element-wrapper.component.html +30 -0
- package/lib/base/element-wrapper/element-wrapper.component.ts +33 -0
- package/lib/base/element-wrapper/element-wrapper.module.ts +30 -0
- package/lib/base/hint/hint.component.html +1 -0
- package/lib/base/hint/hint.component.scss +0 -0
- package/lib/base/hint/hint.component.ts +12 -0
- package/lib/base/hint/hint.module.ts +13 -0
- package/lib/base/validation/validation.component.html +8 -0
- package/lib/base/validation/validation.component.scss +0 -0
- package/lib/base/validation/validation.component.ts +84 -0
- package/lib/base/validation/validation.module.ts +12 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.component.html +14 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.component.scss +16 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.component.ts +23 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.module.ts +13 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.html +11 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.scss +0 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.spec.ts +24 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.ts +12 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.module.ts +12 -0
- package/lib/ecabs-buttons/ecabs-buttons.component.html +18 -0
- package/lib/ecabs-buttons/ecabs-buttons.component.ts +54 -0
- package/lib/ecabs-buttons/ecabs-buttons.module.ts +13 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.d.ts +5 -3
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.html +27 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.scss +15 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.ts +86 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.module.ts +21 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.html +4 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.scss +0 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.spec.ts +23 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.ts +11 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.html +31 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.scss +10 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.spec.ts +24 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.ts +72 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.module.ts +28 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.html +4 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.scss +1 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.spec.ts +23 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.ts +11 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.html +31 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.scss +23 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.spec.ts +23 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.ts +113 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.module.ts +48 -0
- package/lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component.html +4 -0
- package/lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component.scss +14 -0
- package/lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component.ts +11 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.html +87 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.scss +68 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.spec.ts +23 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.ts +185 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.module.ts +36 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.html +4 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.scss +11 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.spec.ts +23 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.ts +10 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.html +107 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.scss +51 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.spec.ts +24 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.ts +206 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.module.ts +37 -0
- package/lib/ecabs-date-time-range-picker/time-range.directive.ts +38 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component.html +32 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component.scss +24 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component.ts +57 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.module.ts +12 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.html +27 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.scss +25 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.spec.ts +38 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.ts +49 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.module.ts +12 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.html +9 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.scss +0 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.spec.ts +34 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.ts +22 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.module.ts +11 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.html +33 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.scss +79 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.spec.ts +26 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.ts +77 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.module.ts +16 -0
- package/lib/ecabs-increment/ecabs-increment.component.html +18 -0
- package/lib/ecabs-increment/ecabs-increment.component.scss +33 -0
- package/lib/ecabs-increment/ecabs-increment.component.ts +74 -0
- package/lib/ecabs-increment/ecabs-increment.module.ts +16 -0
- package/lib/ecabs-input/ecabs-input.component.html +27 -0
- package/lib/ecabs-input/ecabs-input.component.ts +86 -0
- package/lib/ecabs-input/ecabs-input.module.ts +14 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.component.html +17 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.component.scss +24 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.component.ts +56 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.module.ts +21 -0
- package/lib/ecabs-loading/ecabs-loading.component.html +7 -0
- package/lib/ecabs-loading/ecabs-loading.component.spec.ts +24 -0
- package/lib/ecabs-loading/ecabs-loading.component.ts +11 -0
- package/lib/ecabs-loading/ecabs-loading.module.ts +11 -0
- package/lib/ecabs-loading/spinner/spinner.component.html +5 -0
- package/lib/ecabs-loading/spinner/spinner.component.scss +61 -0
- package/lib/ecabs-loading/spinner/spinner.component.spec.ts +24 -0
- package/lib/ecabs-loading/spinner/spinner.component.ts +11 -0
- package/lib/ecabs-note/ecabs-note.component.html +10 -0
- package/lib/ecabs-note/ecabs-note.component.scss +29 -0
- package/lib/ecabs-note/ecabs-note.component.ts +27 -0
- package/lib/ecabs-note/ecabs-note.module.ts +11 -0
- package/lib/ecabs-phone/ecabs-phone.component.html +17 -0
- package/lib/ecabs-phone/ecabs-phone.component.ts +108 -0
- package/lib/ecabs-phone/ecabs-phone.module.ts +15 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.component.html +12 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.component.scss +12 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.component.ts +61 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.module.ts +15 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.component.html +13 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.component.scss +16 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.component.ts +60 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.module.ts +20 -0
- package/lib/ecabs-select/ecabs-select.component.html +38 -0
- package/lib/ecabs-select/ecabs-select.component.ts +346 -0
- package/lib/ecabs-select/ecabs-select.module.ts +37 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.html +7 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.scss +11 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.spec.ts +34 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.ts +14 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.module.ts +14 -0
- package/lib/ecabs-table/ecabs-table.component.html +26 -0
- package/lib/ecabs-table/ecabs-table.component.scss +6 -0
- package/lib/ecabs-table/ecabs-table.component.spec.ts +24 -0
- package/lib/ecabs-table/ecabs-table.component.ts +42 -0
- package/lib/ecabs-table/ecabs-table.module.ts +19 -0
- package/lib/ecabs-textarea/ecabs-textarea.component.html +13 -0
- package/lib/ecabs-textarea/ecabs-textarea.component.ts +61 -0
- package/lib/ecabs-textarea/ecabs-textarea.module.ts +12 -0
- package/lib/ecabs-timepicker/componets/ecabs-time-list-panel/ecabs-time-list-panel.component.html +16 -0
- package/lib/ecabs-timepicker/componets/ecabs-time-list-panel/ecabs-time-list-panel.component.ts +126 -0
- package/lib/ecabs-timepicker/config.model.ts +5 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.component.html +36 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.component.scss +5 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.component.ts +330 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.module.ts +12 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.service.ts +28 -0
- package/lib/ecabs-validation/ecabs-validation.component.html +9 -0
- package/lib/ecabs-validation/ecabs-validation.component.scss +23 -0
- package/lib/ecabs-validation/ecabs-validation.component.ts +14 -0
- package/lib/ecabs-validation/ecabs-validation.module.ts +12 -0
- package/lib/models/bread-crumb.ts +5 -0
- package/lib/models/language.models.ts +0 -0
- package/lib/models/timepicker.models.ts +7 -0
- package/lib/models/validation.models.ts +4 -0
- package/lib/services/ecabs-components.service.ts +33 -0
- package/package.json +1 -1
- package/public-api.ts +58 -0
- package/styles/material/overrides/_form.scss +5 -0
- package/test.ts +27 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { Component, Input, HostBinding, HostListener, ElementRef, Injector, AfterViewInit } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR, NgControl, UntypedFormControl } from '@angular/forms';
|
|
3
|
+
import { FormTimePickerService } from './ecabs-timepicker.service';
|
|
4
|
+
import ElementBaseComponent from '../base/element-base';
|
|
5
|
+
import { ListPlacement, ListPosition } from '../models/timepicker.models';
|
|
6
|
+
|
|
7
|
+
@Component( {
|
|
8
|
+
selector: 'ecabs-timepicker',
|
|
9
|
+
templateUrl: './ecabs-timepicker.component.html',
|
|
10
|
+
styleUrls: [ 'ecabs-timepicker.component.scss' ],
|
|
11
|
+
providers: [
|
|
12
|
+
{
|
|
13
|
+
provide: NG_VALUE_ACCESSOR,
|
|
14
|
+
useExisting: EcabsTimepickerComponent,
|
|
15
|
+
multi: true,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
} )
|
|
19
|
+
export class EcabsTimepickerComponent extends ElementBaseComponent implements ControlValueAccessor, AfterViewInit {
|
|
20
|
+
@Input() showCloseIcon = true;
|
|
21
|
+
@Input() @HostBinding( 'class.form-timepicker-focused' ) focusedFlag = false;
|
|
22
|
+
@Input() listPlacement: ListPlacement = 'auto';
|
|
23
|
+
@Input() appendTo!: string;
|
|
24
|
+
@Input() min!: string;
|
|
25
|
+
@Input() max!: string;
|
|
26
|
+
@Input() showDayStart = true;
|
|
27
|
+
@Input() showDayEnd = false;
|
|
28
|
+
@Input() addSecond = true;
|
|
29
|
+
|
|
30
|
+
position: ListPosition = {};
|
|
31
|
+
_data = '';
|
|
32
|
+
_timePicker;
|
|
33
|
+
_input!: any;
|
|
34
|
+
listPosition: ListPosition = {};
|
|
35
|
+
caretPositionStart!: any;
|
|
36
|
+
caretPositionEnd!: any;
|
|
37
|
+
|
|
38
|
+
get data(): any {
|
|
39
|
+
return this._data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
set data( value: any ) {
|
|
43
|
+
this._data = value;
|
|
44
|
+
if ( this._data.length === 5 ) {
|
|
45
|
+
if ( this._data === '23:59' ) {
|
|
46
|
+
this.onChangeFn( this._data + ( this.addSecond ? ':59' : '' ) );
|
|
47
|
+
} else {
|
|
48
|
+
this.onChangeFn( this._data + ( this.addSecond ? ':00' : '' ) );
|
|
49
|
+
}
|
|
50
|
+
} else if ( this._data === '' ) {
|
|
51
|
+
this.onChangeFn( this._data );
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
private elementRef: ElementRef,
|
|
57
|
+
private timepickerService: FormTimePickerService,
|
|
58
|
+
private injector: Injector
|
|
59
|
+
) {
|
|
60
|
+
super();
|
|
61
|
+
this.placeholder = '00:00';
|
|
62
|
+
this._timePicker = this.elementRef.nativeElement;
|
|
63
|
+
setTimeout( () => {
|
|
64
|
+
this._input = this._timePicker.querySelector( 'input' );
|
|
65
|
+
} );
|
|
66
|
+
if ( !this.iconClass ) {
|
|
67
|
+
this.iconClass = this.timepickerService.getConfig().iconClass;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@HostListener( 'document:mousedown', [ '$event' ] )
|
|
72
|
+
handleMousedown( $event: MouseEvent ): void {
|
|
73
|
+
const target = $event.target as HTMLElement;
|
|
74
|
+
if (
|
|
75
|
+
target.closest( '.form-time-list' ) ||
|
|
76
|
+
target.closest( '.timeInputWrapper' ) === this._timePicker.querySelector( '.timeInputWrapper' )
|
|
77
|
+
) {
|
|
78
|
+
this._timePicker.querySelector( '.timeInputWrapper' ).focus();
|
|
79
|
+
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if ( this.focusedFlag ) {
|
|
83
|
+
this.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ngAfterViewInit(): void {
|
|
88
|
+
const ngControl: NgControl = this.injector.get( NgControl, null ) as NgControl;
|
|
89
|
+
if ( ngControl ) {
|
|
90
|
+
this.control = ngControl.control as UntypedFormControl;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
clearInput(): void {
|
|
95
|
+
this.data = '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
calcListPosition(): void {
|
|
99
|
+
const position = this._timePicker.querySelector( '.timeInputFieldWrapper' ).getBoundingClientRect();
|
|
100
|
+
if ( this.appendTo ) {
|
|
101
|
+
this.listPosition = {
|
|
102
|
+
left: position.x,
|
|
103
|
+
top: position.top + position.height,
|
|
104
|
+
width: position.width,
|
|
105
|
+
};
|
|
106
|
+
} else {
|
|
107
|
+
this.listPosition = {
|
|
108
|
+
left: 0,
|
|
109
|
+
top: position.height,
|
|
110
|
+
width: position.width,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
inputKeyDown( event: any ): boolean {
|
|
116
|
+
this.caretPositionStart = event.target.selectionStart;
|
|
117
|
+
this.caretPositionEnd = event.target.selectionEnd;
|
|
118
|
+
const key = event.key;
|
|
119
|
+
this.setCaretPosition( this._input );
|
|
120
|
+
switch ( this.checkSpecialKeys( key, this.caretPositionStart, this.caretPositionEnd ) ) {
|
|
121
|
+
case 'stop':
|
|
122
|
+
return false;
|
|
123
|
+
|
|
124
|
+
case 'tab':
|
|
125
|
+
this.close();
|
|
126
|
+
|
|
127
|
+
return false;
|
|
128
|
+
|
|
129
|
+
case 'arrow':
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if ( this.checkUnUsedKeys( key ) ) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const newData =
|
|
138
|
+
this.data.slice( 0, this.caretPositionStart ) + key + this.data.slice( this.caretPositionStart, this.data.length );
|
|
139
|
+
|
|
140
|
+
if ( this.checkOutOfRangeNumber( newData ) ) {
|
|
141
|
+
this.data = newData;
|
|
142
|
+
this.caretPositionStart++;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (
|
|
146
|
+
this.caretPositionStart === this.data.length &&
|
|
147
|
+
( this.data.length === 2 || ( this.data.length === 1 && parseInt( this.data ) > 2 ) )
|
|
148
|
+
) {
|
|
149
|
+
this.makeHourFull();
|
|
150
|
+
this.data += ':';
|
|
151
|
+
this.caretPositionStart++;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
checkSpecialKeys( key: any, selectionStart: any, selectionEnd: any ): 'stop' | 'continue' | 'tab' | 'arrow' {
|
|
158
|
+
if ( selectionStart !== selectionEnd && key !== 'ArrowLeft' && key !== 'ArrowRight' ) {
|
|
159
|
+
if ( !( this.data.slice( selectionStart, selectionEnd ).includes( ':' ) && selectionEnd !== this.data.length ) ) {
|
|
160
|
+
this.data = this.data.slice( 0, selectionStart ) + this.data.slice( selectionEnd, this.data.length );
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if ( selectionStart === selectionEnd && key === 'Backspace' ) {
|
|
164
|
+
if ( this.data.length > 0 ) {
|
|
165
|
+
if (
|
|
166
|
+
this.data[ selectionStart - 1 ] !== ':' ||
|
|
167
|
+
( this.data[ selectionStart - 1 ] === ':' && selectionStart === this.data.length )
|
|
168
|
+
) {
|
|
169
|
+
this.data = this.data.slice( 0, selectionStart - 1 ) + this.data.slice( selectionEnd, this.data.length );
|
|
170
|
+
this.caretPositionStart--;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return 'stop';
|
|
175
|
+
}
|
|
176
|
+
if ( key === 'Tab' || key === ' ' || key === ':' ) {
|
|
177
|
+
if ( !this.data.includes( ':' ) && this.data.length > 0 ) {
|
|
178
|
+
this.makeHourFull();
|
|
179
|
+
this.data += ':';
|
|
180
|
+
this.caretPositionStart++;
|
|
181
|
+
|
|
182
|
+
return 'stop';
|
|
183
|
+
}
|
|
184
|
+
if ( key === 'Tab' ) {
|
|
185
|
+
return 'tab';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return 'stop';
|
|
189
|
+
}
|
|
190
|
+
if ( key === 'ArrowRight' ) {
|
|
191
|
+
if ( this.caretPositionStart < this.data.length ) {
|
|
192
|
+
this.caretPositionStart++;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return 'arrow';
|
|
196
|
+
}
|
|
197
|
+
if ( key === 'ArrowLeft' ) {
|
|
198
|
+
if ( this.caretPositionStart > 0 ) {
|
|
199
|
+
this.caretPositionStart--;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return 'arrow';
|
|
203
|
+
}
|
|
204
|
+
if ( key === 'ArrowDown' && !this.focusedFlag ) {
|
|
205
|
+
this.show();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return 'continue';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
checkUnUsedKeys( key: string ): boolean {
|
|
212
|
+
const r = new RegExp( '[0-9]' );
|
|
213
|
+
|
|
214
|
+
return !r.test( key );
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
setCaretPosition( elem: any ): void {
|
|
218
|
+
setTimeout( () => {
|
|
219
|
+
if ( elem !== null ) {
|
|
220
|
+
if ( elem.createTextRange ) {
|
|
221
|
+
const range = elem.createTextRange();
|
|
222
|
+
range.move( 'character', this.caretPositionStart );
|
|
223
|
+
range.select();
|
|
224
|
+
} else {
|
|
225
|
+
if ( elem.selectionStart ) {
|
|
226
|
+
elem.focus();
|
|
227
|
+
elem.setSelectionRange( this.caretPositionStart, this.caretPositionStart );
|
|
228
|
+
} else {
|
|
229
|
+
elem.focus();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} );
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
checkOutOfRangeNumber( time: any ): boolean {
|
|
237
|
+
const hour = parseInt( time.split( ':' )[ 0 ], 10 );
|
|
238
|
+
let minute = -1;
|
|
239
|
+
if ( time.split( ':' ).length > 1 ) {
|
|
240
|
+
minute = parseInt( time.split( ':' )[ 1 ], 10 );
|
|
241
|
+
}
|
|
242
|
+
if ( hour < 24 && time.split( ':' )[ 0 ].length < 3 && minute < 60 ) {
|
|
243
|
+
if ( time.split( ':' ).length > 1 && time.split( ':' )[ 1 ].length > 2 ) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
makeHourFull(): void {
|
|
254
|
+
const hourPart = this.data.split( ':' )[ 0 ];
|
|
255
|
+
const minutePart = this.data.split( ':' ).length > 1 ? this.data.split( ':' )[ 1 ] : '';
|
|
256
|
+
if ( hourPart.length === 1 ) {
|
|
257
|
+
this.data = '0' + hourPart + ( minutePart ? ':' + minutePart : minutePart );
|
|
258
|
+
this.caretPositionStart++;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
makeMinuteFull(): void {
|
|
263
|
+
const hourPart = this.data.split( ':' )[ 0 ];
|
|
264
|
+
const minutePart = this.data.split( ':' ).length > 1 ? this.data.split( ':' )[ 1 ] : '';
|
|
265
|
+
if ( minutePart.length === 0 ) {
|
|
266
|
+
this.data = hourPart + ':00';
|
|
267
|
+
this.caretPositionStart += 2;
|
|
268
|
+
}
|
|
269
|
+
if ( minutePart.length === 1 ) {
|
|
270
|
+
this.data = hourPart + ':' + minutePart + '0';
|
|
271
|
+
this.caretPositionStart++;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
fixTimeToNearest(): void {
|
|
276
|
+
if ( this.data.length > 0 ) {
|
|
277
|
+
this.makeHourFull();
|
|
278
|
+
this.makeMinuteFull();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
//eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/no-empty-function
|
|
283
|
+
public onChangeFn = ( _: any ): void => { };
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
285
|
+
public onTouchedFn = (): void => { };
|
|
286
|
+
|
|
287
|
+
public registerOnChange( fn: any ): void {
|
|
288
|
+
this.onChangeFn = fn;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public registerOnTouched( fn: any ): void {
|
|
292
|
+
this.onTouchedFn = fn;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
public setDisabledState( isDisabled: boolean ): void {
|
|
296
|
+
this.disabled = isDisabled;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
public writeValue( obj: any ): void {
|
|
300
|
+
if ( obj ) {
|
|
301
|
+
obj = obj.toString();
|
|
302
|
+
let temp = '';
|
|
303
|
+
if ( obj.split( ':' ).length >= 2 ) {
|
|
304
|
+
temp = obj.split( ':' )[ 0 ] + ':' + obj.split( ':' )[ 1 ];
|
|
305
|
+
}
|
|
306
|
+
this._data = temp;
|
|
307
|
+
} else {
|
|
308
|
+
this._data = '';
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public onChange(): void {
|
|
313
|
+
this.onChangeFn( this.data );
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
show(): void {
|
|
317
|
+
this.calcListPosition();
|
|
318
|
+
this.focusedFlag = true;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
close( val = null ): void {
|
|
322
|
+
if ( val ) {
|
|
323
|
+
this.data = val;
|
|
324
|
+
} else {
|
|
325
|
+
this.fixTimeToNearest();
|
|
326
|
+
}
|
|
327
|
+
this.focusedFlag = false;
|
|
328
|
+
this.control?.markAsTouched();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { EcabsTimepickerComponent } from './ecabs-timepicker.component';
|
|
4
|
+
import { EcabsTimeListPanelComponent } from './componets/ecabs-time-list-panel/ecabs-time-list-panel.component';
|
|
5
|
+
import { ElementWrapperModule } from '../base/element-wrapper/element-wrapper.module';
|
|
6
|
+
|
|
7
|
+
@NgModule( {
|
|
8
|
+
declarations: [ EcabsTimepickerComponent, EcabsTimeListPanelComponent ],
|
|
9
|
+
imports: [ CommonModule, ElementWrapperModule ],
|
|
10
|
+
exports: [ EcabsTimeListPanelComponent, EcabsTimepickerComponent ],
|
|
11
|
+
} )
|
|
12
|
+
export class EcabsTimepickerModule { }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import { FormTimePickerConfig } from './config.model';
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
})
|
|
8
|
+
export class FormTimePickerService {
|
|
9
|
+
config: FormTimePickerConfig = {
|
|
10
|
+
dayEnd: 'Day End',
|
|
11
|
+
dayStart: 'Day Start',
|
|
12
|
+
iconClass: '',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
public closeSub = new Subject<boolean>();
|
|
16
|
+
|
|
17
|
+
setConfig(c: FormTimePickerConfig): void {
|
|
18
|
+
this.config = Object.assign(this.config, c);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getConfig(): FormTimePickerConfig {
|
|
22
|
+
return this.config;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
close(): void {
|
|
26
|
+
this.closeSub.next(true);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="form-validations">
|
|
2
|
+
<div class="header font-medium">{{ title }}</div>
|
|
3
|
+
<ecabs-validations-messages
|
|
4
|
+
*ngFor="let validation of validations"
|
|
5
|
+
[showValidationOnNotTouched]="true"
|
|
6
|
+
[element]="form.controls[validation.controlName]"
|
|
7
|
+
[updatedErrors]="validation.errors"
|
|
8
|
+
></ecabs-validations-messages>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import "../../styles/scss/utilities/variables";
|
|
2
|
+
:host ::ng-deep {
|
|
3
|
+
.form-validations {
|
|
4
|
+
background-color: var(--color-white);
|
|
5
|
+
box-shadow: $box-shadow-default;
|
|
6
|
+
border-radius: $border-radius-base * 2;
|
|
7
|
+
padding: 1.5rem;
|
|
8
|
+
line-height: 1.125rem;
|
|
9
|
+
|
|
10
|
+
.form-field__validation__item {
|
|
11
|
+
font-size: 1rem !important;
|
|
12
|
+
color: var(--color-black);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.form-field--invalid {
|
|
17
|
+
transform: translateY(0.825rem);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.header {
|
|
21
|
+
color: var(--color-error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import { UntypedFormGroup } from '@angular/forms';
|
|
3
|
+
import { FormControlValidation } from '../models/validation.models';
|
|
4
|
+
|
|
5
|
+
@Component( {
|
|
6
|
+
selector: 'ecabs-validation',
|
|
7
|
+
templateUrl: './ecabs-validation.component.html',
|
|
8
|
+
styleUrls: [ './ecabs-validation.component.scss' ],
|
|
9
|
+
} )
|
|
10
|
+
export class EcabsValidationComponent {
|
|
11
|
+
@Input() validations: FormControlValidation[];
|
|
12
|
+
@Input() form: UntypedFormGroup;
|
|
13
|
+
@Input() title: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { EcabsValidationComponent } from './ecabs-validation.component';
|
|
4
|
+
import { EcabsValidationModule } from '../base/validation/validation.module';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@NgModule( {
|
|
8
|
+
declarations: [ EcabsValidationComponent ],
|
|
9
|
+
imports: [ CommonModule, EcabsValidationModule ],
|
|
10
|
+
exports: [ EcabsValidationComponent ],
|
|
11
|
+
} )
|
|
12
|
+
export class EcabsValidationViewModule { }
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Injectable({
|
|
4
|
+
providedIn: 'root',
|
|
5
|
+
})
|
|
6
|
+
export class EcabsComponentsService {
|
|
7
|
+
config: EcabsComponentsConfig = {
|
|
8
|
+
errorMessages: [
|
|
9
|
+
{ type: 'required', message: '[label] is required' },
|
|
10
|
+
{ type: 'minlength', message: '[label] should be atleast [requiredLength] character' },
|
|
11
|
+
{ type: 'maxLength', message: '[label] should be maximum [requiredLength] character' },
|
|
12
|
+
{ type: 'min', message: '[label] should be minmum [min]' },
|
|
13
|
+
{ type: 'max', message: '[label] should be maximum [max]' },
|
|
14
|
+
{ type: 'minValue', message: '[label] should be minmum [requiredMin]' },
|
|
15
|
+
{ type: 'maxValue', message: '[label] should be maximum [requiredMax]' },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
constructor() {}
|
|
19
|
+
setConfig(c: EcabsComponentsConfig) {
|
|
20
|
+
this.config.errorMessages = c.errorMessages;
|
|
21
|
+
}
|
|
22
|
+
getConfig(): EcabsComponentsConfig {
|
|
23
|
+
return this.config;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface EcabsComponentsConfig {
|
|
28
|
+
errorMessages: ErrorMessage[];
|
|
29
|
+
}
|
|
30
|
+
export interface ErrorMessage {
|
|
31
|
+
type: string;
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
package/package.json
CHANGED
package/public-api.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export * from './lib/ecabs-loading/ecabs-loading.module';
|
|
2
|
+
export * from './lib/ecabs-loading/ecabs-loading.component';
|
|
3
|
+
export * from './lib/ecabs-loading/spinner/spinner.component';
|
|
4
|
+
export * from './lib/ecabs-buttons/ecabs-buttons.component';
|
|
5
|
+
export * from './lib/ecabs-buttons/ecabs-buttons.module';
|
|
6
|
+
export * from './lib/ecabs-input/ecabs-input.component';
|
|
7
|
+
export * from './lib/ecabs-input/ecabs-input.module';
|
|
8
|
+
export * from './lib/ecabs-select/ecabs-select.module';
|
|
9
|
+
export * from './lib/ecabs-select/ecabs-select.component';
|
|
10
|
+
export * from './lib/ecabs-textarea/ecabs-textarea.component';
|
|
11
|
+
export * from './lib/ecabs-textarea/ecabs-textarea.module';
|
|
12
|
+
export * from './lib/services/ecabs-components.service';
|
|
13
|
+
export * from './lib/base/validation/validation.component';
|
|
14
|
+
export * from './lib/base/validation/validation.module';
|
|
15
|
+
export * from './lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component';
|
|
16
|
+
export * from './lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.module';
|
|
17
|
+
export * from './lib/ecabs-date-picker/ecabs-date-picker.component';
|
|
18
|
+
export * from './lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component';
|
|
19
|
+
export * from './lib/ecabs-date-time-picker/ecabs-date-time-picker.module';
|
|
20
|
+
export * from './lib/ecabs-date-time-picker/ecabs-date-time-picker.component';
|
|
21
|
+
export * from './lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component';
|
|
22
|
+
export * from './lib/ecabs-date-picker/ecabs-date-picker.module';
|
|
23
|
+
export * from './lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.module';
|
|
24
|
+
export * from './lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component';
|
|
25
|
+
export * from './lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component';
|
|
26
|
+
export * from './lib/ecabs-date-time-range-picker/time-range.directive';
|
|
27
|
+
export * from './lib/ecabs-increment/ecabs-increment.module';
|
|
28
|
+
export * from './lib/ecabs-increment/ecabs-increment.component';
|
|
29
|
+
export * from './lib/ecabs-phone/ecabs-phone.module';
|
|
30
|
+
export * from './lib/ecabs-phone/ecabs-phone.component';
|
|
31
|
+
export * from './lib/ecabs-radio-button-list/ecabs-radio-button-list.module';
|
|
32
|
+
export * from './lib/ecabs-radio-button-list/ecabs-radio-button-list.component';
|
|
33
|
+
export * from './lib/ecabs-timepicker/ecabs-timepicker.module';
|
|
34
|
+
export * from './lib/ecabs-timepicker/ecabs-timepicker.component';
|
|
35
|
+
export * from './lib/ecabs-timepicker/componets/ecabs-time-list-panel/ecabs-time-list-panel.component';
|
|
36
|
+
export * from './lib/ecabs-timepicker/ecabs-timepicker.service';
|
|
37
|
+
export * from './lib/ecabs-empty-placeholder/ecabs-empty-placeholder.module';
|
|
38
|
+
export * from './lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component';
|
|
39
|
+
export * from './lib/ecabs-expansion-panel/ecabs-expansion-panel.module';
|
|
40
|
+
export * from './lib/ecabs-expansion-panel/ecabs-expansion-panel.component';
|
|
41
|
+
export * from './lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.module';
|
|
42
|
+
export * from './lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component';
|
|
43
|
+
export * from './lib/ecabs-table/ecabs-table.module';
|
|
44
|
+
export * from './lib/ecabs-table/ecabs-table.component';
|
|
45
|
+
export * from './lib/ecabs-note/ecabs-note.module';
|
|
46
|
+
export * from './lib/ecabs-note/ecabs-note.component';
|
|
47
|
+
export * from './lib/ecabs-dialog-confirm/ecabs-dialog-confirm.module';
|
|
48
|
+
export * from './lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component';
|
|
49
|
+
export * from './lib/ecabs-dialog-message/ecabs-dialog-message.module';
|
|
50
|
+
export * from './lib/ecabs-dialog-message/ecabs-dialog-message.component';
|
|
51
|
+
export * from './lib/ecabs-breadcrumb/ecabs-breadcrumb.module';
|
|
52
|
+
export * from './lib/ecabs-breadcrumb/ecabs-breadcrumb.component';
|
|
53
|
+
export * from './lib/ecabs-language-selector/ecabs-language-selector.module';
|
|
54
|
+
export * from './lib/ecabs-language-selector/ecabs-language-selector.component';
|
|
55
|
+
export * from './lib/ecabs-active-status-filter/ecabs-active-status-filter.module';
|
|
56
|
+
export * from './lib/ecabs-active-status-filter/ecabs-active-status-filter.component';
|
|
57
|
+
export * from './lib/ecabs-validation/ecabs-validation.module';
|
|
58
|
+
export * from './lib/ecabs-validation/ecabs-validation.component';
|
package/test.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
+
|
|
3
|
+
import 'zone.js';
|
|
4
|
+
import 'zone.js/testing';
|
|
5
|
+
import { getTestBed } from '@angular/core/testing';
|
|
6
|
+
import {
|
|
7
|
+
BrowserDynamicTestingModule,
|
|
8
|
+
platformBrowserDynamicTesting
|
|
9
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
+
|
|
11
|
+
declare const require: {
|
|
12
|
+
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
+
<T>(id: string): T;
|
|
14
|
+
keys(): string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// First, initialize the Angular testing environment.
|
|
19
|
+
getTestBed().initTestEnvironment(
|
|
20
|
+
BrowserDynamicTestingModule,
|
|
21
|
+
platformBrowserDynamicTesting(),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Then we find all the tests.
|
|
25
|
+
const context = require.context('./', true, /\.spec\.ts$/);
|
|
26
|
+
// And load the modules.
|
|
27
|
+
context.keys().forEach(context);
|