@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,359 @@
1
+ import { AsyncPipe } from '@angular/common';
2
+ import { Component, HostListener, Input } from '@angular/core';
3
+ import { Validators } from '@angular/forms';
4
+ import { BehaviorSubject } from 'rxjs';
5
+ import { DateFormat } from '../../../types/common.types';
6
+ import { buildDateFormatRegex, convertStringToDate, formatDateToString, isValidDate } from '../../../utils/date.utils';
7
+ import { InputBase } from '../input-base';
8
+ import { InputCalendarComponent } from '../input-calendar/input-calendar.component';
9
+ import { DEFAULT_INPUT_DATE_ERROR_MESSAGES, DEFAULT_INPUT_DATE_WARNINGS_MESSAGES } from '../input-consts';
10
+ import { InputDateType } from '../input-type';
11
+ import { InputValidationComponent } from '../input-validation/input-validation.component';
12
+ import { InputRequiredLabelPipe } from '../input.pipe';
13
+ import { maxDate, minDate } from './input-date-validators';
14
+
15
+ @Component({
16
+ selector: 'frg-input-date',
17
+ imports: [InputValidationComponent, InputRequiredLabelPipe, InputCalendarComponent, AsyncPipe],
18
+ templateUrl: './input-date.component.html',
19
+ styleUrl: './input-date.component.scss',
20
+ })
21
+ export class InputDateComponent extends InputBase<Date | null> {
22
+
23
+ @HostListener('document:click', ['$event'])
24
+ onDocumentClick(event: MouseEvent) {
25
+ const target = event.target as HTMLElement;
26
+
27
+ if (!target.closest('.frg-input__wrapper')) {
28
+ this.showCalendar$.next(false);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @inheritdoc
34
+ */
35
+ @Input() public override label: string = '';
36
+ /**
37
+ * @inheritdoc
38
+ */
39
+ @Input() public override placeholder: string = '';
40
+ /**
41
+ * @inheritdoc
42
+ */
43
+ @Input() public override required: boolean = false;
44
+ /**
45
+ * @inheritdoc
46
+ */
47
+ @Input() public override showValidation: boolean = true;
48
+ /**
49
+ * @inheritdoc
50
+ */
51
+ @Input() public override errorMessages: Record<string, string> = {};
52
+ /**
53
+ * The type of the input element.
54
+ * Can be 'text', 'password', 'email', 'tel', etc.
55
+ * Defaults to 'text'.
56
+ *
57
+ * @see InputTextType
58
+ */
59
+ @Input() public type: InputDateType = 'date';
60
+ /**
61
+ * Minimum year selectable in the calendar
62
+ */
63
+ @Input() public minDate: Date = new Date(1900, 0, 1);
64
+ /**
65
+ * Maximum year selectable in the calendar
66
+ */
67
+ @Input() public maxDate: Date = new Date(2099, 11, 31);
68
+ /**
69
+ * The format of date
70
+ */
71
+ @Input() public format: DateFormat = 'dd/MM/yyyy';
72
+ /**
73
+ * Enables strict mode for email validation.
74
+ * When set to true, the email validator will use a more stringent pattern.
75
+ * Defaults to false.
76
+ */
77
+ @Input() public validatorStrictMode: boolean = false;
78
+
79
+ /**
80
+ * Used for show calendar
81
+ */
82
+ public showCalendar$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
83
+
84
+ /**
85
+ * Determines the actual input type to be used in the template.
86
+ * If the type is 'password', it toggles between 'text' and 'password'
87
+ * based on the showPassword property.
88
+ *
89
+ * @returns The input type as a string.
90
+ */
91
+ public get inputType(): string {
92
+ if (this.type === 'date') {
93
+ return 'text';
94
+ }
95
+ return this.type;
96
+ }
97
+
98
+ /** Internal store for warnings */
99
+ private warnings: Record<string, boolean> = {};
100
+
101
+ /**
102
+ * @inheritdoc
103
+ */
104
+ public override ngOnInit(): void {
105
+ super.ngOnInit();
106
+ this.initPlaceholder();
107
+ this.initValidators();
108
+ }
109
+
110
+ /**
111
+ * Handles the blur event on the input element.
112
+ * Validates and formats the input value.
113
+ * Marks the control as touched and updates the model value.
114
+ * @param event Focus event
115
+ */
116
+ public override onBlur(event: FocusEvent): void {
117
+ const input = event.target as HTMLInputElement;
118
+ const value = input.value.trim();
119
+
120
+ this.validate(value);
121
+
122
+ if (isValidDate(value, this.format)) {
123
+ let date = convertStringToDate(value, this.format);
124
+ if (date) {
125
+ date = this.clampDate(date);
126
+ }
127
+ this.value = date ?? null;
128
+ input.value = this.formatDate(this.value);
129
+ } else {
130
+ input.value = '';
131
+ this.value = null;
132
+ }
133
+
134
+ this.onTouched();
135
+ this.onChange(this.value);
136
+ }
137
+
138
+ /**
139
+ * Handles the input event on the input element.
140
+ * Validates the input value.
141
+ * @param event Input event
142
+ */
143
+ public override onInput(event: Event): void {
144
+ const input = event.target as HTMLInputElement;
145
+ const value = input.value.trim();
146
+
147
+ this.validate(value);
148
+ }
149
+
150
+ /**
151
+ * Handles the blur event on the input element.
152
+ * Marks the control as touched.
153
+ */
154
+ public override onFocus(_event: FocusEvent): void {
155
+ this.showCalendar$.next(true);
156
+ }
157
+
158
+ /**
159
+ * Format value for input display
160
+ * @param value Date value
161
+ * @returns Formatted date string
162
+ */
163
+ protected formatDate(value: Date | null): string {
164
+ if(value){
165
+ return formatDateToString(value, this.format);
166
+ }
167
+
168
+ return '';
169
+ }
170
+
171
+ protected selectDate(date: Date): void {
172
+ this.value = date;
173
+
174
+ this.onChange(this.value);
175
+ this.onTouched();
176
+
177
+ this.showCalendar$.next(false);
178
+ }
179
+
180
+ protected toggleCalendar(){
181
+ this.showCalendar$.next(!this.showCalendar$.value);
182
+ }
183
+
184
+ /**
185
+ * @inheritdoc
186
+ */
187
+ protected updateView(_value: Date | null): void {
188
+ // Handled by Angular binding
189
+ }
190
+
191
+ /**
192
+ * @inheritdoc
193
+ */
194
+ protected updateDisabledState(_isDisabled: boolean): void {
195
+ // Handled by Angular binding
196
+ }
197
+
198
+ /**
199
+ * @inheritdoc
200
+ */
201
+ protected override get errorList(): string[] {
202
+ if (!this.control?.errors) return [];
203
+
204
+ const errors = this.control.errors;
205
+ return Object.keys(errors)
206
+ .filter(key => !key.startsWith('warning_'))
207
+ .map(key => {
208
+ if (this.errorMessages[key]) {
209
+ return this.errorMessages[key];
210
+ }
211
+ let template = this.errorMessages[key] || DEFAULT_INPUT_DATE_ERROR_MESSAGES[key] || 'Invalid field.';
212
+
213
+ switch (key) {
214
+ case 'min':
215
+ template = template.replace('{{date}}', formatDateToString(this.minDate, this.format));
216
+ break;
217
+ case 'max':
218
+ template = template.replace('{{date}}', formatDateToString(this.maxDate, this.format));
219
+ break;
220
+ }
221
+
222
+ return template;
223
+ });
224
+ }
225
+
226
+ /**
227
+ * Returns dynamic warning messages, replacing {{limit}} with actual values.
228
+ */
229
+ protected override get warningList(): string[] {
230
+ return Object.keys(this.warnings).map(key => {
231
+ const template = DEFAULT_INPUT_DATE_WARNINGS_MESSAGES[key] || 'Check this value.';
232
+
233
+ let replacement: string | undefined;
234
+
235
+ switch (key) {
236
+ case 'format':
237
+ replacement = this.format;
238
+ break;
239
+ case 'min':
240
+ replacement = formatDateToString(this.minDate, this.format);
241
+ break;
242
+ case 'max':
243
+ replacement = formatDateToString(this.maxDate, this.format);
244
+ break;
245
+ }
246
+
247
+ if (replacement != null) {
248
+ const placeholder = key === 'format' ? '{{format}}' : '{{limit}}';
249
+ return template.replace(placeholder, replacement.toString());
250
+ }
251
+
252
+ return template;
253
+ });
254
+ }
255
+
256
+ /**
257
+ * Returns whether any warnings are active.
258
+ */
259
+ protected get hasWarning(): boolean {
260
+ return this.warningList.length > 0;
261
+ }
262
+
263
+ /**
264
+ * Adds a warning flag
265
+ * @param key Warning key
266
+ */
267
+ private addWarning(key: string): void {
268
+ this.warnings[key] = true;
269
+ }
270
+
271
+ /**
272
+ * Clamp a date within min/max boundaries
273
+ * @param date Date to clamp
274
+ * @returns Clamped date and sets warnings if needed
275
+ */
276
+ private clampDate(date: Date): Date {
277
+ let clamped = date;
278
+
279
+ if (this.minDate && date < this.minDate) {
280
+ this.addWarning('min');
281
+ clamped = this.minDate;
282
+ }
283
+
284
+ if (this.maxDate && date > this.maxDate) {
285
+ this.addWarning('max');
286
+ clamped = this.maxDate;
287
+ }
288
+
289
+ return clamped;
290
+ }
291
+
292
+ /**
293
+ * Initialize the placeholder based on the date format
294
+ */
295
+ private initPlaceholder() {
296
+ this.placeholder = this.format;
297
+ }
298
+
299
+ /**
300
+ * Initialize validators based on inputs
301
+ */
302
+ private initValidators(): void {
303
+ if (this.control) {
304
+ const validators = [];
305
+
306
+ if (this.required) {
307
+ validators.push(Validators.required);
308
+ }
309
+
310
+ if (this.minDate) {
311
+ validators.push(minDate(this.minDate));
312
+ }
313
+
314
+ if (this.maxDate) {
315
+ validators.push(maxDate(this.maxDate));
316
+ }
317
+
318
+ this.control.setValidators(validators);
319
+ this.control.updateValueAndValidity();
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Validate the input value against the specified format
325
+ * @param value Input value
326
+ */
327
+ private validate(value: string): void {
328
+ this.removeWarning('format');
329
+ this.removeWarning('min');
330
+ this.removeWarning('max');
331
+
332
+ if (!value) return;
333
+
334
+ if (this.format) {
335
+ const regex = buildDateFormatRegex(this.format);
336
+ if (!regex.test(value)) {
337
+ this.addWarning('format');
338
+ return;
339
+ }
340
+ }
341
+
342
+ const date = convertStringToDate(value, this.format);
343
+ if (!date) return;
344
+
345
+ if (this.minDate && date < this.minDate) {
346
+ this.addWarning('min');
347
+ } else if (this.maxDate && date > this.maxDate) {
348
+ this.addWarning('max');
349
+ }
350
+ }
351
+
352
+ /**
353
+ * Remove a warning flag
354
+ * @param key Warning key
355
+ */
356
+ private removeWarning(key: string): void {
357
+ delete this.warnings[key];
358
+ }
359
+ }
@@ -0,0 +1,70 @@
1
+ <div class="frg-input__wrapper"
2
+ [class.input-error]="hasError"
3
+ [class.input-warning]="hasWarning"
4
+ >
5
+ @if(label){
6
+ <label [for]="id">{{ label | inputRequiredLabel: required }}</label>
7
+ }
8
+ <div class="frg-input__field">
9
+ <input
10
+ [id]="id"
11
+ type="text"
12
+ [placeholder]="placeholder"
13
+ [required]="required"
14
+ [disabled]="disabled"
15
+ [value]="formatDate(value)"
16
+ (blur)="onBlur($event)"
17
+ (focus)="onFocus($event)"
18
+ (input)="onInput($event)"
19
+ />
20
+ <div class="frg-input__handle-buttons">
21
+ @if(value){
22
+ <button
23
+ type="button"
24
+ class="frg-input__clear-button"
25
+ aria-label="Clear input"
26
+ (click)="clearValue()"
27
+ >
28
+ &times;
29
+ </button>
30
+
31
+ }
32
+ <button class="fa-regular fa-calendar-days frg-input__calendar-button"
33
+ aria-label="Open calendar"
34
+ (click)="toggleDateTimePicker()"
35
+ ></button>
36
+ </div>
37
+ </div>
38
+ @if(showDateTimePicker$ | async){
39
+ <div class="frg-input__date-time-picker">
40
+ <div class="frg-input__date-time-panel">
41
+ <frg-input-calendar
42
+ [minDate]="minDateTime"
43
+ [maxDate]="maxDateTime"
44
+ [selectedValue]="value"
45
+ (selectDate)="selectDate($event)"
46
+ >
47
+ </frg-input-calendar>
48
+
49
+ <frg-input-clock-picker
50
+ [timeFormat]="timeFormat"
51
+ [selectedHour]="value ? value.getHours().toString() : null"
52
+ [selectedMinute]="value ? value.getMinutes().toString() : null"
53
+ [selectedMeridiem]="currentMeridiem"
54
+ (selectHour)="selectHour($event)"
55
+ (selectMinute)="selectMinute($event)"
56
+ (selectMeridiem)="selectMeridiem($event)">
57
+ </frg-input-clock-picker>
58
+ </div>
59
+ </div>
60
+ }
61
+ </div>
62
+
63
+ @if (showValidation) {
64
+ <frg-input-validation
65
+ [errorList]="errorList"
66
+ [warningList]="warningList"
67
+ [isFormInvalid]="hasError"
68
+ >
69
+ </frg-input-validation>
70
+ }
@@ -0,0 +1,133 @@
1
+ @use "sass:color";
2
+ @use './../../../../../assets/styles/scss/variables' as *;
3
+
4
+ :host {
5
+ display: block;
6
+
7
+ label {
8
+ display: flex;
9
+ font-size: $font-size-xs;
10
+ color: $input-text-color;
11
+ padding: $input-padding;
12
+ }
13
+
14
+ .frg-input {
15
+ font-family: $input-font-family;
16
+ &__wrapper {
17
+ display: inline-block;
18
+ position: relative;
19
+ width: 100%;
20
+
21
+ &.input-error label {
22
+ color: $color-danger;
23
+ }
24
+
25
+ &.input-error .frg-input__field::after {
26
+ width: 100%;
27
+ right: 0;
28
+ }
29
+ }
30
+
31
+ &__field {
32
+ display: inline-flex;
33
+ align-items: center;
34
+ justify-content: space-between;
35
+ padding: $input-padding;
36
+ border-bottom: 2px solid $input-border-color;
37
+ font-family: $input-font-family;
38
+ background: transparent;
39
+ position: relative;
40
+ width: 100%;
41
+
42
+ input {
43
+ border: none;
44
+ background: transparent;
45
+
46
+ &:focus {
47
+ outline: none;
48
+ }
49
+ }
50
+
51
+ span {
52
+ margin-left: 0.5rem;
53
+ cursor: pointer;
54
+ color: $input-text-color;
55
+ }
56
+
57
+ &::before {
58
+ content: "";
59
+ position: absolute;
60
+ bottom: -2px;
61
+ left: -50%;
62
+ width: 0;
63
+ height: 0.125rem;
64
+ background: $input-focus-border-color;
65
+ transition: width 0.3s ease, left 0.3s ease;
66
+ }
67
+
68
+ &:has(input:focus)::before {
69
+ width: 100%;
70
+ left: 0;
71
+ }
72
+
73
+ &::after {
74
+ content: "";
75
+ position: absolute;
76
+ bottom: -2px;
77
+ right: -50%;
78
+ width: 0;
79
+ height: 0.125rem;
80
+ background: $color-danger;
81
+ transition: width 0.3s ease, right 0.3s ease;
82
+ }
83
+ }
84
+
85
+ &__clear-button {
86
+ background: transparent;
87
+ border: none;
88
+ font-size: $font-size-2xl;
89
+ color: $color-dark-neutral;
90
+ line-height: 0;
91
+ font-weight: lighter;
92
+ }
93
+
94
+ &__calendar-button {
95
+ border: none;
96
+ background: transparent;
97
+ color: $color-dark-neutral;
98
+
99
+ &:focus,
100
+ &:focus-visible,
101
+ &:focus-within {
102
+ border: none;
103
+ outline: none;
104
+ }
105
+ }
106
+
107
+ &__date-time-picker {
108
+ position: absolute;
109
+ top: calc(100% + 0.5rem);
110
+ left: 0;
111
+ z-index: 5;
112
+ }
113
+
114
+ &__date-time-panel {
115
+ display: flex;
116
+ align-items: center;
117
+ gap: 0.75rem;
118
+ padding: 0.5rem;
119
+ border-radius: 0.5rem;
120
+ background: $color-light;
121
+ box-shadow: $box-shadow-md;
122
+ flex-wrap: nowrap;
123
+ justify-content: center;
124
+ }
125
+
126
+ &__date-time-panel frg-input-calendar,
127
+ &__date-time-panel frg-input-clock-picker {
128
+ display: block;
129
+ flex: 0 0 auto;
130
+ margin: 0;
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,36 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { By } from '@angular/platform-browser';
3
+ import { InputDateTimeComponent } from './input-date-time.component';
4
+
5
+ describe('InputDateTimeComponent', () => {
6
+ let fixture: ComponentFixture<InputDateTimeComponent>;
7
+ let component: InputDateTimeComponent;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [InputDateTimeComponent]
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(InputDateTimeComponent);
15
+ component = fixture.componentInstance;
16
+ });
17
+
18
+ it('toggles the date time picker on button click', () => {
19
+ fixture.detectChanges();
20
+
21
+ const button = fixture.debugElement.query(By.css('.frg-input__calendar-button'));
22
+ button.nativeElement.click();
23
+
24
+ expect(component.showDateTimePicker$.value).toBeTrue();
25
+ });
26
+
27
+ it('clears value and closes pickers', () => {
28
+ component.value = new Date(2024, 0, 1, 9, 30);
29
+ component.showDateTimePicker$.next(true);
30
+
31
+ component.clearValue();
32
+
33
+ expect(component.value).toBeNull();
34
+ expect(component.showDateTimePicker$.value).toBeFalse();
35
+ });
36
+ });