@tacdaed/fragments 1.0.0-beta.2 → 1.0.0-beta.3
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/README.md +3 -3
- package/fesm2022/tacdaed-fragments.mjs +8928 -0
- package/fesm2022/tacdaed-fragments.mjs.map +1 -0
- package/index.d.ts +3929 -0
- package/package.json +29 -22
- package/ng-package.json +0 -25
- package/src/lib/components/accordion/accordion.component.html +0 -103
- package/src/lib/components/accordion/accordion.component.scss +0 -382
- package/src/lib/components/accordion/accordion.component.spec.ts +0 -147
- package/src/lib/components/accordion/accordion.component.ts +0 -211
- package/src/lib/components/accordion/accordion.type.ts +0 -82
- package/src/lib/components/breadcrumb/breadcrumb.component.html +0 -43
- package/src/lib/components/breadcrumb/breadcrumb.component.scss +0 -112
- package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +0 -33
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +0 -103
- package/src/lib/components/breadcrumb/breadcrumb.interface.ts +0 -7
- package/src/lib/components/button/button.component.html +0 -57
- package/src/lib/components/button/button.component.scss +0 -445
- package/src/lib/components/button/button.component.spec.ts +0 -99
- package/src/lib/components/button/button.component.ts +0 -143
- package/src/lib/components/button/button.type.ts +0 -7
- package/src/lib/components/card/card.component.html +0 -44
- package/src/lib/components/card/card.component.scss +0 -114
- package/src/lib/components/card/card.component.spec.ts +0 -65
- package/src/lib/components/card/card.component.ts +0 -21
- package/src/lib/components/card/card.type.ts +0 -3
- package/src/lib/components/code-block/code-block.component.html +0 -55
- package/src/lib/components/code-block/code-block.component.scss +0 -122
- package/src/lib/components/code-block/code-block.component.spec.ts +0 -81
- package/src/lib/components/code-block/code-block.component.ts +0 -302
- package/src/lib/components/code-block/code-block.interface.ts +0 -28
- package/src/lib/components/code-block/code-block.type.ts +0 -73
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.html +0 -14
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.scss +0 -20
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.spec.ts +0 -38
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.ts +0 -181
- package/src/lib/components/input/input-base.ts +0 -187
- package/src/lib/components/input/input-calendar/input-calendar.component.html +0 -76
- package/src/lib/components/input/input-calendar/input-calendar.component.scss +0 -179
- package/src/lib/components/input/input-calendar/input-calendar.component.spec.ts +0 -44
- package/src/lib/components/input/input-calendar/input-calendar.component.ts +0 -299
- package/src/lib/components/input/input-checkbox/input-checkbox.component.html +0 -37
- package/src/lib/components/input/input-checkbox/input-checkbox.component.scss +0 -128
- package/src/lib/components/input/input-checkbox/input-checkbox.component.spec.ts +0 -43
- package/src/lib/components/input/input-checkbox/input-checkbox.component.ts +0 -112
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.html +0 -43
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.scss +0 -140
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.spec.ts +0 -62
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.ts +0 -136
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.html +0 -81
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.scss +0 -228
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.spec.ts +0 -62
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.ts +0 -178
- package/src/lib/components/input/input-consts.ts +0 -132
- package/src/lib/components/input/input-date/input-date-validators.ts +0 -41
- package/src/lib/components/input/input-date/input-date.component.html +0 -41
- package/src/lib/components/input/input-date/input-date.component.scss +0 -95
- package/src/lib/components/input/input-date/input-date.component.spec.ts +0 -43
- package/src/lib/components/input/input-date/input-date.component.ts +0 -359
- package/src/lib/components/input/input-date-time/input-date-time.component.html +0 -70
- package/src/lib/components/input/input-date-time/input-date-time.component.scss +0 -133
- package/src/lib/components/input/input-date-time/input-date-time.component.spec.ts +0 -36
- package/src/lib/components/input/input-date-time/input-date-time.component.ts +0 -387
- package/src/lib/components/input/input-file-upload/input-file-upload.component.html +0 -89
- package/src/lib/components/input/input-file-upload/input-file-upload.component.scss +0 -171
- package/src/lib/components/input/input-file-upload/input-file-upload.component.spec.ts +0 -43
- package/src/lib/components/input/input-file-upload/input-file-upload.component.ts +0 -351
- package/src/lib/components/input/input-interface.ts +0 -8
- package/src/lib/components/input/input-number/input-number-validators.ts +0 -0
- package/src/lib/components/input/input-number/input-number.component.html +0 -51
- package/src/lib/components/input/input-number/input-number.component.scss +0 -140
- package/src/lib/components/input/input-number/input-number.component.spec.ts +0 -44
- package/src/lib/components/input/input-number/input-number.component.ts +0 -343
- package/src/lib/components/input/input-radio-group/input-radio-group.component.html +0 -44
- package/src/lib/components/input/input-radio-group/input-radio-group.component.scss +0 -139
- package/src/lib/components/input/input-radio-group/input-radio-group.component.spec.ts +0 -58
- package/src/lib/components/input/input-radio-group/input-radio-group.component.ts +0 -132
- package/src/lib/components/input/input-slider/input-slider.component.html +0 -111
- package/src/lib/components/input/input-slider/input-slider.component.scss +0 -203
- package/src/lib/components/input/input-slider/input-slider.component.spec.ts +0 -46
- package/src/lib/components/input/input-slider/input-slider.component.ts +0 -410
- package/src/lib/components/input/input-text/input-text-validators.ts +0 -67
- package/src/lib/components/input/input-text/input-text.component.html +0 -71
- package/src/lib/components/input/input-text/input-text.component.scss +0 -118
- package/src/lib/components/input/input-text/input-text.component.spec.ts +0 -55
- package/src/lib/components/input/input-text/input-text.component.ts +0 -215
- package/src/lib/components/input/input-time/input-time-validators.ts +0 -42
- package/src/lib/components/input/input-time/input-time.component.html +0 -92
- package/src/lib/components/input/input-time/input-time.component.scss +0 -191
- package/src/lib/components/input/input-time/input-time.component.spec.ts +0 -39
- package/src/lib/components/input/input-time/input-time.component.ts +0 -691
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.html +0 -36
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.scss +0 -121
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.spec.ts +0 -54
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.ts +0 -117
- package/src/lib/components/input/input-type.ts +0 -18
- package/src/lib/components/input/input-validation/input-validation.component.html +0 -19
- package/src/lib/components/input/input-validation/input-validation.component.scss +0 -39
- package/src/lib/components/input/input-validation/input-validation.component.spec.ts +0 -45
- package/src/lib/components/input/input-validation/input-validation.component.ts +0 -13
- package/src/lib/components/input/input.pipe.ts +0 -14
- package/src/lib/components/layout/container/container.component.html +0 -1
- package/src/lib/components/layout/container/container.component.scss +0 -33
- package/src/lib/components/layout/container/container.component.ts +0 -32
- package/src/lib/components/layout/container/container.type.ts +0 -1
- package/src/lib/components/layout/divider/divider.component.html +0 -1
- package/src/lib/components/layout/divider/divider.component.scss +0 -60
- package/src/lib/components/layout/divider/divider.component.ts +0 -38
- package/src/lib/components/layout/divider/divider.type.ts +0 -2
- package/src/lib/components/layout/section/section.component.html +0 -21
- package/src/lib/components/layout/section/section.component.scss +0 -43
- package/src/lib/components/layout/section/section.component.ts +0 -33
- package/src/lib/components/layout/section/section.type.ts +0 -2
- package/src/lib/components/layout/separator/separator.component.html +0 -9
- package/src/lib/components/layout/separator/separator.component.scss +0 -52
- package/src/lib/components/layout/separator/separator.component.ts +0 -25
- package/src/lib/components/layout/separator/separator.type.ts +0 -1
- package/src/lib/components/loader/content-blur/content-blur.component.html +0 -13
- package/src/lib/components/loader/content-blur/content-blur.component.scss +0 -43
- package/src/lib/components/loader/content-blur/content-blur.component.spec.ts +0 -42
- package/src/lib/components/loader/content-blur/content-blur.component.ts +0 -34
- package/src/lib/components/loader/loader.type.ts +0 -2
- package/src/lib/components/loader/progress-bar/progress-bar.component.html +0 -26
- package/src/lib/components/loader/progress-bar/progress-bar.component.scss +0 -151
- package/src/lib/components/loader/progress-bar/progress-bar.component.spec.ts +0 -47
- package/src/lib/components/loader/progress-bar/progress-bar.component.ts +0 -28
- package/src/lib/components/loader/progress-bar/progress-bar.type.ts +0 -8
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.html +0 -12
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.scss +0 -202
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.spec.ts +0 -55
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.ts +0 -73
- package/src/lib/components/loader/pulse-loader/pulse-loader.type.ts +0 -6
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.html +0 -13
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.scss +0 -113
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.spec.ts +0 -37
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.ts +0 -51
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.type.ts +0 -6
- package/src/lib/components/loader/spinner/spinner.component.html +0 -20
- package/src/lib/components/loader/spinner/spinner.component.scss +0 -137
- package/src/lib/components/loader/spinner/spinner.component.spec.ts +0 -43
- package/src/lib/components/loader/spinner/spinner.component.ts +0 -32
- package/src/lib/components/loader/spinner/spinner.type.ts +0 -6
- package/src/lib/components/modal/modal.component.html +0 -47
- package/src/lib/components/modal/modal.component.scss +0 -139
- package/src/lib/components/modal/modal.component.spec.ts +0 -60
- package/src/lib/components/modal/modal.component.ts +0 -83
- package/src/lib/components/modal/modal.type.ts +0 -9
- package/src/lib/components/morph/blob-moph/blob-moprh.component.spec.ts +0 -79
- package/src/lib/components/morph/blob-moph/blob-moprh.component.ts +0 -96
- package/src/lib/components/morph/blob-moph/blob-morph.component.html +0 -34
- package/src/lib/components/morph/blob-moph/blob-morph.component.scss +0 -7
- package/src/lib/components/morph/morph.abstract.ts +0 -13
- package/src/lib/components/pagination/pagination.interface.ts +0 -4
- package/src/lib/components/pagination/small-pagination/small-pagination.component.html +0 -61
- package/src/lib/components/pagination/small-pagination/small-pagination.component.scss +0 -187
- package/src/lib/components/pagination/small-pagination/small-pagination.component.spec.ts +0 -88
- package/src/lib/components/pagination/small-pagination/small-pagination.component.ts +0 -177
- package/src/lib/components/selection-lists/multi-select/multi-select.component.html +0 -170
- package/src/lib/components/selection-lists/multi-select/multi-select.component.scss +0 -312
- package/src/lib/components/selection-lists/multi-select/multi-select.component.spec.ts +0 -61
- package/src/lib/components/selection-lists/multi-select/multi-select.component.ts +0 -372
- package/src/lib/components/selection-lists/selection-list/selection-list.component.html +0 -125
- package/src/lib/components/selection-lists/selection-list/selection-list.component.scss +0 -267
- package/src/lib/components/selection-lists/selection-list/selection-list.component.spec.ts +0 -66
- package/src/lib/components/selection-lists/selection-list/selection-list.component.ts +0 -315
- package/src/lib/components/selection-lists/selection-lists-base.ts +0 -35
- package/src/lib/components/selection-lists/selection-lists-const.ts +0 -17
- package/src/lib/components/selection-lists/selection-lists-interface.ts +0 -7
- package/src/lib/components/selection-lists/selection-lists.type.ts +0 -1
- package/src/lib/components/side-nav/side-nav.component.html +0 -101
- package/src/lib/components/side-nav/side-nav.component.scss +0 -295
- package/src/lib/components/side-nav/side-nav.component.spec.ts +0 -0
- package/src/lib/components/side-nav/side-nav.component.ts +0 -18
- package/src/lib/components/side-nav/side-nav.type.ts +0 -28
- package/src/lib/components/snackbar/snackbar.component.html +0 -33
- package/src/lib/components/snackbar/snackbar.component.scss +0 -195
- package/src/lib/components/snackbar/snackbar.component.ts +0 -112
- package/src/lib/components/snackbar/snackbar.type.ts +0 -27
- package/src/lib/components/status/chip/chip.component.html +0 -51
- package/src/lib/components/status/chip/chip.component.scss +0 -149
- package/src/lib/components/status/chip/chip.component.spec.ts +0 -62
- package/src/lib/components/status/chip/chip.component.ts +0 -83
- package/src/lib/components/status/chip/chip.type.ts +0 -42
- package/src/lib/components/status/directives/badge/badge.directive.spec.ts +0 -60
- package/src/lib/components/status/directives/badge/badge.directive.ts +0 -190
- package/src/lib/components/status/directives/badge/badge.interface.ts +0 -19
- package/src/lib/components/status/pill/pill.component.html +0 -40
- package/src/lib/components/status/pill/pill.component.scss +0 -113
- package/src/lib/components/status/pill/pill.component.spec.ts +0 -47
- package/src/lib/components/status/pill/pill.component.ts +0 -83
- package/src/lib/components/status/pill/pill.type.ts +0 -42
- package/src/lib/components/status/status.interface.ts +0 -57
- package/src/lib/components/status/status.type.ts +0 -62
- package/src/lib/components/status/tag/tag.component.html +0 -39
- package/src/lib/components/status/tag/tag.component.scss +0 -140
- package/src/lib/components/status/tag/tag.component.spec.ts +0 -47
- package/src/lib/components/status/tag/tag.component.ts +0 -83
- package/src/lib/components/status/tag/tag.type.ts +0 -42
- package/src/lib/components/stepper/stepper.component.html +0 -83
- package/src/lib/components/stepper/stepper.component.scss +0 -196
- package/src/lib/components/stepper/stepper.component.ts +0 -482
- package/src/lib/components/stepper/stepper.type.ts +0 -60
- package/src/lib/components/table/table.component.html +0 -438
- package/src/lib/components/table/table.component.scss +0 -259
- package/src/lib/components/table/table.component.spec.ts +0 -117
- package/src/lib/components/table/table.component.ts +0 -215
- package/src/lib/components/table/table.enum.ts +0 -4
- package/src/lib/components/table/table.function.ts +0 -47
- package/src/lib/components/table/table.interface.ts +0 -143
- package/src/lib/components/table/table.pipe.ts +0 -62
- package/src/lib/components/table/table.type.ts +0 -15
- package/src/lib/components/tabs/tabs.component.html +0 -88
- package/src/lib/components/tabs/tabs.component.scss +0 -305
- package/src/lib/components/tabs/tabs.component.spec.ts +0 -94
- package/src/lib/components/tabs/tabs.component.ts +0 -282
- package/src/lib/components/tabs/tabs.type.ts +0 -81
- package/src/lib/components/title-bar/title-bar.component.html +0 -21
- package/src/lib/components/title-bar/title-bar.component.scss +0 -139
- package/src/lib/components/title-bar/title-bar.component.spec.ts +0 -44
- package/src/lib/components/title-bar/title-bar.component.ts +0 -13
- package/src/lib/components/toast/toast.component.html +0 -36
- package/src/lib/components/toast/toast.component.scss +0 -241
- package/src/lib/components/toast/toast.component.ts +0 -165
- package/src/lib/components/toast/toast.type.ts +0 -37
- package/src/lib/components/toast-stack/toast-stack.component.html +0 -30
- package/src/lib/components/toast-stack/toast-stack.component.scss +0 -35
- package/src/lib/components/toast-stack/toast-stack.component.ts +0 -51
- package/src/lib/consts/country-prefix.ts +0 -244
- package/src/lib/directives/tooltip/popover.directive.ts +0 -274
- package/src/lib/directives/tooltip/tooltip.directive.spec.ts +0 -86
- package/src/lib/directives/tooltip/tooltip.directive.ts +0 -234
- package/src/lib/directives/tooltip/tooltip.interface.ts +0 -29
- package/src/lib/directives/tooltip/tooltip.type.ts +0 -9
- package/src/lib/interfaces/common.interfaces.ts +0 -4
- package/src/lib/pipes/chunk.pipe.ts +0 -16
- package/src/lib/pipes/safe-html.pipe.ts +0 -14
- package/src/lib/pipes/sanitize-html.pipe.ts +0 -23
- package/src/lib/types/base.types.ts +0 -23
- package/src/lib/types/common.types.ts +0 -98
- package/src/lib/types/form.types.ts +0 -5
- package/src/lib/utils/common.utils.ts +0 -53
- package/src/lib/utils/date.utils.ts +0 -474
- package/src/lib/utils/number.utils.ts +0 -16
- package/src/lib/utils/uuid.utils.ts +0 -39
- package/src/public-api.ts +0 -114
- package/tsconfig.lib.json +0 -17
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -9
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import { AsyncPipe } from '@angular/common';
|
|
2
|
-
import { Component, HostListener, Input } from '@angular/core';
|
|
3
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import { BehaviorSubject } from 'rxjs';
|
|
5
|
-
import { DateTimeFormat, TimeFormat } from '../../../types/common.types';
|
|
6
|
-
import { buildDateTimeFormatRegex, convertStringToDateTime, extractTimeFormat, formatDateTimeToString, isMeridiemFormat, isValidDateTime } from '../../../utils/date.utils';
|
|
7
|
-
import { InputBase } from '../input-base';
|
|
8
|
-
import { InputCalendarComponent } from '../input-calendar/input-calendar.component';
|
|
9
|
-
import { InputClockPickerComponent } from '../input-clock-picker/input-clock-picker.component';
|
|
10
|
-
import { DEFAULT_INPUT_DATE_TIME_ERROR_MESSAGES, DEFAULT_INPUT_DATE_TIME_WARNINGS_MESSAGES } from '../input-consts';
|
|
11
|
-
import { InputTimeMeridiem } from '../input-type';
|
|
12
|
-
import { InputValidationComponent } from '../input-validation/input-validation.component';
|
|
13
|
-
import { InputRequiredLabelPipe } from '../input.pipe';
|
|
14
|
-
|
|
15
|
-
@Component({
|
|
16
|
-
selector: 'frg-input-date-time',
|
|
17
|
-
imports: [InputRequiredLabelPipe, ReactiveFormsModule, AsyncPipe, InputCalendarComponent, InputValidationComponent, InputClockPickerComponent],
|
|
18
|
-
templateUrl: './input-date-time.component.html',
|
|
19
|
-
styleUrl: './input-date-time.component.scss',
|
|
20
|
-
})
|
|
21
|
-
export class InputDateTimeComponent extends InputBase<Date | null> {
|
|
22
|
-
|
|
23
|
-
@HostListener('document:click', ['$event'])
|
|
24
|
-
onDocumentClick(event: MouseEvent) {
|
|
25
|
-
const target = event.target as HTMLElement;
|
|
26
|
-
|
|
27
|
-
const wrapper = document.getElementById(this.id)?.closest('.frg-input__wrapper');
|
|
28
|
-
|
|
29
|
-
if (!target.closest('.frg-input__wrapper') || !wrapper?.contains(target)) {
|
|
30
|
-
this.showDateTimePicker$.next(false);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @inheritdoc
|
|
36
|
-
*/
|
|
37
|
-
@Input() public override label: string = '';
|
|
38
|
-
/**
|
|
39
|
-
* @inheritdoc
|
|
40
|
-
*/
|
|
41
|
-
@Input() public override placeholder: string = '';
|
|
42
|
-
/**
|
|
43
|
-
* @inheritdoc
|
|
44
|
-
*/
|
|
45
|
-
@Input() public override required: boolean = false;
|
|
46
|
-
/**
|
|
47
|
-
* @inheritdoc
|
|
48
|
-
*/
|
|
49
|
-
@Input() public override showValidation: boolean = true;
|
|
50
|
-
/**
|
|
51
|
-
* @inheritdoc
|
|
52
|
-
*/
|
|
53
|
-
@Input() public override errorMessages: Record<string, string> = {};
|
|
54
|
-
/**
|
|
55
|
-
* Minimum year selectable in the calendar
|
|
56
|
-
*/
|
|
57
|
-
@Input() public minDateTime: Date = new Date(1900, 0, 1, 0, 0, 0);
|
|
58
|
-
/**
|
|
59
|
-
* Maximum year selectable in the calendar
|
|
60
|
-
*/
|
|
61
|
-
@Input() public maxDateTime: Date = new Date(2099, 11, 31, 0, 0, 0);
|
|
62
|
-
/**
|
|
63
|
-
* The format of date time
|
|
64
|
-
*/
|
|
65
|
-
@Input() public format: DateTimeFormat = 'dd/MM/yyyy HH:mm';
|
|
66
|
-
|
|
67
|
-
public showDateTimePicker$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
68
|
-
|
|
69
|
-
public get currentMeridiem(): InputTimeMeridiem{
|
|
70
|
-
return this.meridiem;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Returns whether any warnings are active.
|
|
75
|
-
*/
|
|
76
|
-
protected get hasWarning(): boolean {
|
|
77
|
-
return this.warningList.length > 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Returns dynamic warning messages, replacing {{limit}} with actual values.
|
|
82
|
-
*/
|
|
83
|
-
protected override get warningList(): string[] {
|
|
84
|
-
return Object.keys(this.warnings).map(key => {
|
|
85
|
-
const template = DEFAULT_INPUT_DATE_TIME_WARNINGS_MESSAGES[key] || 'Check this value.';
|
|
86
|
-
|
|
87
|
-
let replacement: string | undefined;
|
|
88
|
-
|
|
89
|
-
switch (key) {
|
|
90
|
-
case 'format':
|
|
91
|
-
replacement = this.format;
|
|
92
|
-
break;
|
|
93
|
-
case 'min':
|
|
94
|
-
replacement = formatDateTimeToString(this.minDateTime, this.format);
|
|
95
|
-
break;
|
|
96
|
-
case 'max':
|
|
97
|
-
replacement = formatDateTimeToString(this.maxDateTime, this.format);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (replacement != null) {
|
|
102
|
-
const placeholder = key === 'format' ? '{{format}}' : '{{limit}}';
|
|
103
|
-
return template.replace(placeholder, replacement.toString());
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return template;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** Internal store for warnings */
|
|
111
|
-
private readonly warnings: Record<string, boolean> = {};
|
|
112
|
-
|
|
113
|
-
/** Current meridiem passed to clock picker */
|
|
114
|
-
private meridiem: InputTimeMeridiem = 'AM';
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Handles the blur event on the input element.
|
|
118
|
-
* Marks the control as touched.
|
|
119
|
-
*/
|
|
120
|
-
public override onFocus(_event: FocusEvent): void {
|
|
121
|
-
this.showDateTimePicker$.next(true);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Handles the blur event on the input element.
|
|
126
|
-
* Marks the control as touched.
|
|
127
|
-
*/
|
|
128
|
-
public override onBlur(event: FocusEvent): void {
|
|
129
|
-
const input = event.target as HTMLInputElement;
|
|
130
|
-
const value = input.value.trim();
|
|
131
|
-
|
|
132
|
-
this.validate(value);
|
|
133
|
-
|
|
134
|
-
if (isValidDateTime(value, this.format)) {
|
|
135
|
-
let date = convertStringToDateTime(value, this.format);
|
|
136
|
-
if (date) {
|
|
137
|
-
date = this.clampDate(date);
|
|
138
|
-
}
|
|
139
|
-
this.value = date ?? null;
|
|
140
|
-
input.value = this.formatDate(this.value);
|
|
141
|
-
} else {
|
|
142
|
-
input.value = '';
|
|
143
|
-
this.value = null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
this.onTouched();
|
|
147
|
-
this.onChange(this.value);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Format value for input display
|
|
152
|
-
* @param value Date value
|
|
153
|
-
* @returns Formatted date string
|
|
154
|
-
*/
|
|
155
|
-
protected formatDate(value: Date | null): string {
|
|
156
|
-
if (value) {
|
|
157
|
-
return formatDateTimeToString(value, this.format);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return '';
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
protected override updateView(_value: Date | null): void {
|
|
164
|
-
// To be implemented<
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
protected override updateDisabledState(_isDisabled: boolean): void {
|
|
168
|
-
// To be implemented
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @inheritdoc
|
|
173
|
-
*/
|
|
174
|
-
protected override get errorList(): string[] {
|
|
175
|
-
if (!this.control?.errors) return [];
|
|
176
|
-
|
|
177
|
-
const errors = this.control.errors;
|
|
178
|
-
return Object.keys(errors)
|
|
179
|
-
.filter(key => !key.startsWith('warning_'))
|
|
180
|
-
.map(key => {
|
|
181
|
-
if (this.errorMessages[key]) {
|
|
182
|
-
return this.errorMessages[key];
|
|
183
|
-
}
|
|
184
|
-
let template = this.errorMessages[key] || DEFAULT_INPUT_DATE_TIME_ERROR_MESSAGES[key] || 'Invalid field.';
|
|
185
|
-
|
|
186
|
-
switch (key) {
|
|
187
|
-
case 'min':
|
|
188
|
-
template = template.replace('{{date}}', formatDateTimeToString(this.minDateTime, this.format));
|
|
189
|
-
break;
|
|
190
|
-
case 'max':
|
|
191
|
-
template = template.replace('{{date}}', formatDateTimeToString(this.maxDateTime, this.format));
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return template;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @inheritdoc
|
|
201
|
-
*/
|
|
202
|
-
public override ngOnInit(): void {
|
|
203
|
-
super.ngOnInit();
|
|
204
|
-
this.initPlaceholder();
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public clearValue(): void {
|
|
208
|
-
this.value = null;
|
|
209
|
-
this.meridiem = 'AM';
|
|
210
|
-
this.showDateTimePicker$.next(false);
|
|
211
|
-
|
|
212
|
-
this.onChange(this.value);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
protected selectDate(date: Date) {
|
|
216
|
-
if (this.value) {
|
|
217
|
-
const hours = this.value.getHours();
|
|
218
|
-
const minutes = this.value.getMinutes();
|
|
219
|
-
const seconds = this.value.getSeconds();
|
|
220
|
-
const milliseconds = this.value.getMilliseconds();
|
|
221
|
-
|
|
222
|
-
this.value = new Date(
|
|
223
|
-
date.getFullYear(),
|
|
224
|
-
date.getMonth(),
|
|
225
|
-
date.getDate(),
|
|
226
|
-
hours,
|
|
227
|
-
minutes,
|
|
228
|
-
seconds,
|
|
229
|
-
milliseconds
|
|
230
|
-
);
|
|
231
|
-
} else {
|
|
232
|
-
this.value = date;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
this.onChange(this.value);
|
|
236
|
-
this.onTouched();
|
|
237
|
-
this.selectMeridiem(this.currentMeridiem);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Initialize the placeholder based on the date format
|
|
242
|
-
*/
|
|
243
|
-
private initPlaceholder() {
|
|
244
|
-
this.placeholder = this.format;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
protected selectHour(hour: string) {
|
|
248
|
-
if (!this.value) {
|
|
249
|
-
this.value = this.clampDate(new Date());
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const newDate = new Date(this.value);
|
|
253
|
-
const currentHours = newDate.getHours();
|
|
254
|
-
|
|
255
|
-
let newHours = Number.parseInt(hour, 10);
|
|
256
|
-
|
|
257
|
-
if (isMeridiemFormat(extractTimeFormat(this.format))) {
|
|
258
|
-
const isPM = currentHours >= 12;
|
|
259
|
-
|
|
260
|
-
if (isPM) {
|
|
261
|
-
newHours = newHours === 12 ? 12 : newHours + 12;
|
|
262
|
-
} else {
|
|
263
|
-
newHours = newHours === 12 ? 0 : newHours;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
newDate.setHours(newHours);
|
|
268
|
-
this.value = newDate;
|
|
269
|
-
|
|
270
|
-
this.onChange(this.value);
|
|
271
|
-
this.onTouched();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
protected selectMinute(minute: string) {
|
|
275
|
-
if (!this.value) {
|
|
276
|
-
this.value = this.clampDate(new Date());
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const newDate = new Date(this.value);
|
|
280
|
-
const newMinutes = Number.parseInt(minute, 10);
|
|
281
|
-
|
|
282
|
-
newDate.setMinutes(newMinutes);
|
|
283
|
-
this.value = newDate;
|
|
284
|
-
|
|
285
|
-
this.onChange(this.value);
|
|
286
|
-
this.onTouched();
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
protected selectMeridiem(meridiem: InputTimeMeridiem) {
|
|
290
|
-
if (!this.value) {
|
|
291
|
-
const now = new Date();
|
|
292
|
-
const base = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
293
|
-
this.value = this.clampDate(base);
|
|
294
|
-
this.meridiem = meridiem;
|
|
295
|
-
this.onChange(this.value);
|
|
296
|
-
this.onTouched();
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const newDate = new Date(this.value);
|
|
301
|
-
let hours = newDate.getHours();
|
|
302
|
-
|
|
303
|
-
if (meridiem === 'AM' && hours >= 12) hours -= 12;
|
|
304
|
-
if (meridiem === 'PM' && hours < 12) hours += 12;
|
|
305
|
-
|
|
306
|
-
newDate.setHours(hours);
|
|
307
|
-
this.value = newDate;
|
|
308
|
-
this.meridiem = meridiem;
|
|
309
|
-
|
|
310
|
-
this.onChange(this.value);
|
|
311
|
-
this.onTouched();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
protected get timeFormat(): TimeFormat | null {
|
|
315
|
-
return extractTimeFormat(this.format);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
protected toggleDateTimePicker() {
|
|
319
|
-
this.showDateTimePicker$.next(!this.showDateTimePicker$.value);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Adds a warning flag
|
|
324
|
-
* @param key Warning key
|
|
325
|
-
*/
|
|
326
|
-
private addWarning(key: string): void {
|
|
327
|
-
this.warnings[key] = true;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Clamp a date within min/max boundaries
|
|
332
|
-
* @param date Date to clamp
|
|
333
|
-
* @returns Clamped date and sets warnings if needed
|
|
334
|
-
*/
|
|
335
|
-
private clampDate(date: Date): Date {
|
|
336
|
-
let clamped = date;
|
|
337
|
-
|
|
338
|
-
if (this.minDateTime && date < this.minDateTime) {
|
|
339
|
-
this.addWarning('min');
|
|
340
|
-
clamped = this.minDateTime;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (this.maxDateTime && date > this.maxDateTime) {
|
|
344
|
-
this.addWarning('max');
|
|
345
|
-
clamped = this.maxDateTime;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return clamped;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Remove a warning flag
|
|
353
|
-
* @param key Warning key
|
|
354
|
-
*/
|
|
355
|
-
private removeWarning(key: string): void {
|
|
356
|
-
delete this.warnings[key];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Validate the input value against the specified format
|
|
361
|
-
* @param value Input value
|
|
362
|
-
*/
|
|
363
|
-
private validate(value: string): void {
|
|
364
|
-
this.removeWarning('format');
|
|
365
|
-
this.removeWarning('min');
|
|
366
|
-
this.removeWarning('max');
|
|
367
|
-
|
|
368
|
-
if (!value) return;
|
|
369
|
-
|
|
370
|
-
if (this.format) {
|
|
371
|
-
const regex = buildDateTimeFormatRegex(this.format);
|
|
372
|
-
if (!regex.test(value)) {
|
|
373
|
-
this.addWarning('format');
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const date = convertStringToDateTime(value, this.format);
|
|
379
|
-
if (!date) return;
|
|
380
|
-
|
|
381
|
-
if (this.minDateTime && date < this.minDateTime) {
|
|
382
|
-
this.addWarning('min');
|
|
383
|
-
} else if (this.maxDateTime && date > this.maxDateTime) {
|
|
384
|
-
this.addWarning('max');
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
<div class="frg-input__wrapper"
|
|
2
|
-
[class.input-error]="hasError"
|
|
3
|
-
(dragover)="onDragOver($event)"
|
|
4
|
-
(dragleave)="onDragLeave($event)"
|
|
5
|
-
(drop)="onDrop($event)"
|
|
6
|
-
>
|
|
7
|
-
@if(label){
|
|
8
|
-
<label [for]="id">{{ label | inputRequiredLabel: required }}</label>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
<div class="frg-input__file" [class.has-files]="hasFiles" [class.is-dragover]="isDragOver">
|
|
12
|
-
<div class="frg-input__file-main">
|
|
13
|
-
<frg-button
|
|
14
|
-
[styleType]="'primary'"
|
|
15
|
-
[shape]="'pill'"
|
|
16
|
-
[size]="'small'"
|
|
17
|
-
[text]="buttonLabel"
|
|
18
|
-
[iconClass]="'fas fa-plus'"
|
|
19
|
-
[iconStyleType]="'light'"
|
|
20
|
-
[iconPosition]="'left'"
|
|
21
|
-
[disabled]="disabled"
|
|
22
|
-
(clickEvent)="triggerFileDialog()"
|
|
23
|
-
>
|
|
24
|
-
</frg-button>
|
|
25
|
-
|
|
26
|
-
<div class="frg-input__file-summary">
|
|
27
|
-
<span class="frg-input__file-summary-title">{{ fileSummary }}</span>
|
|
28
|
-
<span class="frg-input__file-summary-subtitle">Drop or browse to upload</span>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
@if(showClearButton && hasFiles){
|
|
33
|
-
<button
|
|
34
|
-
type="button"
|
|
35
|
-
class="frg-input__file-clear"
|
|
36
|
-
[disabled]="disabled"
|
|
37
|
-
(click)="clearFiles()"
|
|
38
|
-
>
|
|
39
|
-
Clear all
|
|
40
|
-
</button>
|
|
41
|
-
}
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
<input
|
|
45
|
-
#fileInput
|
|
46
|
-
[id]="id"
|
|
47
|
-
type="file"
|
|
48
|
-
class="frg-input__file-input"
|
|
49
|
-
[required]="required"
|
|
50
|
-
[disabled]="disabled"
|
|
51
|
-
[attr.accept]="accept || null"
|
|
52
|
-
[attr.multiple]="multiple ? '' : null"
|
|
53
|
-
(change)="onFileChange($event)"
|
|
54
|
-
(blur)="onBlur($event)"
|
|
55
|
-
/>
|
|
56
|
-
|
|
57
|
-
@if(showFileList && files.length){
|
|
58
|
-
<div class="frg-input__file-list">
|
|
59
|
-
@for(file of files; track trackFile($index, file)){
|
|
60
|
-
<div class="frg-input__file-chip">
|
|
61
|
-
<span class="frg-input__file-name">{{ file.name }}</span>
|
|
62
|
-
@if(showFileSize){
|
|
63
|
-
<span class="frg-input__file-size">{{ formatBytes(file.size) }}</span>
|
|
64
|
-
}
|
|
65
|
-
@if(multiple){
|
|
66
|
-
<button
|
|
67
|
-
type="button"
|
|
68
|
-
class="frg-input__file-remove"
|
|
69
|
-
[disabled]="disabled"
|
|
70
|
-
(click)="removeFile($index)"
|
|
71
|
-
aria-label="Remove file"
|
|
72
|
-
>
|
|
73
|
-
x
|
|
74
|
-
</button>
|
|
75
|
-
}
|
|
76
|
-
</div>
|
|
77
|
-
}
|
|
78
|
-
</div>
|
|
79
|
-
}
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
@if (showValidation) {
|
|
83
|
-
<frg-input-validation
|
|
84
|
-
[errorList]="errorList"
|
|
85
|
-
[warningList]="warningList"
|
|
86
|
-
[isFormInvalid]="hasError"
|
|
87
|
-
>
|
|
88
|
-
</frg-input-validation>
|
|
89
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
@use './../../../../../assets/styles/scss/variables' as *;
|
|
2
|
-
|
|
3
|
-
:host {
|
|
4
|
-
display: block;
|
|
5
|
-
|
|
6
|
-
label {
|
|
7
|
-
display: flex;
|
|
8
|
-
font-size: $font-size-xs;
|
|
9
|
-
color: $input-text-color;
|
|
10
|
-
padding: $input-padding;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.frg-input {
|
|
14
|
-
font-family: $input-font-family;
|
|
15
|
-
|
|
16
|
-
&__wrapper {
|
|
17
|
-
position: relative;
|
|
18
|
-
display: inline-block;
|
|
19
|
-
width: 100%;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&__file {
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: space-between;
|
|
26
|
-
gap: 1rem;
|
|
27
|
-
padding: 0.75rem 0.85rem;
|
|
28
|
-
border: 1px dashed $input-border-color;
|
|
29
|
-
border-radius: $input-border-radius;
|
|
30
|
-
font-family: $input-font-family;
|
|
31
|
-
color: $input-text-color;
|
|
32
|
-
background: $input-background;
|
|
33
|
-
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
34
|
-
|
|
35
|
-
&.has-files {
|
|
36
|
-
border-style: solid;
|
|
37
|
-
border-color: $input-focus-border-color;
|
|
38
|
-
box-shadow: $box-shadow-light-sm;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&.is-dragover {
|
|
42
|
-
border-color: $color-primary;
|
|
43
|
-
box-shadow: $box-shadow-primary-sm;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&:hover {
|
|
47
|
-
border-color: $input-focus-border-color;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&__file-main {
|
|
52
|
-
display: flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
gap: 0.75rem;
|
|
55
|
-
flex: 1;
|
|
56
|
-
min-width: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
frg-button .frg-btn {
|
|
60
|
-
margin: 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&__file-summary {
|
|
64
|
-
display: flex;
|
|
65
|
-
flex-direction: column;
|
|
66
|
-
gap: 0.15rem;
|
|
67
|
-
min-width: 0;
|
|
68
|
-
font-size: $font-size-sm;
|
|
69
|
-
color: $input-text-color;
|
|
70
|
-
overflow: hidden;
|
|
71
|
-
text-overflow: ellipsis;
|
|
72
|
-
white-space: nowrap;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&__file-summary-title {
|
|
76
|
-
font-weight: 600;
|
|
77
|
-
overflow: hidden;
|
|
78
|
-
text-overflow: ellipsis;
|
|
79
|
-
white-space: nowrap;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&__file-summary-subtitle {
|
|
83
|
-
font-size: $font-size-xs;
|
|
84
|
-
color: $color-dark-soft;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&__file-clear {
|
|
88
|
-
border: 1px solid $color-danger;
|
|
89
|
-
background: transparent;
|
|
90
|
-
color: $color-danger;
|
|
91
|
-
font-size: $font-size-xs;
|
|
92
|
-
border-radius: 999px;
|
|
93
|
-
padding: 0.2rem 0.6rem;
|
|
94
|
-
cursor: pointer;
|
|
95
|
-
|
|
96
|
-
&:disabled {
|
|
97
|
-
cursor: not-allowed;
|
|
98
|
-
opacity: 0.6;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&__file-input {
|
|
103
|
-
position: absolute;
|
|
104
|
-
inset: 0;
|
|
105
|
-
opacity: 0;
|
|
106
|
-
pointer-events: none;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&__file-list {
|
|
110
|
-
margin-top: 0.5rem;
|
|
111
|
-
display: flex;
|
|
112
|
-
flex-wrap: wrap;
|
|
113
|
-
gap: 0.4rem;
|
|
114
|
-
font-size: $font-size-sm;
|
|
115
|
-
color: $input-text-color;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
&__file-chip {
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
gap: 0.35rem;
|
|
122
|
-
background: $color-light;
|
|
123
|
-
border: 1px solid $input-border-color;
|
|
124
|
-
border-radius: 999px;
|
|
125
|
-
padding: 0.2rem 0.5rem;
|
|
126
|
-
box-shadow: $box-shadow-light-sm;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
&__file-name {
|
|
130
|
-
max-width: 10rem;
|
|
131
|
-
overflow: hidden;
|
|
132
|
-
text-overflow: ellipsis;
|
|
133
|
-
white-space: nowrap;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
&__file-size {
|
|
137
|
-
color: $color-dark-soft;
|
|
138
|
-
font-size: $font-size-xs;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
&__file-remove {
|
|
142
|
-
border: none;
|
|
143
|
-
background: transparent;
|
|
144
|
-
color: $color-danger;
|
|
145
|
-
font-size: $font-size-xs;
|
|
146
|
-
cursor: pointer;
|
|
147
|
-
|
|
148
|
-
&:disabled {
|
|
149
|
-
cursor: not-allowed;
|
|
150
|
-
opacity: 0.6;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
&__wrapper.input-error .frg-input__file {
|
|
155
|
-
border-color: $color-danger;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&__wrapper.input-error label {
|
|
159
|
-
color: $color-danger;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
&__wrapper::before {
|
|
163
|
-
content: "";
|
|
164
|
-
position: absolute;
|
|
165
|
-
bottom: 0;
|
|
166
|
-
left: 0;
|
|
167
|
-
width: 0;
|
|
168
|
-
height: 0;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { By } from '@angular/platform-browser';
|
|
3
|
-
import { RouterTestingModule } from '@angular/router/testing';
|
|
4
|
-
import { InputFileUploadComponent } from './input-file-upload.component';
|
|
5
|
-
|
|
6
|
-
describe('InputFileUploadComponent', () => {
|
|
7
|
-
let fixture: ComponentFixture<InputFileUploadComponent>;
|
|
8
|
-
let component: InputFileUploadComponent;
|
|
9
|
-
|
|
10
|
-
beforeEach(async () => {
|
|
11
|
-
await TestBed.configureTestingModule({
|
|
12
|
-
imports: [InputFileUploadComponent, RouterTestingModule]
|
|
13
|
-
}).compileComponents();
|
|
14
|
-
|
|
15
|
-
fixture = TestBed.createComponent(InputFileUploadComponent);
|
|
16
|
-
component = fixture.componentInstance;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('renders label when provided', () => {
|
|
20
|
-
component.label = 'Attachment';
|
|
21
|
-
|
|
22
|
-
fixture.detectChanges();
|
|
23
|
-
|
|
24
|
-
const label = fixture.debugElement.query(By.css('label'));
|
|
25
|
-
expect(label.nativeElement.textContent).toContain('Attachment');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('updates value on file change', () => {
|
|
29
|
-
const onChangeSpy = jasmine.createSpy('onChange');
|
|
30
|
-
component.registerOnChange(onChangeSpy);
|
|
31
|
-
|
|
32
|
-
fixture.detectChanges();
|
|
33
|
-
|
|
34
|
-
const file = new File(['test'], 'test.txt', { type: 'text/plain' });
|
|
35
|
-
const input = fixture.debugElement.query(By.css('input[type="file"]')).nativeElement as HTMLInputElement;
|
|
36
|
-
|
|
37
|
-
Object.defineProperty(input, 'files', { value: [file] });
|
|
38
|
-
input.dispatchEvent(new Event('change'));
|
|
39
|
-
|
|
40
|
-
expect(component.value).toBe(file);
|
|
41
|
-
expect(onChangeSpy).toHaveBeenCalledWith(file);
|
|
42
|
-
});
|
|
43
|
-
});
|