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

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 +2 -18
  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,55 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { By } from '@angular/platform-browser';
3
+ import { InputTextComponent } from './input-text.component';
4
+
5
+ describe('InputTextComponent', () => {
6
+ let fixture: ComponentFixture<InputTextComponent>;
7
+ let component: InputTextComponent;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [InputTextComponent]
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(InputTextComponent);
15
+ component = fixture.componentInstance;
16
+ });
17
+
18
+ it('renders label when provided', () => {
19
+ component.label = 'Username';
20
+
21
+ fixture.detectChanges();
22
+
23
+ const label = fixture.debugElement.query(By.css('label'));
24
+ expect(label.nativeElement.textContent).toContain('Username');
25
+ });
26
+
27
+ it('toggles password visibility', () => {
28
+ component.type = 'password';
29
+
30
+ fixture.detectChanges();
31
+
32
+ const input = fixture.debugElement.query(By.css('input')).nativeElement as HTMLInputElement;
33
+ expect(input.type).toBe('password');
34
+
35
+ const toggleBtn = fixture.debugElement.query(By.css('.frg-input__toggle-password'));
36
+ toggleBtn.nativeElement.click();
37
+ fixture.detectChanges();
38
+
39
+ expect(input.type).toBe('text');
40
+ });
41
+
42
+ it('updates value on input', () => {
43
+ const onChangeSpy = jasmine.createSpy('onChange');
44
+ component.registerOnChange(onChangeSpy);
45
+
46
+ fixture.detectChanges();
47
+
48
+ const input = fixture.debugElement.query(By.css('input')).nativeElement as HTMLInputElement;
49
+ input.value = 'hello';
50
+ input.dispatchEvent(new Event('input'));
51
+
52
+ expect(component.value).toBe('hello');
53
+ expect(onChangeSpy).toHaveBeenCalledWith('hello');
54
+ });
55
+ });
@@ -0,0 +1,215 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
2
+ import { Component, Input, OnInit } from '@angular/core';
3
+ import { Validators } from '@angular/forms';
4
+ import { InputBase } from '../input-base';
5
+ import { DEFAULT_INPUT_TEXT_ERROR_MESSAGES, DEFAULT_INPUT_TEXT_WARNINGS_MESSAGES } from '../input-consts';
6
+ import { InputTextType } from '../input-type';
7
+ import { InputValidationComponent } from '../input-validation/input-validation.component';
8
+ import { InputRequiredLabelPipe } from '../input.pipe';
9
+ import { phoneNumberValidator, strictEmailValidator, strictPhoneNumberValidator, strictUrlValidator, urlValidator } from './input-text-validators';
10
+
11
+ @Component({
12
+ selector: 'frg-input-text',
13
+ imports: [InputRequiredLabelPipe, NgTemplateOutlet, InputValidationComponent],
14
+ templateUrl: './input-text.component.html',
15
+ styleUrl: './input-text.component.scss',
16
+ })
17
+ export class InputTextComponent extends InputBase<string> implements OnInit {
18
+ /**
19
+ * @inheritdoc
20
+ */
21
+ @Input() public override label: string = '';
22
+ /**
23
+ * @inheritdoc
24
+ */
25
+ @Input() public override placeholder: string = '';
26
+ /**
27
+ * @inheritdoc
28
+ */
29
+ @Input() public override required: boolean = false;
30
+ /**
31
+ * @inheritdoc
32
+ */
33
+ @Input() public override showValidation: boolean = true;
34
+ /**
35
+ * @inheritdoc
36
+ */
37
+ @Input() public override errorMessages: Record<string, string> = {};
38
+ /**
39
+ * The type of the input element.
40
+ * Can be 'text', 'password', 'email', 'tel', etc.
41
+ * Defaults to 'text'.
42
+ *
43
+ * @see InputTextType
44
+ */
45
+ @Input() public type: InputTextType = 'text';
46
+ /**
47
+ * Enables strict mode for email validation.
48
+ * When set to true, the email validator will use a more stringent pattern.
49
+ * Defaults to false.
50
+ */
51
+ @Input() public validatorStrictMode: boolean = false;
52
+
53
+ protected override get errorList(): string[] {
54
+ if (!this.control?.errors) return [];
55
+ const errors = this.control.errors;
56
+ return Object.keys(errors).map(key => {
57
+ if (this.errorMessages[key]) {
58
+ return this.errorMessages[key];
59
+ }
60
+
61
+ if (key === 'minlength' && errors[key]?.requiredLength) {
62
+ return `Minimum length is ${errors[key].requiredLength} characters.`;
63
+ }
64
+
65
+ if (key === 'maxlength' && errors[key]?.requiredLength) {
66
+ return `Maximum length is ${errors[key].requiredLength} characters.`;
67
+ }
68
+
69
+ return DEFAULT_INPUT_TEXT_ERROR_MESSAGES[key] || 'Invalid field.';
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Handles the blur event on the input element.
75
+ * Marks the control as touched.
76
+ */
77
+ public override onBlur(): void {
78
+ this.onTouched();
79
+ }
80
+
81
+ /**
82
+ * Handles the input event on the input element.
83
+ * Updates the value and notifies the form control.
84
+ */
85
+ public override onInput(event: Event): void {
86
+ const input = event.target as HTMLInputElement;
87
+ this.value = input.value;
88
+ this.onChange(this.value);
89
+ }
90
+
91
+ /**
92
+ * @inheritdoc
93
+ */
94
+ public override ngOnInit(): void {
95
+ super.ngOnInit();
96
+ if (this.type === 'email' && this.control) {
97
+ this.validateEmail();
98
+ }
99
+ if (this.type === 'tel' && this.control) {
100
+ this.validatePhoneNumber();
101
+ }
102
+ if (this.type === 'url' && this.control){
103
+ this.validateUrl();
104
+ }
105
+ }
106
+
107
+ /**
108
+ * @inheritdoc
109
+ */
110
+ protected updateView(_value: string | null): void {
111
+ // Handled by Angular binding
112
+ }
113
+
114
+ /**
115
+ * @inheritdoc
116
+ */
117
+ protected updateDisabledState(_isDisabled: boolean): void {
118
+ // Handled by Angular binding
119
+ }
120
+
121
+ /**
122
+ * Indicates whether the password is visible or hidden.
123
+ *
124
+ * Used only when the input type is 'password'.
125
+ */
126
+ protected showPassword: boolean = false;
127
+
128
+ /**
129
+ * Determines the actual input type to be used in the template.
130
+ * If the type is 'password', it toggles between 'text' and 'password'
131
+ * based on the showPassword property.
132
+ *
133
+ * @returns The input type as a string.
134
+ */
135
+ public get inputType(): string {
136
+ if (this.type === 'password') {
137
+ return this.showPassword ? 'text' : 'password';
138
+ }
139
+ return this.type;
140
+ }
141
+
142
+ /**
143
+ * Returns warning messages. Consumers may pass arbitrary warnings via `warningMessages`.
144
+ * Falls back to DEFAULT_INPUT_TEXT_WARNINGS_MESSAGES or a generic message.
145
+ */
146
+ protected override get warningList(): string[] {
147
+ return Object.keys(this.warningMessages).map(key => {
148
+ return (
149
+ this.warningMessages[key] ||
150
+ DEFAULT_INPUT_TEXT_WARNINGS_MESSAGES[key] ||
151
+ ''
152
+ );
153
+ });
154
+ }
155
+
156
+ /**
157
+ * Returns whether any warnings are active.
158
+ */
159
+ protected get hasWarning(): boolean {
160
+ return this.warningList.length > 0;
161
+ }
162
+
163
+ /**
164
+ * Toggles the visibility of the password input field.
165
+ * This method switches the input type between 'text' and 'password'.
166
+ *
167
+ * Used only when the input type is 'password'.
168
+ */
169
+ protected toggleShowPassword(): void {
170
+ this.showPassword = !this.showPassword;
171
+ }
172
+
173
+ /**
174
+ * Adds email validator to the control if the type is 'email'.
175
+ * This ensures that the input value is a valid email address.
176
+ */
177
+ private validateEmail(): void {
178
+ const existingValidators = this.control?.validator
179
+ ? [this.control.validator]
180
+ : [];
181
+
182
+ this.control?.setValidators([
183
+ ...existingValidators,
184
+ this.validatorStrictMode ? strictEmailValidator() : Validators.email
185
+ ]);
186
+
187
+ this.control?.updateValueAndValidity();
188
+ }
189
+
190
+ private validatePhoneNumber(): void {
191
+ const existingValidators = this.control?.validator
192
+ ? [this.control.validator]
193
+ : [];
194
+
195
+ this.control?.setValidators([
196
+ ...existingValidators,
197
+ this.validatorStrictMode ? strictPhoneNumberValidator() : phoneNumberValidator()
198
+ ]);
199
+
200
+ this.control?.updateValueAndValidity();
201
+ }
202
+
203
+ private validateUrl(): void {
204
+ const existingValidators = this.control?.validator
205
+ ? [this.control.validator]
206
+ : [];
207
+
208
+ this.control?.setValidators([
209
+ ...existingValidators,
210
+ this.validatorStrictMode ? strictUrlValidator() : urlValidator()
211
+ ]);
212
+
213
+ this.control?.updateValueAndValidity();
214
+ }
215
+ }
@@ -0,0 +1,42 @@
1
+ import { AbstractControl, ValidationErrors, ValidatorFn } from "@angular/forms";
2
+ import { parseTimeToMinutes } from "../../../utils/date.utils";
3
+
4
+ export function minTime(min: string): ValidatorFn {
5
+ return (control: AbstractControl): ValidationErrors | null => {
6
+ const value = control.value as string | null;
7
+ if (!value) return null;
8
+
9
+ const minMinutes = parseTimeToMinutes(min);
10
+ const valueMinutes = parseTimeToMinutes(value);
11
+
12
+ if (minMinutes === null || valueMinutes === null) {
13
+ return { invalidFormat: true };
14
+ }
15
+
16
+ if (valueMinutes < minMinutes) {
17
+ return { min: true };
18
+ }
19
+
20
+ return null;
21
+ };
22
+ }
23
+
24
+ export function maxTime(max: string): ValidatorFn {
25
+ return (control: AbstractControl): ValidationErrors | null => {
26
+ const value = control.value as string | null;
27
+ if (!value) return null;
28
+
29
+ const maxMinutes = parseTimeToMinutes(max);
30
+ const valueMinutes = parseTimeToMinutes(value);
31
+
32
+ if (maxMinutes === null || valueMinutes === null) {
33
+ return { invalidFormat: true };
34
+ }
35
+
36
+ if (valueMinutes > maxMinutes) {
37
+ return { max: true };
38
+ }
39
+
40
+ return null;
41
+ };
42
+ }
@@ -0,0 +1,92 @@
1
+ <div class="frg-input__wrapper"
2
+ [class.input-error]="hasError"
3
+ [class.input-warning]="hasWarning"
4
+ >
5
+ @if(label){
6
+ <label [for]="id + '-full'">{{ label | inputRequiredLabel: required }}</label>
7
+ }
8
+ <div class="frg-input__field">
9
+ @if(format.includes('HH') || format.includes('hh')) {
10
+ <ng-container *ngTemplateOutlet="timeControl; context:{partial:'hour', min:minHour, max:maxHour, placeholder: format.includes('HH') ? 'HH' : 'hh'}"></ng-container>
11
+ }
12
+
13
+ @if(format.includes('mm')) {
14
+ <span class="colon-seprator">:</span>
15
+ <ng-container *ngTemplateOutlet="timeControl; context:{partial:'minute', min:minMinute, max:maxMinute, placeholder:'mm'}"></ng-container>
16
+ }
17
+
18
+ @if(format.includes('ss')) {
19
+ <span class="colon-seprator">:</span>
20
+ <ng-container *ngTemplateOutlet="timeControl; context:{partial:'second', min:minSecond, max:maxSecond, placeholder:'ss'}"></ng-container>
21
+ }
22
+
23
+ @if(format.includes('a')) {
24
+ <div class="frg-input__time__container frg-input__time__meridiem">
25
+ <input
26
+ [id]="id + '-meridiem'"
27
+ [attr.data-partialTime]="'meridiem'"
28
+ type="checkbox"
29
+ tabindex="0"
30
+ role="switch"
31
+ [checked]="formatTime(value, 'meridiem') === 'PM'"
32
+ aria-checked="{{ formatTime(value, 'meridiem') === 'PM' }}"
33
+ placeholder="AM/PM"
34
+ [required]="required"
35
+ [disabled]="disabled"
36
+ (blur)="onBlur($event)"
37
+ (focus)="onFocus($event)"
38
+ (change)="onInput($event)"
39
+ (keydown.enter)="onKeydown($event)"
40
+ />
41
+ </div>
42
+ <span class="focus-line"></span>
43
+
44
+ }
45
+
46
+ <input type="text" [id]="id + '-full'" [value]="value" hidden />
47
+ </div>
48
+
49
+ @if(showValidation) {
50
+ <frg-input-validation
51
+ [errorList]="errorList"
52
+ [warningList]="warningList"
53
+ [isFormInvalid]="hasError"
54
+ ></frg-input-validation>
55
+ }
56
+ </div>
57
+
58
+ <ng-template #timeControl let-partial="partial" let-min="min" let-max="max" let-placeholder="placeholder">
59
+ <div class="frg-input__time__container" [ngClass]="'frg-input__time__' + partial">
60
+ <button
61
+ type="button"
62
+ class="frg-input__time__arrow frg-input__time__arrow--increment"
63
+ (click)="increase(partial)"
64
+ aria-label="Increase value"
65
+ >
66
+ <span class="fas fa-chevron-up"></span>
67
+ </button>
68
+ <input
69
+ [id]="id + '-' + partial"
70
+ [attr.data-partialTime]="partial"
71
+ type="number"
72
+ [placeholder]="placeholder"
73
+ [min]="min"
74
+ [max]="max"
75
+ [required]="required"
76
+ [disabled]="disabled"
77
+ [value]="formatTime(value, partial) !== placeholder ? formatTime(value, partial) : ''"
78
+ (blur)="onBlur($event)"
79
+ (focus)="onFocus($event)"
80
+ (input)="onInput($event)"
81
+ />
82
+ <span class="focus-line"></span>
83
+ <button
84
+ type="button"
85
+ class="frg-input__time__arrow frg-input__time__arrow--decrement"
86
+ (click)="decrease(partial)"
87
+ aria-label="Decrease value"
88
+ >
89
+ <span class="fas fa-chevron-down"></span>
90
+ </button>
91
+ </div>
92
+ </ng-template>
@@ -0,0 +1,191 @@
1
+ @use "sass:color";
2
+ @use './../../../../../assets/styles/scss/variables' as *;
3
+
4
+ :host {
5
+ display: block;
6
+
7
+ input::-webkit-outer-spin-button,
8
+ input::-webkit-inner-spin-button {
9
+ -webkit-appearance: none;
10
+ margin: 0;
11
+ }
12
+
13
+ .frg-input {
14
+ &__wrapper {
15
+ position: relative;
16
+ box-sizing: border-box;
17
+
18
+ label {
19
+ font-size: $font-size-xs;
20
+ color: $input-text-color;
21
+ display: block;
22
+ padding: $input-padding;
23
+ }
24
+
25
+ &.input-error label {
26
+ color: $color-danger;
27
+ }
28
+
29
+ &.input-warning label {
30
+ color: $color-warning;
31
+ }
32
+ }
33
+
34
+ &__field {
35
+ display: inline-flex;
36
+ justify-content: center;
37
+ align-items: center;
38
+
39
+ input[type="number"],
40
+ input[type="number"]:focus,
41
+ input[type="number"]:focus-visible {
42
+ border: none;
43
+ outline: none;
44
+ }
45
+
46
+ input[type="number"] {
47
+ background: transparent;
48
+ text-align: center;
49
+ padding: 0.5rem 0;
50
+ letter-spacing: .1rem;
51
+ font-size: $font-size-md;
52
+ font-weight: 600;
53
+ color: $color-dark-soft;
54
+ display: block;
55
+ }
56
+
57
+ .partial-label {
58
+ display: block;
59
+ font-size: $font-size-xs;
60
+ text-transform: capitalize;
61
+ width: 100%;
62
+ text-align: center;
63
+ color: $color-dark-soft;
64
+ }
65
+
66
+ .colon-seprator {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ font-size: $font-size-md;
71
+ font-weight: 600;
72
+ }
73
+ }
74
+
75
+ &__time {
76
+ &__container {
77
+ display: flex;
78
+ flex-direction: column;
79
+ align-items: center;
80
+
81
+ .focus-line {
82
+ display: block;
83
+ width: 50%;
84
+ margin: 0 auto;
85
+ height: 2px;
86
+ background-color: $color-primary;
87
+ transform: scaleX(0);
88
+ transform-origin: left center;
89
+ transition: transform 0.2s ease, background-color 0.2s ease;
90
+ }
91
+
92
+ &:focus-within .focus-line {
93
+ transform: scaleX(1);
94
+ }
95
+
96
+ .frg-input__wrapper.input-error & .focus-line {
97
+ background-color: $color-danger;
98
+ transform: scaleX(1);
99
+ }
100
+
101
+ .frg-input__wrapper.input-warning & .focus-line {
102
+ background-color: $color-warning;
103
+ transform: scaleX(1);
104
+ }
105
+ }
106
+
107
+ &__meridiem {
108
+ position: relative;
109
+ width: 3.5rem;
110
+ height: 1.5rem;
111
+
112
+ input[type="checkbox"] {
113
+ appearance: none;
114
+ -webkit-appearance: none;
115
+ width: 100%;
116
+ height: 100%;
117
+ border-radius: 0.25rem;
118
+ background-color: $color-light-soft;
119
+ cursor: pointer;
120
+ position: relative;
121
+ overflow: hidden;
122
+ transition: background-color 0.25s ease;
123
+
124
+ &:focus {
125
+ outline: none;
126
+ }
127
+
128
+ &:focus-visible {
129
+ outline-offset: 0.25rem;
130
+ outline: 2px solid $color-dark-neutral;
131
+ box-shadow: 0 0 0 2px rgba($color-primary, 0.2);
132
+
133
+ .frg-input__wrapper.input-error & {
134
+ outline-color: $color-danger;
135
+ box-shadow: 0 0 0 2px rgba($color-danger, 0.2);
136
+ }
137
+
138
+ .frg-input__wrapper.input-warning & {
139
+ outline-color: $color-warning;
140
+ box-shadow: 0 0 0 2px rgba($color-warning, 0.2);
141
+ }
142
+ }
143
+
144
+ &:before,
145
+ &:after {
146
+ content: "AM";
147
+ position: absolute;
148
+ top: 50%;
149
+ left: 50%;
150
+ transform: translate(-50%, -50%);
151
+ font-size: $font-size-md;
152
+ font-weight: 600;
153
+ color: $color-dark-neutral;
154
+ transition: transform 0.25s ease, opacity 0.25s ease;
155
+ }
156
+
157
+ &:after {
158
+ content: "PM";
159
+ opacity: 0;
160
+ transform: translate(-50%, 150%);
161
+ color: $color-light;
162
+ }
163
+
164
+ &:checked {
165
+ background-color: $color-primary;
166
+
167
+ &:before {
168
+ transform: translate(-50%, -150%);
169
+ opacity: 0;
170
+ }
171
+
172
+ &:after {
173
+ transform: translate(-50%, -50%);
174
+ opacity: 1;
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ &__arrow {
181
+ background: transparent;
182
+ color: $color-dark-neutral;
183
+ border: none;
184
+ display: block;
185
+ width: 100%;
186
+ padding: 0 0.5rem;
187
+ cursor: pointer;
188
+ }
189
+ }
190
+ }
191
+ }
@@ -0,0 +1,39 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { By } from '@angular/platform-browser';
3
+ import { InputTimeComponent } from './input-time.component';
4
+
5
+ describe('InputTimeComponent', () => {
6
+ let fixture: ComponentFixture<InputTimeComponent>;
7
+ let component: InputTimeComponent;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [InputTimeComponent]
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(InputTimeComponent);
15
+ component = fixture.componentInstance;
16
+ });
17
+
18
+ it('renders hour and minute inputs', () => {
19
+ fixture.detectChanges();
20
+
21
+ const hour = fixture.debugElement.query(By.css('input[id$="-hour"]'));
22
+ const minute = fixture.debugElement.query(By.css('input[id$="-minute"]'));
23
+
24
+ expect(hour).toBeTruthy();
25
+ expect(minute).toBeTruthy();
26
+ });
27
+
28
+ it('increments hour when clicking the first increment button', () => {
29
+ component.value = '10:15';
30
+
31
+ fixture.detectChanges();
32
+
33
+ const buttons = fixture.debugElement.queryAll(By.css('.frg-input__time__arrow--increment'));
34
+ buttons[0].nativeElement.click();
35
+ fixture.detectChanges();
36
+
37
+ expect(component.value).toBe('11:15');
38
+ });
39
+ });