@tacdaed/fragments 1.0.0-beta.1 → 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 +4 -20
- 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,372 +0,0 @@
|
|
|
1
|
-
import { NgTemplateOutlet } from "@angular/common";
|
|
2
|
-
import { Component, ElementRef, HostListener, Input, QueryList, TemplateRef, ViewChild, ViewChildren, inject } from "@angular/core";
|
|
3
|
-
import { DEFAULT_INPUT_MULTI_SELECT_WARNINGS_MESSAGES } from "../../input/input-consts";
|
|
4
|
-
import { InputValidationComponent } from "../../input/input-validation/input-validation.component";
|
|
5
|
-
import { SelectionListBase } from "../selection-lists-base";
|
|
6
|
-
import { DEFAULT_SELECTION_LIST_ERROR_MESSAGES } from "../selection-lists-const";
|
|
7
|
-
import { SelectionListItem } from "../selection-lists-interface";
|
|
8
|
-
import { ChipComponent } from "../../status/chip/chip.component";
|
|
9
|
-
import { TChipType } from "../../status/chip/chip.type";
|
|
10
|
-
|
|
11
|
-
@Component({
|
|
12
|
-
selector: "frg-multi-select",
|
|
13
|
-
templateUrl: "./multi-select.component.html",
|
|
14
|
-
styleUrls: ["./multi-select.component.scss"],
|
|
15
|
-
imports: [NgTemplateOutlet, InputValidationComponent, ChipComponent]
|
|
16
|
-
})
|
|
17
|
-
export class MultiSelectComponent<T> extends SelectionListBase<Array<T>> {
|
|
18
|
-
private readonly elementRef = inject(ElementRef);
|
|
19
|
-
|
|
20
|
-
@Input() items: Array<SelectionListItem<T>> = [];
|
|
21
|
-
@Input() hasSearch: boolean = false;
|
|
22
|
-
@Input() optionTemplate?: TemplateRef<unknown>;
|
|
23
|
-
@Input() valuesTemplate?: TemplateRef<unknown>;
|
|
24
|
-
@Input() showChips: boolean = false;
|
|
25
|
-
@Input() chipsStyle: TChipType = "light";
|
|
26
|
-
|
|
27
|
-
@ViewChildren("optionButton") optionButtons!: QueryList<ElementRef<HTMLButtonElement>>;
|
|
28
|
-
@ViewChild("searchInput", { read: ElementRef }) searchInput?: ElementRef<HTMLInputElement>;
|
|
29
|
-
|
|
30
|
-
protected isOpen = false;
|
|
31
|
-
protected searchTerm = "";
|
|
32
|
-
protected selectedIds: Array<string> = [];
|
|
33
|
-
|
|
34
|
-
private focusedIndex = -1;
|
|
35
|
-
|
|
36
|
-
@HostListener("document:click", ['$event'])
|
|
37
|
-
closeDropdown(event: MouseEvent): void {
|
|
38
|
-
const target = event.target as HTMLElement;
|
|
39
|
-
const nativeElement = this.elementRef.nativeElement;
|
|
40
|
-
|
|
41
|
-
const clickedInside = nativeElement.contains(target);
|
|
42
|
-
const isSearchInput = target.closest('.options-search__input');
|
|
43
|
-
|
|
44
|
-
if (!clickedInside && !isSearchInput) {
|
|
45
|
-
this.isOpen = false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public get filteredItems(): Array<SelectionListItem<T>> {
|
|
50
|
-
if (this.hasSearch && this.searchTerm && this.searchTerm.length > 2) {
|
|
51
|
-
const lower = this.searchTerm.toLowerCase();
|
|
52
|
-
const lowerWithTrim = this.searchTerm.toLowerCase().trim();
|
|
53
|
-
|
|
54
|
-
return this.items.filter(item =>
|
|
55
|
-
(item.label ?? '').toLowerCase().includes(lower)
|
|
56
|
-
|| (item.label ?? '').toLowerCase().trim().includes(lowerWithTrim)
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return this.items;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public get selectedLabels(): string {
|
|
64
|
-
return this.selectedItems.length ?
|
|
65
|
-
this.selectedItems.map(x => x.label ?? '').join(', ')
|
|
66
|
-
: this.placeholder || 'Select…';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public get selectedItems(): Array<SelectionListItem<T>> {
|
|
70
|
-
return this.items.filter(i => this.selectedIds.includes(i.id));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
protected override get errorList(): string[] {
|
|
74
|
-
if (!this.control?.errors) return [];
|
|
75
|
-
const errors = this.control.errors;
|
|
76
|
-
return Object.keys(errors).map(key => {
|
|
77
|
-
if (this.errorMessages[key]) {
|
|
78
|
-
return this.errorMessages[key];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (key === 'minlength' && errors[key]?.requiredLength) {
|
|
82
|
-
return `Minimum length is ${errors[key].requiredLength} characters.`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (key === 'maxlength' && errors[key]?.requiredLength) {
|
|
86
|
-
return `Maximum length is ${errors[key].requiredLength} characters.`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return DEFAULT_SELECTION_LIST_ERROR_MESSAGES[key] || 'Invalid field.';
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public toggleDropdown(event: Event): void {
|
|
94
|
-
event.stopPropagation();
|
|
95
|
-
const target = event.target as HTMLElement | null;
|
|
96
|
-
|
|
97
|
-
if (target?.closest('frg-chip') && this.showChips) return;
|
|
98
|
-
if (this.disabled) return;
|
|
99
|
-
|
|
100
|
-
this.isOpen = !this.isOpen;
|
|
101
|
-
|
|
102
|
-
if (this.isOpen) {
|
|
103
|
-
this.setDropdownDirection();
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
if (this.hasSearch && this.searchInput) {
|
|
106
|
-
this.searchInput.nativeElement.focus();
|
|
107
|
-
const len = this.searchInput.nativeElement.value.length;
|
|
108
|
-
this.searchInput.nativeElement.setSelectionRange(len, len);
|
|
109
|
-
} else {
|
|
110
|
-
this.focusFirstItem();
|
|
111
|
-
}
|
|
112
|
-
}, 0);
|
|
113
|
-
} else {
|
|
114
|
-
this.searchTerm = "";
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public selectItem(item: SelectionListItem<T>, event: Event): void {
|
|
119
|
-
event.stopPropagation();
|
|
120
|
-
if (item.disabled) return;
|
|
121
|
-
|
|
122
|
-
this.updateSelection(item, item.selected);
|
|
123
|
-
|
|
124
|
-
this.value = this.selectedItems
|
|
125
|
-
.map(i => i.value)
|
|
126
|
-
.filter((v): v is T => v !== null);
|
|
127
|
-
|
|
128
|
-
this.focusedIndex = this.items.findIndex(i => i.id === item.id);
|
|
129
|
-
|
|
130
|
-
this.onChange(this.value);
|
|
131
|
-
this.onTouched();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
protected removeItem(item: SelectionListItem<T>, event: MouseEvent): void {
|
|
135
|
-
event.stopPropagation();
|
|
136
|
-
if (this.disabled || !item.selected) return;
|
|
137
|
-
|
|
138
|
-
this.updateSelection(item, true);
|
|
139
|
-
|
|
140
|
-
const selectedValues = this.selectedItems
|
|
141
|
-
.map(i => i.value)
|
|
142
|
-
.filter((v): v is T => v !== null);
|
|
143
|
-
|
|
144
|
-
this.value = selectedValues.length ? selectedValues : null;
|
|
145
|
-
|
|
146
|
-
this.onChange(this.value);
|
|
147
|
-
this.onTouched();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
protected removeItemById(id: string): void {
|
|
151
|
-
if (this.disabled) return;
|
|
152
|
-
const item = this.items.find(current => current.id === id);
|
|
153
|
-
if (!item || !item.selected) return;
|
|
154
|
-
|
|
155
|
-
this.updateSelection(item, true);
|
|
156
|
-
|
|
157
|
-
const selectedValues = this.selectedItems
|
|
158
|
-
.map(i => i.value)
|
|
159
|
-
.filter((v): v is T => v !== null);
|
|
160
|
-
|
|
161
|
-
this.value = selectedValues.length ? selectedValues : null;
|
|
162
|
-
|
|
163
|
-
this.onChange(this.value);
|
|
164
|
-
this.onTouched();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
protected override clearValue(event: MouseEvent) {
|
|
168
|
-
event.stopPropagation();
|
|
169
|
-
|
|
170
|
-
for (const selectedItem of this.selectedItems) {
|
|
171
|
-
selectedItem.selected = false;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
this.selectedIds = [];
|
|
175
|
-
this.value = null;
|
|
176
|
-
this.searchTerm = '';
|
|
177
|
-
this.isOpen = false;
|
|
178
|
-
|
|
179
|
-
this.onChange(null);
|
|
180
|
-
this.onTouched();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
protected onKeyDown(event: KeyboardEvent): void {
|
|
184
|
-
if (this.disabled) return;
|
|
185
|
-
|
|
186
|
-
switch (event.key) {
|
|
187
|
-
case "Enter":
|
|
188
|
-
case " ":
|
|
189
|
-
case "Spacebar":
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
this.toggleDropdown(event);
|
|
192
|
-
break;
|
|
193
|
-
case "ArrowDown":
|
|
194
|
-
event.preventDefault();
|
|
195
|
-
if (!this.isOpen) this.isOpen = true;
|
|
196
|
-
setTimeout(() => {
|
|
197
|
-
if (this.hasSearch && this.searchInput) {
|
|
198
|
-
this.searchInput.nativeElement.focus();
|
|
199
|
-
} else {
|
|
200
|
-
this.focusFirstItem();
|
|
201
|
-
}
|
|
202
|
-
}, 0);
|
|
203
|
-
break;
|
|
204
|
-
case "Escape":
|
|
205
|
-
this.isOpen = false;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
protected onOptionKeyDown(event: KeyboardEvent, item: SelectionListItem<T>, index: number): void {
|
|
211
|
-
switch (event.key) {
|
|
212
|
-
case "Enter":
|
|
213
|
-
case " ":
|
|
214
|
-
case "Spacebar":
|
|
215
|
-
event.preventDefault();
|
|
216
|
-
this.selectItem(item, event);
|
|
217
|
-
break;
|
|
218
|
-
case "ArrowDown":
|
|
219
|
-
event.preventDefault();
|
|
220
|
-
this.focusNextItem(index);
|
|
221
|
-
break;
|
|
222
|
-
case "ArrowUp":
|
|
223
|
-
event.preventDefault();
|
|
224
|
-
this.focusPreviousItem(index);
|
|
225
|
-
break;
|
|
226
|
-
case "Escape":
|
|
227
|
-
event.preventDefault();
|
|
228
|
-
this.isOpen = false;
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
protected override onBlur(event: FocusEvent): void {
|
|
234
|
-
const nativeElement = this.elementRef.nativeElement;
|
|
235
|
-
const relatedTarget = event.relatedTarget as Node;
|
|
236
|
-
if (!relatedTarget || !nativeElement.contains(relatedTarget)) {
|
|
237
|
-
this.isOpen = false;
|
|
238
|
-
this.searchTerm = '';
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
protected override onFocus(): void {
|
|
243
|
-
if (!this.disabled) {
|
|
244
|
-
this.isOpen = true;
|
|
245
|
-
this.setDropdownDirection();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
protected onSearch(event: Event): void {
|
|
250
|
-
const target = event.target;
|
|
251
|
-
if (target instanceof HTMLInputElement) {
|
|
252
|
-
this.searchTerm = target.value ?? '';
|
|
253
|
-
this.focusedIndex = 0;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
protected onSearchKeyDown(event: KeyboardEvent): void {
|
|
258
|
-
if (event.key === "Enter" && this.searchTerm.length > 2) {
|
|
259
|
-
event.preventDefault();
|
|
260
|
-
const exactMatch = this.filteredItems.find(i => i.label?.toLowerCase().includes(this.searchTerm.toLowerCase()));
|
|
261
|
-
if (exactMatch) {
|
|
262
|
-
this.selectItem(exactMatch, event);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
switch (event.key) {
|
|
267
|
-
case "ArrowDown":
|
|
268
|
-
event.preventDefault();
|
|
269
|
-
setTimeout(() => this.focusFirstItem(), 0);
|
|
270
|
-
break;
|
|
271
|
-
|
|
272
|
-
case "Escape":
|
|
273
|
-
event.preventDefault();
|
|
274
|
-
this.isOpen = false;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
protected override updateDisabledState(_isDisabled: boolean): void {
|
|
280
|
-
//Intentionally left void, to implement in case is needed
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
protected updateSelection(item: SelectionListItem<T>, isAlreadySelected: boolean): void {
|
|
284
|
-
item.selected = !isAlreadySelected;
|
|
285
|
-
|
|
286
|
-
if (isAlreadySelected) {
|
|
287
|
-
this.selectedIds = this.selectedIds.filter(id => id !== item.id);
|
|
288
|
-
} else {
|
|
289
|
-
this.selectedIds.push(item.id);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
protected override updateView(_value: Array<T> | null): void {
|
|
294
|
-
//Intentionally left void, to implement in case is needed
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
private focusFirstItem(): void {
|
|
298
|
-
const buttons = this.getEnabledButtons();
|
|
299
|
-
if (buttons.length > 0) {
|
|
300
|
-
this.focusedIndex = 0;
|
|
301
|
-
buttons[0].focus();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private focusNextItem(currentIndex: number = this.focusedIndex): void {
|
|
306
|
-
const buttons = this.getEnabledButtons();
|
|
307
|
-
if (buttons.length === 0) return;
|
|
308
|
-
|
|
309
|
-
const nextIndex = (currentIndex + 1) % buttons.length;
|
|
310
|
-
this.focusedIndex = nextIndex;
|
|
311
|
-
buttons[nextIndex].focus();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
private focusPreviousItem(currentIndex: number = this.focusedIndex): void {
|
|
315
|
-
const buttons = this.getEnabledButtons();
|
|
316
|
-
if (buttons.length === 0) return;
|
|
317
|
-
|
|
318
|
-
const prevIndex = (currentIndex - 1 + buttons.length) % buttons.length;
|
|
319
|
-
this.focusedIndex = prevIndex;
|
|
320
|
-
buttons[prevIndex].focus();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private getEnabledButtons(): HTMLButtonElement[] {
|
|
324
|
-
return this.optionButtons
|
|
325
|
-
? this.optionButtons.map(ref => ref.nativeElement).filter(btn => !btn.disabled)
|
|
326
|
-
: [];
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
private setDropdownDirection(): void {
|
|
330
|
-
const trigger: HTMLElement | undefined = this.elementRef.nativeElement.querySelector('.custom-select');
|
|
331
|
-
const searchTrigger: HTMLElement | undefined = this.elementRef.nativeElement.querySelector('.options-search__input');
|
|
332
|
-
const dropdownHeight: number = 240;
|
|
333
|
-
|
|
334
|
-
if(trigger || searchTrigger){
|
|
335
|
-
const rect = trigger?.getBoundingClientRect() || searchTrigger?.getBoundingClientRect();
|
|
336
|
-
const viewportHeight = window.innerHeight;
|
|
337
|
-
|
|
338
|
-
const spaceBelow = viewportHeight - (rect?.bottom ?? 0);
|
|
339
|
-
const spaceAbove = (rect?.top ?? 0);
|
|
340
|
-
|
|
341
|
-
if (spaceBelow >= dropdownHeight) {
|
|
342
|
-
this.openDirection = 'down';
|
|
343
|
-
} else if (spaceAbove >= dropdownHeight) {
|
|
344
|
-
this.openDirection = 'top';
|
|
345
|
-
} else {
|
|
346
|
-
this.openDirection = spaceBelow > spaceAbove ? 'down' : 'top';
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Returns warning messages. Consumers may pass arbitrary warnings via `warningMessages`.
|
|
353
|
-
* Falls back to DEFAULT_INPUT_MULTI_SELECT_WARNINGS_MESSAGES or a generic message.
|
|
354
|
-
*/
|
|
355
|
-
protected override get warningList(): string[] {
|
|
356
|
-
return Object.keys(this.warningMessages).map(key => {
|
|
357
|
-
return (
|
|
358
|
-
this.warningMessages[key] ||
|
|
359
|
-
DEFAULT_INPUT_MULTI_SELECT_WARNINGS_MESSAGES[key] ||
|
|
360
|
-
''
|
|
361
|
-
);
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Returns whether any warnings are active.
|
|
367
|
-
*/
|
|
368
|
-
protected get hasWarning(): boolean {
|
|
369
|
-
return this.warningList.length > 0;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
<div class="frg-selection-list"
|
|
2
|
-
[class.selection-list-error]="hasError"
|
|
3
|
-
>
|
|
4
|
-
<label [attr.for]="id + '-options'">{{ label }}</label>
|
|
5
|
-
|
|
6
|
-
@if(hasSearch){
|
|
7
|
-
<div class="options-search">
|
|
8
|
-
<input
|
|
9
|
-
#searchInput
|
|
10
|
-
type="text"
|
|
11
|
-
[attr.name]="id + '-options'"
|
|
12
|
-
[attr.id]="id + '-options'"
|
|
13
|
-
class="options-search__input"
|
|
14
|
-
[class.open]="isOpen"
|
|
15
|
-
[attr.placeholder]="'Select…'"
|
|
16
|
-
aria-label="Search options"
|
|
17
|
-
role="searchbox"
|
|
18
|
-
[value]="searchTerm"
|
|
19
|
-
(input)="onSearch($event)"
|
|
20
|
-
(blur)="onBlur($event)"
|
|
21
|
-
(focus)="toggleDropdown($event)"
|
|
22
|
-
(keydown)="onSearchKeyDown($event)"
|
|
23
|
-
/>
|
|
24
|
-
<div class="selection-list__actions">
|
|
25
|
-
@if(searchTerm.length){
|
|
26
|
-
<button
|
|
27
|
-
type="button"
|
|
28
|
-
class="clear-button"
|
|
29
|
-
aria-label="Clear input"
|
|
30
|
-
(click)="clearValue($event)"
|
|
31
|
-
>
|
|
32
|
-
<span class="fas fa-xmark"></span>
|
|
33
|
-
</button>
|
|
34
|
-
}
|
|
35
|
-
<button
|
|
36
|
-
type="button"
|
|
37
|
-
class="arrow-button"
|
|
38
|
-
[class.open]="isOpen"
|
|
39
|
-
aria-label="Toggle dropdown"
|
|
40
|
-
(click)="toggleDropdown($event)"
|
|
41
|
-
>
|
|
42
|
-
<span class="arrow-icon fas fa-chevron-down"></span>
|
|
43
|
-
</button>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
} @else {
|
|
47
|
-
<div class="frg-selection-list__handle-buttons">
|
|
48
|
-
<button
|
|
49
|
-
type="button"
|
|
50
|
-
class="custom-select"
|
|
51
|
-
[id]="id + '-options'"
|
|
52
|
-
[attr.name]="id + '-options'"
|
|
53
|
-
[class.open]="isOpen"
|
|
54
|
-
[disabled]="disabled"
|
|
55
|
-
[attr.aria-expanded]="isOpen"
|
|
56
|
-
(click)="toggleDropdown($event)"
|
|
57
|
-
(keydown)="onKeyDown($event)"
|
|
58
|
-
[attr.aria-controls]="id + '-options'"
|
|
59
|
-
>
|
|
60
|
-
<span class="item-label" [class.selected]="selectedItem">
|
|
61
|
-
{{ selectedItem?.label || placeholder || 'Select…' }}
|
|
62
|
-
</span>
|
|
63
|
-
</button>
|
|
64
|
-
|
|
65
|
-
<div class="selection-list__actions">
|
|
66
|
-
@if(value && selectedItem){
|
|
67
|
-
<button
|
|
68
|
-
type="button"
|
|
69
|
-
class="clear-button"
|
|
70
|
-
aria-label="Clear input"
|
|
71
|
-
(click)="clearValue($event)"
|
|
72
|
-
>
|
|
73
|
-
<span class="fas fa-xmark"></span>
|
|
74
|
-
</button>
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
<button
|
|
78
|
-
type="button"
|
|
79
|
-
class="arrow-button"
|
|
80
|
-
[class.open]="isOpen"
|
|
81
|
-
aria-label="Toggle dropdown"
|
|
82
|
-
(click)="toggleDropdown($event)"
|
|
83
|
-
>
|
|
84
|
-
<span class="arrow-icon fas fa-chevron-down"></span>
|
|
85
|
-
</button>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
<frg-input-validation
|
|
91
|
-
[errorList]="errorList"
|
|
92
|
-
[isFormInvalid]="hasError"
|
|
93
|
-
>
|
|
94
|
-
</frg-input-validation>
|
|
95
|
-
|
|
96
|
-
@if (isOpen) {
|
|
97
|
-
<div
|
|
98
|
-
class="options"
|
|
99
|
-
[id]="id + '-options'"
|
|
100
|
-
[class.open-up]="openDirection === 'top'"
|
|
101
|
-
[class.open-down]="openDirection === 'down'"
|
|
102
|
-
>
|
|
103
|
-
@for (item of filteredItems; track item.id; let idx = $index) {
|
|
104
|
-
<button
|
|
105
|
-
#optionButton
|
|
106
|
-
type="button"
|
|
107
|
-
class="option"
|
|
108
|
-
[class.disabled]="item.disabled"
|
|
109
|
-
[class.selected]="item.id === selectedId"
|
|
110
|
-
[disabled]="item.disabled"
|
|
111
|
-
(focus)="onFocus()"
|
|
112
|
-
(blur)="onBlur($event)"
|
|
113
|
-
(click)="selectItem(item, $event)"
|
|
114
|
-
(keydown)="onOptionKeyDown($event, item, idx)"
|
|
115
|
-
>
|
|
116
|
-
@if(optionTemplate) {
|
|
117
|
-
<ng-container *ngTemplateOutlet="optionTemplate; context: { $implicit: item }"></ng-container>
|
|
118
|
-
} @else {
|
|
119
|
-
{{ item.label }}
|
|
120
|
-
}
|
|
121
|
-
</button>
|
|
122
|
-
}
|
|
123
|
-
</div>
|
|
124
|
-
}
|
|
125
|
-
</div>
|