@tacdaed/fragments 1.0.0-beta.0 → 1.0.0-beta.1

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 +1 -1
  2. package/ng-package.json +25 -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/fragments.mjs +0 -8928
  247. package/fesm2022/fragments.mjs.map +0 -1
  248. package/index.d.ts +0 -3929
@@ -0,0 +1,387 @@
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
+ }
@@ -0,0 +1,89 @@
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
+ }
@@ -0,0 +1,171 @@
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
+ }
@@ -0,0 +1,43 @@
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
+ });