i-tech-shared-components 1.1.6 → 1.1.9
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/.npmignore +2 -0
- package/README.md +23 -23
- package/esm2022/i-tech-shared-components.mjs +5 -0
- package/esm2022/lib/components/autocomplete-select/autocomplete-select.component.mjs +409 -0
- package/esm2022/lib/components/button/button.component.mjs +122 -0
- package/esm2022/lib/components/clear-value/clear-value.component.mjs +34 -0
- package/esm2022/lib/components/date-picker/date-picker.component.mjs +111 -0
- package/esm2022/lib/components/date-range-datepicker/date-range-datepicker.component.mjs +118 -0
- package/esm2022/lib/components/icon-button/icon-button.component.mjs +49 -0
- package/esm2022/lib/components/menu/menu.component.mjs +51 -0
- package/esm2022/lib/components/text/text-input.component.mjs +73 -0
- package/esm2022/lib/directives/date-mask.directive.mjs +92 -0
- package/esm2022/lib/directives/input-mask.directive.mjs +92 -0
- package/esm2022/lib/interfaces/app-input.interface.mjs +2 -0
- package/esm2022/lib/interfaces/autocomplete-configs.interface.mjs +2 -0
- package/esm2022/lib/interfaces/button-types.enum.mjs +17 -0
- package/esm2022/lib/interfaces/dropdown-selection.constants.mjs +12 -0
- package/esm2022/lib/pipes/array-to-string.pipe.mjs +17 -0
- package/esm2022/lib/pipes/generate-error-messages.pipe.mjs +31 -0
- package/esm2022/lib/pipes/get-value-by-key-from-object.pipe.mjs +45 -0
- package/esm2022/lib/services/input.service.mjs +29 -0
- package/esm2022/public-api.mjs +20 -0
- package/fesm2022/i-tech-shared-components.mjs +1216 -0
- package/fesm2022/i-tech-shared-components.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/autocomplete-select/autocomplete-select.component.d.ts +84 -0
- package/lib/components/button/button.component.d.ts +65 -0
- package/lib/components/clear-value/clear-value.component.d.ts +9 -0
- package/lib/components/date-picker/date-picker.component.d.ts +35 -0
- package/lib/components/date-range-datepicker/date-range-datepicker.component.d.ts +36 -0
- package/lib/components/icon-button/icon-button.component.d.ts +14 -0
- package/lib/components/menu/menu.component.d.ts +28 -0
- package/lib/components/text/text-input.component.d.ts +21 -0
- package/lib/directives/date-mask.directive.d.ts +25 -0
- package/lib/directives/input-mask.directive.d.ts +21 -0
- package/lib/interfaces/app-input.interface.d.ts +31 -0
- package/lib/interfaces/autocomplete-configs.interface.d.ts +37 -0
- package/lib/interfaces/button-types.enum.d.ts +15 -0
- package/lib/interfaces/dropdown-selection.constants.d.ts +10 -0
- package/lib/pipes/array-to-string.pipe.d.ts +7 -0
- package/lib/pipes/generate-error-messages.pipe.d.ts +10 -0
- package/lib/pipes/get-value-by-key-from-object.pipe.d.ts +7 -0
- package/lib/services/input.service.d.ts +7 -0
- package/package.json +32 -19
- package/{src/public-api.ts → public-api.d.ts} +16 -20
- package/theme/_buttons.scss +63 -63
- package/theme/_color_themes.scss +136 -136
- package/theme/_date_picker.scss +77 -77
- package/theme/_form_fields.scss +112 -112
- package/theme/_icon-button.scss +123 -123
- package/theme/_label.scss +119 -119
- package/theme/_mat-selects.scss +248 -248
- package/theme/_menu.scss +9 -9
- package/theme/_text_input.scss +28 -28
- package/theme/variables/_colors.scss +20 -20
- package/theme.scss +31 -33
- package/docs/README.md +0 -87
- package/docs/components/autocomplete-select/autocomplete-select.component/README.md +0 -13
- package/docs/components/autocomplete-select/autocomplete-select.component/classes/AutocompleteSelectComponent.md +0 -793
- package/docs/components/button/button.component/README.md +0 -13
- package/docs/components/button/button.component/classes/ButtonComponent.md +0 -191
- package/docs/components/button/button.component.spec/README.md +0 -7
- package/docs/components/clear-value/clear-value.component/README.md +0 -13
- package/docs/components/clear-value/clear-value.component/classes/ClearValueComponent.md +0 -47
- package/docs/components/date-picker/date-picker.component/README.md +0 -13
- package/docs/components/date-picker/date-picker.component/classes/DatePickerComponent.md +0 -253
- package/docs/components/date-range-datepicker/date-range-datepicker.component/README.md +0 -13
- package/docs/components/date-range-datepicker/date-range-datepicker.component/classes/DateRangeDatepickerComponent.md +0 -341
- package/docs/components/icon-button/icon-button.component/README.md +0 -13
- package/docs/components/icon-button/icon-button.component/classes/IconButtonComponent.md +0 -107
- package/docs/components/label/label.component/README.md +0 -13
- package/docs/components/label/label.component/classes/LabelComponent.md +0 -97
- package/docs/components/menu/menu.component/README.md +0 -13
- package/docs/components/menu/menu.component/classes/MenuComponent.md +0 -139
- package/docs/components/text/text-input.component/README.md +0 -13
- package/docs/components/text/text-input.component/classes/TextInputComponent.md +0 -133
- package/docs/interfaces/app-input.interface/README.md +0 -13
- package/docs/interfaces/app-input.interface/interfaces/AppInputInterface.md +0 -297
- package/docs/interfaces/autocomplete-configs.interface/README.md +0 -13
- package/docs/interfaces/autocomplete-configs.interface/interfaces/AutocompleteConfigsInterface.md +0 -357
- package/docs/interfaces/button-types.enum/README.md +0 -13
- package/docs/interfaces/button-types.enum/enumerations/ButtonType.md +0 -69
- package/docs/interfaces/dropdown-selection.constants/README.md +0 -17
- package/docs/interfaces/dropdown-selection.constants/enumerations/DropdownSelectionType.md +0 -37
- package/docs/interfaces/dropdown-selection.constants/variables/DropdownItemIcon.md +0 -27
- package/docs/interfaces/label-type.enum/README.md +0 -13
- package/docs/interfaces/label-type.enum/enumerations/LabelTypeEnum.md +0 -127
- package/docs/services/input.service/README.md +0 -13
- package/docs/services/input.service/classes/InputService.md +0 -31
- package/ng-package.json +0 -17
- package/src/README.md +0 -0
- package/src/lib/components/autocomplete-select/autocomplete-select.component.html +0 -211
- package/src/lib/components/autocomplete-select/autocomplete-select.component.scss +0 -58
- package/src/lib/components/autocomplete-select/autocomplete-select.component.ts +0 -430
- package/src/lib/components/autocomplete-select/loader.svg +0 -6
- package/src/lib/components/button/button.component.css +0 -0
- package/src/lib/components/button/button.component.html +0 -48
- package/src/lib/components/button/button.component.spec.ts +0 -23
- package/src/lib/components/button/button.component.ts +0 -106
- package/src/lib/components/clear-value/clear-value.component.ts +0 -44
- package/src/lib/components/date-picker/date-picker.component.html +0 -61
- package/src/lib/components/date-picker/date-picker.component.ts +0 -75
- package/src/lib/components/date-range-datepicker/date-range-datepicker.component.html +0 -44
- package/src/lib/components/date-range-datepicker/date-range-datepicker.component.ts +0 -105
- package/src/lib/components/icon-button/icon-button.component.html +0 -27
- package/src/lib/components/icon-button/icon-button.component.scss +0 -0
- package/src/lib/components/icon-button/icon-button.component.ts +0 -37
- package/src/lib/components/label/label.component.html +0 -15
- package/src/lib/components/label/label.component.ts +0 -33
- package/src/lib/components/menu/menu.component.html +0 -20
- package/src/lib/components/menu/menu.component.scss +0 -9
- package/src/lib/components/menu/menu.component.ts +0 -39
- package/src/lib/components/text/text-input.component.html +0 -91
- package/src/lib/components/text/text-input.component.ts +0 -73
- package/src/lib/directives/date-mask.directive.ts +0 -97
- package/src/lib/directives/input-mask.directive.ts +0 -93
- package/src/lib/interfaces/app-input.interface.ts +0 -32
- package/src/lib/interfaces/autocomplete-configs.interface.ts +0 -37
- package/src/lib/interfaces/button-types.enum.ts +0 -19
- package/src/lib/interfaces/dropdown-selection.constants.ts +0 -11
- package/src/lib/interfaces/label-type.enum.ts +0 -14
- package/src/lib/pipes/array-to-string.pipe.ts +0 -13
- package/src/lib/pipes/generate-error-messages.pipe.ts +0 -31
- package/src/lib/pipes/get-value-by-key-from-object.pipe.ts +0 -46
- package/src/lib/services/input.service.ts +0 -30
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
ViewChild,
|
|
4
|
-
Input,
|
|
5
|
-
Output,
|
|
6
|
-
EventEmitter,
|
|
7
|
-
OnChanges,
|
|
8
|
-
SimpleChanges,
|
|
9
|
-
ElementRef, HostListener, AfterViewInit
|
|
10
|
-
} from '@angular/core';
|
|
11
|
-
import {MatSelect, MatSelectModule} from "@angular/material/select";
|
|
12
|
-
import {AutocompleteConfigsInterface} from "../../interfaces/autocomplete-configs.interface";
|
|
13
|
-
import {FormControlName, ReactiveFormsModule} from "@angular/forms";
|
|
14
|
-
import { InputService } from '../../services/input.service';
|
|
15
|
-
import { ButtonType } from '../../interfaces/button-types.enum';
|
|
16
|
-
import {NgClass, NgFor, NgIf, NgOptimizedImage} from "@angular/common";
|
|
17
|
-
import {MatTooltip} from "@angular/material/tooltip";
|
|
18
|
-
import {TranslateModule} from "@ngx-translate/core";
|
|
19
|
-
import {IconButtonComponent} from "../icon-button/icon-button.component";
|
|
20
|
-
import {ButtonComponent} from "../button/button.component";
|
|
21
|
-
import {GetValueByKeyFromObjectPipe} from "../../pipes/get-value-by-key-from-object.pipe";
|
|
22
|
-
import {ArrayToStringPipe} from "../../pipes/array-to-string.pipe";
|
|
23
|
-
import {MatIcon} from "@angular/material/icon";
|
|
24
|
-
import {GenerateErrorMessagesPipe} from "../../pipes/generate-error-messages.pipe";
|
|
25
|
-
import {ClearValueComponent} from "../clear-value/clear-value.component";
|
|
26
|
-
import {MatFormFieldModule} from "@angular/material/form-field";
|
|
27
|
-
|
|
28
|
-
@Component({
|
|
29
|
-
selector: 'i-tech-autocomplete-select',
|
|
30
|
-
templateUrl: './autocomplete-select.component.html',
|
|
31
|
-
styleUrls: ['./autocomplete-select.component.scss'],
|
|
32
|
-
imports: [
|
|
33
|
-
NgClass,
|
|
34
|
-
MatTooltip,
|
|
35
|
-
NgIf,
|
|
36
|
-
NgFor,
|
|
37
|
-
TranslateModule,
|
|
38
|
-
IconButtonComponent,
|
|
39
|
-
ReactiveFormsModule,
|
|
40
|
-
MatSelectModule,
|
|
41
|
-
ButtonComponent,
|
|
42
|
-
GetValueByKeyFromObjectPipe,
|
|
43
|
-
ArrayToStringPipe,
|
|
44
|
-
NgOptimizedImage,
|
|
45
|
-
MatIcon,
|
|
46
|
-
GenerateErrorMessagesPipe,
|
|
47
|
-
ClearValueComponent,
|
|
48
|
-
MatFormFieldModule
|
|
49
|
-
],
|
|
50
|
-
standalone: true
|
|
51
|
-
})
|
|
52
|
-
export class AutocompleteSelectComponent implements OnChanges, AfterViewInit {
|
|
53
|
-
@ViewChild('matSelect') matSelect!: MatSelect;
|
|
54
|
-
@ViewChild('searchInput') searchInput!: ElementRef;
|
|
55
|
-
@Input() className!: string;
|
|
56
|
-
@Input() submitValue!: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* For working configs.
|
|
59
|
-
*/
|
|
60
|
-
@Input() set configs(data: AutocompleteConfigsInterface) {
|
|
61
|
-
this.selectConfig = data;
|
|
62
|
-
if (!data) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if ((typeof this.selectConfig.paginate) === 'function') {
|
|
67
|
-
if (this.firstRequest) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this.getData();
|
|
71
|
-
this.firstRequest = true
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.data = this.selectConfig.paginate;
|
|
76
|
-
this.findAndSetDefaultValueFromData();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
@Input() detectChanges!: boolean;
|
|
80
|
-
@Output() selectionChange = new EventEmitter<any>();
|
|
81
|
-
@Output() emitAction = new EventEmitter<any>();
|
|
82
|
-
@ViewChild('allSelected') allSelected!: MatSelect;
|
|
83
|
-
pending = false;
|
|
84
|
-
defaultValue!: any;
|
|
85
|
-
data: Array<any> = [];
|
|
86
|
-
paginationData: any = {current: 1, last: 0};
|
|
87
|
-
ngControl: FormControlName;
|
|
88
|
-
selectConfig!: AutocompleteConfigsInterface;
|
|
89
|
-
firstRequest = false;
|
|
90
|
-
showPlaceholder = true;
|
|
91
|
-
isNeededForRecall = false;
|
|
92
|
-
showingValue: any;
|
|
93
|
-
searchTimeoutId: any;
|
|
94
|
-
tabVisibility!: boolean;
|
|
95
|
-
accessToNextRequest = true;
|
|
96
|
-
disabled = false;
|
|
97
|
-
blockRecallDefaultValueSetter = false;
|
|
98
|
-
baseData: any;
|
|
99
|
-
requestLoading = false;
|
|
100
|
-
protected readonly ButtonType = ButtonType;
|
|
101
|
-
|
|
102
|
-
@HostListener('document:visibilitychange')
|
|
103
|
-
handleVisibilityChange(): void {
|
|
104
|
-
this.tabVisibility = !document.hidden;
|
|
105
|
-
if (this.ngControl.control.value) { return;}
|
|
106
|
-
this.closePanelAndUnsetFocus();
|
|
107
|
-
if (!document.hidden) {
|
|
108
|
-
this.isNeededForRecall = true;
|
|
109
|
-
this.pending = true;
|
|
110
|
-
setTimeout(() => {
|
|
111
|
-
this.pending = false
|
|
112
|
-
}, 4000)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
constructor(private inputService: InputService) {
|
|
117
|
-
this.ngControl = this.inputService.injectNgControl();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
ngOnChanges(changes: SimpleChanges) {
|
|
121
|
-
if (changes['selectConfig'] && this.selectConfig) {
|
|
122
|
-
if ((typeof this.selectConfig.paginate) === 'function') {
|
|
123
|
-
this.getData();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
ngAfterViewInit() {
|
|
129
|
-
this.ngControl.control.valueChanges.subscribe((res: any) => {
|
|
130
|
-
if (this.data.length && res && !this.blockRecallDefaultValueSetter) {
|
|
131
|
-
this.findAndSetDefaultValueFromData();
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
hardReload(): void {
|
|
137
|
-
this.getData('', true);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Dynamic request for select data.
|
|
142
|
-
* @param searchText - The input value to search options by.
|
|
143
|
-
* @param fromSearch - Access for search .
|
|
144
|
-
* @returns Select data.
|
|
145
|
-
*/
|
|
146
|
-
getData(searchText?: string, fromSearch?: boolean): void {
|
|
147
|
-
if (!fromSearch && !this.accessToNextRequest) { return; }
|
|
148
|
-
|
|
149
|
-
if (this.requestLoading) { return; }
|
|
150
|
-
|
|
151
|
-
if (fromSearch) {
|
|
152
|
-
this.paginationData.current = 1;
|
|
153
|
-
this.accessToNextRequest = true;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const functionToDo = this.selectConfig.paginate(this.paginationData.current, searchText);
|
|
157
|
-
|
|
158
|
-
this.requestLoading = true;
|
|
159
|
-
functionToDo?.subscribe((data: Array<any> | any) => {
|
|
160
|
-
const dataToAdd = ('content' in data) ? data.content : data;
|
|
161
|
-
|
|
162
|
-
if ('content' in data) {
|
|
163
|
-
this.accessToNextRequest = !data.last || (data.totalPages > this.paginationData.current);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
this.data = (fromSearch || this.selectConfig?.blockPagination) ? dataToAdd : [...this.data, ...dataToAdd];
|
|
167
|
-
this.pending = false;
|
|
168
|
-
this.requestLoading = false;
|
|
169
|
-
|
|
170
|
-
if (!dataToAdd.length) {
|
|
171
|
-
this.paginationData.last = this.paginationData.current;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
this.paginationData.current += 1;
|
|
176
|
-
this.paginationData.last += 1;
|
|
177
|
-
setTimeout(() => {
|
|
178
|
-
this.findAndSetDefaultValueFromData();
|
|
179
|
-
},10)
|
|
180
|
-
}, () => {
|
|
181
|
-
this.pending = false;
|
|
182
|
-
this.requestLoading = false;
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
findAndSetDefaultValueFromData(): void {
|
|
187
|
-
if (this.selectConfig.multiple) {
|
|
188
|
-
if (this.ngControl.value && this.ngControl.value.length == 1) {
|
|
189
|
-
this.setShowingValue(this.data.find((item) => item.id === this.ngControl.value[0]))
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
const isDisabled = this.ngControl.disabled;
|
|
193
|
-
if (isDisabled) {
|
|
194
|
-
// TODO Remove after migrating all selects
|
|
195
|
-
this.ngControl.control.enable();
|
|
196
|
-
if (!this.ngControl.value && !this.data.length) {
|
|
197
|
-
this.ngControl.control.disable();
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
this.setDefaultValue();
|
|
201
|
-
this.ngControl.control.disable();
|
|
202
|
-
} else {
|
|
203
|
-
if (!this.ngControl.value && !this.data) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
this.setDefaultValue();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
setDefaultValue(): void {
|
|
213
|
-
this.defaultValue = this.data.find((item) => item.id === this.ngControl.value);
|
|
214
|
-
this.baseData = this.defaultValue
|
|
215
|
-
if (!this.defaultValue) { return;}
|
|
216
|
-
this.selectionChange.emit()
|
|
217
|
-
this.setShowingValue(this.defaultValue);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
optionClick(showingData: any): void {
|
|
221
|
-
this.baseData = showingData
|
|
222
|
-
if (!this.selectConfig.multiple) {
|
|
223
|
-
this.setShowingValue(showingData);
|
|
224
|
-
this.matSelect.close();
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
if (this.searchInput) {
|
|
228
|
-
if (this.selectConfig.multiple) {
|
|
229
|
-
this.searchInput?.nativeElement?.focus()
|
|
230
|
-
} else {
|
|
231
|
-
this.inputFocusOut();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
this.setShowingValue(showingData);
|
|
236
|
-
this.showPlaceholder = false;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
addNewItemEvent(): void {
|
|
240
|
-
this.isNeededForRecall = true;
|
|
241
|
-
this.emitAction.emit();
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Filter and show.
|
|
245
|
-
* @param data - Existing chosen data.
|
|
246
|
-
*/
|
|
247
|
-
setShowingValue(data: any): void {
|
|
248
|
-
if (!data) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
// TODO refactor this part fully
|
|
252
|
-
let include = data;
|
|
253
|
-
let includeOptional = data;
|
|
254
|
-
|
|
255
|
-
if (this.selectConfig.valueToShowByKey) {
|
|
256
|
-
this.selectConfig.valueToShowByKey.forEach((param: Array<string | number> | string) => {
|
|
257
|
-
|
|
258
|
-
if (typeof param === 'object') {
|
|
259
|
-
param.forEach((key: string | number) => {
|
|
260
|
-
include = (include) ? include[key] : null;
|
|
261
|
-
})
|
|
262
|
-
} else {
|
|
263
|
-
include = include[param];
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
if (this.selectConfig.showFullTextWithOptionalOnSelectedValue) {
|
|
267
|
-
this.selectConfig.valueToShowByParam?.forEach((param: Array<string | number> | string) => {
|
|
268
|
-
|
|
269
|
-
if (typeof param === 'object') {
|
|
270
|
-
param.forEach((key: string | number) => {
|
|
271
|
-
includeOptional = (includeOptional) ? includeOptional[key] : null;
|
|
272
|
-
})
|
|
273
|
-
} else {
|
|
274
|
-
includeOptional = includeOptional[param];
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
if (this.selectConfig.valueToShowByParam && typeof includeOptional === 'string') {
|
|
278
|
-
include += (this.selectConfig.withParamSymbol || '') + includeOptional
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
this.showingValue = include;
|
|
284
|
-
this.blockRecallDefaultValueSetter = true;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Block another events.
|
|
289
|
-
* @param event - Element click event.
|
|
290
|
-
*/
|
|
291
|
-
preventDefault(event: any) {
|
|
292
|
-
if (!this.selectConfig.multiple) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
event.preventDefault()
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
registerPanelScrollEvent(element: MatSelect) {
|
|
299
|
-
if (this.selectConfig.paginateOnScroll === false) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const panel = element.panel.nativeElement;
|
|
304
|
-
panel.addEventListener('scroll', (event: any) => this.loadDataOnScroll(event));
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
loadDataOnScroll(event: any) {
|
|
308
|
-
const pos = (event.target.scrollTop || event.target.scrollTop) + event.target.offsetHeight;
|
|
309
|
-
const max = event.target.scrollHeight;
|
|
310
|
-
if ((pos + 1) >= max) {
|
|
311
|
-
if (this.paginationData.current === this.paginationData.last || this.selectConfig.blockPagination) {
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
this.getData();
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
focusSearchInput() {
|
|
319
|
-
if (this.selectConfig.search && this.searchInput) {
|
|
320
|
-
this.searchInput.nativeElement.focus();
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
inputFocusOut(): void {
|
|
325
|
-
this.isNeededForRecall = !!this.searchInput.nativeElement.value;
|
|
326
|
-
this.searchInput.nativeElement.value = '';
|
|
327
|
-
this.showPlaceholder = true;
|
|
328
|
-
this.clearTimeoutForSearch();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
resetValue(): void {
|
|
332
|
-
this.selectionChange.emit(null);
|
|
333
|
-
this.ngControl.reset(null);
|
|
334
|
-
this.inputFocusOut();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
getDataWithSearch(value: any, event: any): void {
|
|
338
|
-
this.clearTimeoutForSearch();
|
|
339
|
-
if (value.length >= 1) {
|
|
340
|
-
this.searchTimeoutId = setTimeout(() => {
|
|
341
|
-
this.getData(value, true)
|
|
342
|
-
}, 800);
|
|
343
|
-
} else if (value.length <= 1 && event.keyCode === 8) {
|
|
344
|
-
this.getData(value, true)
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
clearTimeoutForSearch(): void {
|
|
349
|
-
if (this.searchTimeoutId) {
|
|
350
|
-
clearTimeout(this.searchTimeoutId);
|
|
351
|
-
this.searchTimeoutId = 0;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
openSelection(): void {
|
|
356
|
-
if (this.selectConfig.disabled || this.ngControl.control.disabled) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
this.showPlaceholder ? this.matSelect.open() : this.closePanelAndUnsetFocus();
|
|
360
|
-
this.showPlaceholder = !this.showPlaceholder;
|
|
361
|
-
if (!this.showPlaceholder) {
|
|
362
|
-
this.reCallData()
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
closePanelAndUnsetFocus(): void {
|
|
367
|
-
this.matSelect.close();
|
|
368
|
-
if (this.searchInput) {
|
|
369
|
-
this.searchInput.nativeElement.blur()
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
openedChange(event: any) {
|
|
374
|
-
if (event) {
|
|
375
|
-
if (this.isNeededForRecall) {
|
|
376
|
-
this.reCallData();
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
if (!this.selectConfig.search) {
|
|
380
|
-
this.pending = false
|
|
381
|
-
this.reCallData();
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
this.showPlaceholder = true;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
reCallData(): void {
|
|
391
|
-
// TODO refactor this part
|
|
392
|
-
if (!this.isNeededForRecall) { return; }
|
|
393
|
-
this.data = [];
|
|
394
|
-
this.pending = true;
|
|
395
|
-
this.paginationData = {
|
|
396
|
-
current: 1,
|
|
397
|
-
last: 0
|
|
398
|
-
};
|
|
399
|
-
this.accessToNextRequest = true;
|
|
400
|
-
if ((typeof this.selectConfig.paginate) === 'function') {
|
|
401
|
-
this.getData();
|
|
402
|
-
} else {
|
|
403
|
-
this.pending = false;
|
|
404
|
-
this.data = this.selectConfig.paginate;
|
|
405
|
-
}
|
|
406
|
-
this.isNeededForRecall = false;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
emitSelectionChangeAndClose(event: any) {
|
|
410
|
-
this.selectionChange.emit(event.value);
|
|
411
|
-
if (this.selectConfig.multiple) {
|
|
412
|
-
if (!event.value?.length) {
|
|
413
|
-
this.ngControl.control.reset();
|
|
414
|
-
}
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
this.matSelect.close();
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
iconClick(matSelect: MatSelect, searchInput?: ElementRef): void {
|
|
421
|
-
matSelect.open();
|
|
422
|
-
searchInput?.nativeElement?.focus();
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
customErrorStateMatcher = {
|
|
426
|
-
isErrorState: (control: any, form: any): boolean => {
|
|
427
|
-
return !!(control && control.invalid && this.submitValue);
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background: none; display: block; shape-rendering: auto;" width="200px" height="200px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
|
|
3
|
-
<circle cx="50" cy="50" fill="none" stroke="#00AC47" stroke-width="10" r="35" stroke-dasharray="164.93361431346415 56.97787143782138">
|
|
4
|
-
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" values="0 50 50;360 50 50" keyTimes="0;1"></animateTransform>
|
|
5
|
-
</circle>
|
|
6
|
-
<!-- [ldio] generated by https://loading.io/ --></svg>
|
|
File without changes
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<button *ngIf="[ButtonType.FILLED,ButtonType.WARNING].includes(type)"
|
|
2
|
-
mat-flat-button
|
|
3
|
-
[attr.data-cy]="data_cy"
|
|
4
|
-
[color]="type === ButtonType.WARNING ? 'warn' : color"
|
|
5
|
-
[class.activated]="activated"
|
|
6
|
-
[ngClass]="(customClass || '')"
|
|
7
|
-
[disabled]="disabled || submit"
|
|
8
|
-
(click)="onClick($event)"
|
|
9
|
-
>
|
|
10
|
-
<span *ngIf="submit" class="spinner-overlay">
|
|
11
|
-
<mat-spinner diameter="16"></mat-spinner>
|
|
12
|
-
</span>
|
|
13
|
-
<mat-icon *ngIf="fontIcon && !submit">{{fontIcon}}</mat-icon>
|
|
14
|
-
<mat-icon *ngIf="svgIcon && !submit" [svgIcon]="svgIcon"></mat-icon>
|
|
15
|
-
<span>{{text | translate}}</span>
|
|
16
|
-
</button>
|
|
17
|
-
<button *ngIf="[ButtonType.TONAL,ButtonType.TEXT].includes(type)"
|
|
18
|
-
mat-button
|
|
19
|
-
[attr.data-cy]="data_cy"
|
|
20
|
-
[ngClass]="(type === ButtonType.TONAL ? 'tertiary ' : '') + (customClass || '')"
|
|
21
|
-
[class.activated]="activated"
|
|
22
|
-
[disabled]="disabled || submit"
|
|
23
|
-
(click)="onClick($event)"
|
|
24
|
-
>
|
|
25
|
-
<span *ngIf="submit" class="spinner-overlay">
|
|
26
|
-
<mat-spinner diameter="16"></mat-spinner>
|
|
27
|
-
</span>
|
|
28
|
-
<mat-icon *ngIf="fontIcon && !submit">{{fontIcon}}</mat-icon>
|
|
29
|
-
<mat-icon *ngIf="svgIcon && !submit" [svgIcon]="svgIcon"></mat-icon>
|
|
30
|
-
|
|
31
|
-
<span>{{text | translate}}</span>
|
|
32
|
-
</button>
|
|
33
|
-
<button *ngIf="type === ButtonType.OUTLINE"
|
|
34
|
-
[color]="color"
|
|
35
|
-
mat-stroked-button
|
|
36
|
-
[attr.data-cy]="data_cy"
|
|
37
|
-
[ngClass]="(customClass || '') "
|
|
38
|
-
[disabled]="disabled || submit"
|
|
39
|
-
(click)="onClick($event)"
|
|
40
|
-
[class.activated]="activated"
|
|
41
|
-
>
|
|
42
|
-
<span *ngIf="submit" class="spinner-overlay">
|
|
43
|
-
<mat-spinner diameter="16"></mat-spinner>
|
|
44
|
-
</span>
|
|
45
|
-
<mat-icon *ngIf="fontIcon && !submit" >{{fontIcon}}</mat-icon>
|
|
46
|
-
<mat-icon *ngIf="svgIcon && !submit" [svgIcon]="svgIcon"></mat-icon>
|
|
47
|
-
<span>{{text | translate}}</span>
|
|
48
|
-
</button>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { ButtonComponent } from './button.component';
|
|
4
|
-
|
|
5
|
-
describe('ButtonComponent', () => {
|
|
6
|
-
let component: ButtonComponent;
|
|
7
|
-
let fixture: ComponentFixture<ButtonComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
imports: [ButtonComponent]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
|
|
15
|
-
fixture = TestBed.createComponent(ButtonComponent);
|
|
16
|
-
component = fixture.componentInstance;
|
|
17
|
-
fixture.detectChanges();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should create', () => {
|
|
21
|
-
expect(component).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
|
2
|
-
import {MatButton} from "@angular/material/button";
|
|
3
|
-
import {NgClass, NgIf} from "@angular/common";
|
|
4
|
-
import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
|
5
|
-
import {MatIconModule} from "@angular/material/icon";
|
|
6
|
-
import {TranslateModule, TranslatePipe, TranslateService} from "@ngx-translate/core";
|
|
7
|
-
import { ButtonType } from '../../interfaces/button-types.enum';
|
|
8
|
-
import {NgxMaskDirective, NgxMaskPipe } from 'ngx-mask';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A reusable button component with Material Design styling and custom functionality.
|
|
12
|
-
*/
|
|
13
|
-
@Component({
|
|
14
|
-
selector: 'i-tech-button',
|
|
15
|
-
standalone: true,
|
|
16
|
-
imports: [
|
|
17
|
-
MatButton,
|
|
18
|
-
NgClass,
|
|
19
|
-
MatProgressSpinner,
|
|
20
|
-
NgIf,
|
|
21
|
-
MatIconModule,
|
|
22
|
-
TranslateModule
|
|
23
|
-
],
|
|
24
|
-
templateUrl: './button.component.html',
|
|
25
|
-
styleUrl: './button.component.css',
|
|
26
|
-
providers: [
|
|
27
|
-
NgxMaskDirective,
|
|
28
|
-
NgxMaskPipe,
|
|
29
|
-
TranslatePipe,
|
|
30
|
-
TranslateService
|
|
31
|
-
]
|
|
32
|
-
})
|
|
33
|
-
export class ButtonComponent {
|
|
34
|
-
/**
|
|
35
|
-
* The text displayed inside the button.
|
|
36
|
-
*/
|
|
37
|
-
@Input() text: string = '';
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Data attribute used for Cypress or other testing frameworks.
|
|
41
|
-
*/
|
|
42
|
-
@Input() data_cy: string = '';
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Font icon class for displaying an icon (e.g., Material Icons).
|
|
46
|
-
*/
|
|
47
|
-
@Input() fontIcon: string = '';
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* SVG icon name for displaying an SVG icon.
|
|
51
|
-
*/
|
|
52
|
-
@Input() svgIcon: string = '';
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Defines the type of button (e.g., `FILLED`, `OUTLINED`).
|
|
56
|
-
*/
|
|
57
|
-
@Input() type: ButtonType = ButtonType.FILLED;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Additional custom classes to style the button.
|
|
61
|
-
*/
|
|
62
|
-
@Input() customClass: string = '';
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* If true, the button acts as a submit button.
|
|
66
|
-
*/
|
|
67
|
-
@Input() submit: boolean = false;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* If true, the button is disabled and cannot be clicked.
|
|
71
|
-
*/
|
|
72
|
-
@Input() disabled: boolean = false;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Indicates whether the button is currently activated.
|
|
76
|
-
*/
|
|
77
|
-
@Input() activated: boolean = false;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* The color of the button (e.g., `primary`, `warn`).
|
|
81
|
-
*/
|
|
82
|
-
@Input() color: 'primary' | 'warn' = 'primary';
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Emits an event when the button is clicked.
|
|
86
|
-
*/
|
|
87
|
-
@Output() buttonClick = new EventEmitter<void>();
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Enum reference for `ButtonType` to use in templates.
|
|
91
|
-
*/
|
|
92
|
-
protected readonly ButtonType = ButtonType;
|
|
93
|
-
|
|
94
|
-
constructor() {}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Handles the button click event.
|
|
98
|
-
*
|
|
99
|
-
* @param event - The mouse event triggered by clicking the button.
|
|
100
|
-
*/
|
|
101
|
-
onClick(event: MouseEvent): void {
|
|
102
|
-
if (!this.disabled && !this.submit) {
|
|
103
|
-
this.buttonClick.emit();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
|
2
|
-
import {NgClass, NgOptimizedImage} from "@angular/common";
|
|
3
|
-
|
|
4
|
-
@Component({
|
|
5
|
-
selector: 'i-tech-clear-value',
|
|
6
|
-
template: `<img
|
|
7
|
-
class="pointer"
|
|
8
|
-
[ngClass]="className || 'standard'"
|
|
9
|
-
(click)="reset.emit()"
|
|
10
|
-
ngSrc="./ic_close.svg"
|
|
11
|
-
height="24" width="24" alt=""/>`,
|
|
12
|
-
styles: [`
|
|
13
|
-
img {
|
|
14
|
-
position: absolute;
|
|
15
|
-
width: 15px;
|
|
16
|
-
height: 15px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.big {
|
|
20
|
-
width: 25px;
|
|
21
|
-
height: 25px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.range_date {
|
|
25
|
-
right: -65px;
|
|
26
|
-
top: 15px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.standard {
|
|
30
|
-
right: -20px;
|
|
31
|
-
top: 40px;
|
|
32
|
-
}
|
|
33
|
-
`],
|
|
34
|
-
imports: [
|
|
35
|
-
NgClass,
|
|
36
|
-
NgOptimizedImage
|
|
37
|
-
],
|
|
38
|
-
standalone: true
|
|
39
|
-
})
|
|
40
|
-
export class ClearValueComponent {
|
|
41
|
-
@Input() className!: string;
|
|
42
|
-
@Input() additionalClass!: string;
|
|
43
|
-
@Output() reset = new EventEmitter<any>();
|
|
44
|
-
}
|