@tacdaed/fragments 1.0.0-beta.3 → 1.0.0-beta.4

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.
Files changed (248) hide show
  1. package/README.md +14 -0
  2. package/ng-package.json +20 -0
  3. package/package.json +22 -29
  4. package/src/lib/components/accordion/accordion.component.html +103 -0
  5. package/src/lib/components/accordion/accordion.component.scss +382 -0
  6. package/src/lib/components/accordion/accordion.component.spec.ts +147 -0
  7. package/src/lib/components/accordion/accordion.component.ts +211 -0
  8. package/src/lib/components/accordion/accordion.type.ts +82 -0
  9. package/src/lib/components/breadcrumb/breadcrumb.component.html +43 -0
  10. package/src/lib/components/breadcrumb/breadcrumb.component.scss +112 -0
  11. package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +33 -0
  12. package/src/lib/components/breadcrumb/breadcrumb.component.ts +103 -0
  13. package/src/lib/components/breadcrumb/breadcrumb.interface.ts +7 -0
  14. package/src/lib/components/button/button.component.html +57 -0
  15. package/src/lib/components/button/button.component.scss +445 -0
  16. package/src/lib/components/button/button.component.spec.ts +99 -0
  17. package/src/lib/components/button/button.component.ts +143 -0
  18. package/src/lib/components/button/button.type.ts +7 -0
  19. package/src/lib/components/card/card.component.html +44 -0
  20. package/src/lib/components/card/card.component.scss +114 -0
  21. package/src/lib/components/card/card.component.spec.ts +65 -0
  22. package/src/lib/components/card/card.component.ts +21 -0
  23. package/src/lib/components/card/card.type.ts +3 -0
  24. package/src/lib/components/code-block/code-block.component.html +55 -0
  25. package/src/lib/components/code-block/code-block.component.scss +122 -0
  26. package/src/lib/components/code-block/code-block.component.spec.ts +81 -0
  27. package/src/lib/components/code-block/code-block.component.ts +302 -0
  28. package/src/lib/components/code-block/code-block.interface.ts +28 -0
  29. package/src/lib/components/code-block/code-block.type.ts +73 -0
  30. package/src/lib/components/decorative/sparkle-field/sparkle-field.component.html +14 -0
  31. package/src/lib/components/decorative/sparkle-field/sparkle-field.component.scss +20 -0
  32. package/src/lib/components/decorative/sparkle-field/sparkle-field.component.spec.ts +38 -0
  33. package/src/lib/components/decorative/sparkle-field/sparkle-field.component.ts +181 -0
  34. package/src/lib/components/input/input-base.ts +187 -0
  35. package/src/lib/components/input/input-calendar/input-calendar.component.html +76 -0
  36. package/src/lib/components/input/input-calendar/input-calendar.component.scss +179 -0
  37. package/src/lib/components/input/input-calendar/input-calendar.component.spec.ts +44 -0
  38. package/src/lib/components/input/input-calendar/input-calendar.component.ts +299 -0
  39. package/src/lib/components/input/input-checkbox/input-checkbox.component.html +37 -0
  40. package/src/lib/components/input/input-checkbox/input-checkbox.component.scss +128 -0
  41. package/src/lib/components/input/input-checkbox/input-checkbox.component.spec.ts +43 -0
  42. package/src/lib/components/input/input-checkbox/input-checkbox.component.ts +112 -0
  43. package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.html +43 -0
  44. package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.scss +140 -0
  45. package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.spec.ts +62 -0
  46. package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.ts +136 -0
  47. package/src/lib/components/input/input-clock-picker/input-clock-picker.component.html +81 -0
  48. package/src/lib/components/input/input-clock-picker/input-clock-picker.component.scss +228 -0
  49. package/src/lib/components/input/input-clock-picker/input-clock-picker.component.spec.ts +62 -0
  50. package/src/lib/components/input/input-clock-picker/input-clock-picker.component.ts +178 -0
  51. package/src/lib/components/input/input-consts.ts +132 -0
  52. package/src/lib/components/input/input-date/input-date-validators.ts +41 -0
  53. package/src/lib/components/input/input-date/input-date.component.html +41 -0
  54. package/src/lib/components/input/input-date/input-date.component.scss +95 -0
  55. package/src/lib/components/input/input-date/input-date.component.spec.ts +43 -0
  56. package/src/lib/components/input/input-date/input-date.component.ts +359 -0
  57. package/src/lib/components/input/input-date-time/input-date-time.component.html +70 -0
  58. package/src/lib/components/input/input-date-time/input-date-time.component.scss +133 -0
  59. package/src/lib/components/input/input-date-time/input-date-time.component.spec.ts +36 -0
  60. package/src/lib/components/input/input-date-time/input-date-time.component.ts +387 -0
  61. package/src/lib/components/input/input-file-upload/input-file-upload.component.html +89 -0
  62. package/src/lib/components/input/input-file-upload/input-file-upload.component.scss +171 -0
  63. package/src/lib/components/input/input-file-upload/input-file-upload.component.spec.ts +43 -0
  64. package/src/lib/components/input/input-file-upload/input-file-upload.component.ts +351 -0
  65. package/src/lib/components/input/input-interface.ts +8 -0
  66. package/src/lib/components/input/input-number/input-number-validators.ts +0 -0
  67. package/src/lib/components/input/input-number/input-number.component.html +51 -0
  68. package/src/lib/components/input/input-number/input-number.component.scss +140 -0
  69. package/src/lib/components/input/input-number/input-number.component.spec.ts +44 -0
  70. package/src/lib/components/input/input-number/input-number.component.ts +343 -0
  71. package/src/lib/components/input/input-radio-group/input-radio-group.component.html +44 -0
  72. package/src/lib/components/input/input-radio-group/input-radio-group.component.scss +139 -0
  73. package/src/lib/components/input/input-radio-group/input-radio-group.component.spec.ts +58 -0
  74. package/src/lib/components/input/input-radio-group/input-radio-group.component.ts +132 -0
  75. package/src/lib/components/input/input-slider/input-slider.component.html +111 -0
  76. package/src/lib/components/input/input-slider/input-slider.component.scss +203 -0
  77. package/src/lib/components/input/input-slider/input-slider.component.spec.ts +46 -0
  78. package/src/lib/components/input/input-slider/input-slider.component.ts +410 -0
  79. package/src/lib/components/input/input-text/input-text-validators.ts +67 -0
  80. package/src/lib/components/input/input-text/input-text.component.html +71 -0
  81. package/src/lib/components/input/input-text/input-text.component.scss +118 -0
  82. package/src/lib/components/input/input-text/input-text.component.spec.ts +55 -0
  83. package/src/lib/components/input/input-text/input-text.component.ts +215 -0
  84. package/src/lib/components/input/input-time/input-time-validators.ts +42 -0
  85. package/src/lib/components/input/input-time/input-time.component.html +92 -0
  86. package/src/lib/components/input/input-time/input-time.component.scss +191 -0
  87. package/src/lib/components/input/input-time/input-time.component.spec.ts +39 -0
  88. package/src/lib/components/input/input-time/input-time.component.ts +691 -0
  89. package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.html +36 -0
  90. package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.scss +121 -0
  91. package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.spec.ts +54 -0
  92. package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.ts +117 -0
  93. package/src/lib/components/input/input-type.ts +18 -0
  94. package/src/lib/components/input/input-validation/input-validation.component.html +19 -0
  95. package/src/lib/components/input/input-validation/input-validation.component.scss +39 -0
  96. package/src/lib/components/input/input-validation/input-validation.component.spec.ts +45 -0
  97. package/src/lib/components/input/input-validation/input-validation.component.ts +13 -0
  98. package/src/lib/components/input/input.pipe.ts +14 -0
  99. package/src/lib/components/layout/container/container.component.html +1 -0
  100. package/src/lib/components/layout/container/container.component.scss +33 -0
  101. package/src/lib/components/layout/container/container.component.ts +32 -0
  102. package/src/lib/components/layout/container/container.type.ts +1 -0
  103. package/src/lib/components/layout/divider/divider.component.html +1 -0
  104. package/src/lib/components/layout/divider/divider.component.scss +60 -0
  105. package/src/lib/components/layout/divider/divider.component.ts +38 -0
  106. package/src/lib/components/layout/divider/divider.type.ts +2 -0
  107. package/src/lib/components/layout/section/section.component.html +21 -0
  108. package/src/lib/components/layout/section/section.component.scss +43 -0
  109. package/src/lib/components/layout/section/section.component.ts +33 -0
  110. package/src/lib/components/layout/section/section.type.ts +2 -0
  111. package/src/lib/components/layout/separator/separator.component.html +9 -0
  112. package/src/lib/components/layout/separator/separator.component.scss +52 -0
  113. package/src/lib/components/layout/separator/separator.component.ts +25 -0
  114. package/src/lib/components/layout/separator/separator.type.ts +1 -0
  115. package/src/lib/components/loader/content-blur/content-blur.component.html +13 -0
  116. package/src/lib/components/loader/content-blur/content-blur.component.scss +43 -0
  117. package/src/lib/components/loader/content-blur/content-blur.component.spec.ts +42 -0
  118. package/src/lib/components/loader/content-blur/content-blur.component.ts +34 -0
  119. package/src/lib/components/loader/loader.type.ts +2 -0
  120. package/src/lib/components/loader/progress-bar/progress-bar.component.html +26 -0
  121. package/src/lib/components/loader/progress-bar/progress-bar.component.scss +151 -0
  122. package/src/lib/components/loader/progress-bar/progress-bar.component.spec.ts +47 -0
  123. package/src/lib/components/loader/progress-bar/progress-bar.component.ts +28 -0
  124. package/src/lib/components/loader/progress-bar/progress-bar.type.ts +8 -0
  125. package/src/lib/components/loader/pulse-loader/pulse-loader.component.html +12 -0
  126. package/src/lib/components/loader/pulse-loader/pulse-loader.component.scss +202 -0
  127. package/src/lib/components/loader/pulse-loader/pulse-loader.component.spec.ts +55 -0
  128. package/src/lib/components/loader/pulse-loader/pulse-loader.component.ts +73 -0
  129. package/src/lib/components/loader/pulse-loader/pulse-loader.type.ts +6 -0
  130. package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.html +13 -0
  131. package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.scss +113 -0
  132. package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.spec.ts +37 -0
  133. package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.ts +51 -0
  134. package/src/lib/components/loader/skeleton-loader/skeleton-loader.type.ts +6 -0
  135. package/src/lib/components/loader/spinner/spinner.component.html +20 -0
  136. package/src/lib/components/loader/spinner/spinner.component.scss +137 -0
  137. package/src/lib/components/loader/spinner/spinner.component.spec.ts +43 -0
  138. package/src/lib/components/loader/spinner/spinner.component.ts +32 -0
  139. package/src/lib/components/loader/spinner/spinner.type.ts +6 -0
  140. package/src/lib/components/modal/modal.component.html +47 -0
  141. package/src/lib/components/modal/modal.component.scss +139 -0
  142. package/src/lib/components/modal/modal.component.spec.ts +60 -0
  143. package/src/lib/components/modal/modal.component.ts +83 -0
  144. package/src/lib/components/modal/modal.type.ts +9 -0
  145. package/src/lib/components/morph/blob-moph/blob-moprh.component.spec.ts +79 -0
  146. package/src/lib/components/morph/blob-moph/blob-moprh.component.ts +96 -0
  147. package/src/lib/components/morph/blob-moph/blob-morph.component.html +34 -0
  148. package/src/lib/components/morph/blob-moph/blob-morph.component.scss +7 -0
  149. package/src/lib/components/morph/morph.abstract.ts +13 -0
  150. package/src/lib/components/pagination/pagination.interface.ts +4 -0
  151. package/src/lib/components/pagination/small-pagination/small-pagination.component.html +61 -0
  152. package/src/lib/components/pagination/small-pagination/small-pagination.component.scss +187 -0
  153. package/src/lib/components/pagination/small-pagination/small-pagination.component.spec.ts +88 -0
  154. package/src/lib/components/pagination/small-pagination/small-pagination.component.ts +177 -0
  155. package/src/lib/components/selection-lists/multi-select/multi-select.component.html +170 -0
  156. package/src/lib/components/selection-lists/multi-select/multi-select.component.scss +312 -0
  157. package/src/lib/components/selection-lists/multi-select/multi-select.component.spec.ts +61 -0
  158. package/src/lib/components/selection-lists/multi-select/multi-select.component.ts +372 -0
  159. package/src/lib/components/selection-lists/selection-list/selection-list.component.html +125 -0
  160. package/src/lib/components/selection-lists/selection-list/selection-list.component.scss +267 -0
  161. package/src/lib/components/selection-lists/selection-list/selection-list.component.spec.ts +66 -0
  162. package/src/lib/components/selection-lists/selection-list/selection-list.component.ts +315 -0
  163. package/src/lib/components/selection-lists/selection-lists-base.ts +35 -0
  164. package/src/lib/components/selection-lists/selection-lists-const.ts +17 -0
  165. package/src/lib/components/selection-lists/selection-lists-interface.ts +7 -0
  166. package/src/lib/components/selection-lists/selection-lists.type.ts +1 -0
  167. package/src/lib/components/side-nav/side-nav.component.html +101 -0
  168. package/src/lib/components/side-nav/side-nav.component.scss +295 -0
  169. package/src/lib/components/side-nav/side-nav.component.spec.ts +0 -0
  170. package/src/lib/components/side-nav/side-nav.component.ts +18 -0
  171. package/src/lib/components/side-nav/side-nav.type.ts +28 -0
  172. package/src/lib/components/snackbar/snackbar.component.html +33 -0
  173. package/src/lib/components/snackbar/snackbar.component.scss +195 -0
  174. package/src/lib/components/snackbar/snackbar.component.ts +112 -0
  175. package/src/lib/components/snackbar/snackbar.type.ts +27 -0
  176. package/src/lib/components/status/chip/chip.component.html +51 -0
  177. package/src/lib/components/status/chip/chip.component.scss +149 -0
  178. package/src/lib/components/status/chip/chip.component.spec.ts +62 -0
  179. package/src/lib/components/status/chip/chip.component.ts +83 -0
  180. package/src/lib/components/status/chip/chip.type.ts +42 -0
  181. package/src/lib/components/status/directives/badge/badge.directive.spec.ts +60 -0
  182. package/src/lib/components/status/directives/badge/badge.directive.ts +190 -0
  183. package/src/lib/components/status/directives/badge/badge.interface.ts +19 -0
  184. package/src/lib/components/status/pill/pill.component.html +40 -0
  185. package/src/lib/components/status/pill/pill.component.scss +113 -0
  186. package/src/lib/components/status/pill/pill.component.spec.ts +47 -0
  187. package/src/lib/components/status/pill/pill.component.ts +83 -0
  188. package/src/lib/components/status/pill/pill.type.ts +42 -0
  189. package/src/lib/components/status/status.interface.ts +57 -0
  190. package/src/lib/components/status/status.type.ts +62 -0
  191. package/src/lib/components/status/tag/tag.component.html +39 -0
  192. package/src/lib/components/status/tag/tag.component.scss +140 -0
  193. package/src/lib/components/status/tag/tag.component.spec.ts +47 -0
  194. package/src/lib/components/status/tag/tag.component.ts +83 -0
  195. package/src/lib/components/status/tag/tag.type.ts +42 -0
  196. package/src/lib/components/stepper/stepper.component.html +83 -0
  197. package/src/lib/components/stepper/stepper.component.scss +196 -0
  198. package/src/lib/components/stepper/stepper.component.ts +482 -0
  199. package/src/lib/components/stepper/stepper.type.ts +60 -0
  200. package/src/lib/components/table/table.component.html +438 -0
  201. package/src/lib/components/table/table.component.scss +259 -0
  202. package/src/lib/components/table/table.component.spec.ts +117 -0
  203. package/src/lib/components/table/table.component.ts +215 -0
  204. package/src/lib/components/table/table.enum.ts +4 -0
  205. package/src/lib/components/table/table.function.ts +47 -0
  206. package/src/lib/components/table/table.interface.ts +143 -0
  207. package/src/lib/components/table/table.pipe.ts +62 -0
  208. package/src/lib/components/table/table.type.ts +15 -0
  209. package/src/lib/components/tabs/tabs.component.html +88 -0
  210. package/src/lib/components/tabs/tabs.component.scss +305 -0
  211. package/src/lib/components/tabs/tabs.component.spec.ts +94 -0
  212. package/src/lib/components/tabs/tabs.component.ts +282 -0
  213. package/src/lib/components/tabs/tabs.type.ts +81 -0
  214. package/src/lib/components/title-bar/title-bar.component.html +21 -0
  215. package/src/lib/components/title-bar/title-bar.component.scss +139 -0
  216. package/src/lib/components/title-bar/title-bar.component.spec.ts +44 -0
  217. package/src/lib/components/title-bar/title-bar.component.ts +13 -0
  218. package/src/lib/components/toast/toast.component.html +36 -0
  219. package/src/lib/components/toast/toast.component.scss +241 -0
  220. package/src/lib/components/toast/toast.component.ts +165 -0
  221. package/src/lib/components/toast/toast.type.ts +37 -0
  222. package/src/lib/components/toast-stack/toast-stack.component.html +30 -0
  223. package/src/lib/components/toast-stack/toast-stack.component.scss +35 -0
  224. package/src/lib/components/toast-stack/toast-stack.component.ts +51 -0
  225. package/src/lib/consts/country-prefix.ts +244 -0
  226. package/src/lib/directives/tooltip/popover.directive.ts +274 -0
  227. package/src/lib/directives/tooltip/tooltip.directive.spec.ts +86 -0
  228. package/src/lib/directives/tooltip/tooltip.directive.ts +234 -0
  229. package/src/lib/directives/tooltip/tooltip.interface.ts +29 -0
  230. package/src/lib/directives/tooltip/tooltip.type.ts +9 -0
  231. package/src/lib/interfaces/common.interfaces.ts +4 -0
  232. package/src/lib/pipes/chunk.pipe.ts +16 -0
  233. package/src/lib/pipes/safe-html.pipe.ts +14 -0
  234. package/src/lib/pipes/sanitize-html.pipe.ts +23 -0
  235. package/src/lib/types/base.types.ts +23 -0
  236. package/src/lib/types/common.types.ts +98 -0
  237. package/src/lib/types/form.types.ts +5 -0
  238. package/src/lib/utils/common.utils.ts +53 -0
  239. package/src/lib/utils/date.utils.ts +474 -0
  240. package/src/lib/utils/number.utils.ts +16 -0
  241. package/src/lib/utils/uuid.utils.ts +39 -0
  242. package/src/public-api.ts +114 -0
  243. package/tsconfig.lib.json +17 -0
  244. package/tsconfig.lib.prod.json +10 -0
  245. package/tsconfig.spec.json +9 -0
  246. package/fesm2022/tacdaed-fragments.mjs +0 -8928
  247. package/fesm2022/tacdaed-fragments.mjs.map +0 -1
  248. package/index.d.ts +0 -3929
@@ -0,0 +1,372 @@
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
+ }
@@ -0,0 +1,125 @@
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>