@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,351 @@
1
+ import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
2
+ import { InputBase } from '../input-base';
3
+ import { InputRequiredLabelPipe } from '../input.pipe';
4
+ import { ButtonComponent } from '../../button/button.component';
5
+ import { InputValidationComponent } from '../input-validation/input-validation.component';
6
+ import { DEFAULT_INPUT_FILE_UPLOAD_ERROR_MESSAGES } from '../input-consts';
7
+
8
+ type InputFileUploadValue = File | File[] | null;
9
+
10
+ @Component({
11
+ selector: 'frg-input-file-upload',
12
+ imports: [InputRequiredLabelPipe, InputValidationComponent, ButtonComponent],
13
+ templateUrl: './input-file-upload.component.html',
14
+ styleUrl: './input-file-upload.component.scss',
15
+ })
16
+ export class InputFileUploadComponent extends InputBase<InputFileUploadValue> implements OnInit {
17
+ /**
18
+ * @inheritdoc
19
+ */
20
+ @Input() public override label: string = '';
21
+ /**
22
+ * @inheritdoc
23
+ */
24
+ @Input() public override required: boolean = false;
25
+ /**
26
+ * @inheritdoc
27
+ */
28
+ @Input() public override showValidation: boolean = true;
29
+ /**
30
+ * @inheritdoc
31
+ */
32
+ @Input() public override errorMessages: Record<string, string> = {};
33
+
34
+ /**
35
+ * Accepted file types (e.g. ".pdf,.png" or "image/*").
36
+ */
37
+ @Input() public accept: string = '';
38
+ /**
39
+ * Allow multiple file selection.
40
+ */
41
+ @Input() public multiple: boolean = false;
42
+ /**
43
+ * Maximum number of files allowed.
44
+ */
45
+ @Input() public maxFiles: number | null = null;
46
+ /**
47
+ * Maximum size per file in bytes.
48
+ */
49
+ @Input() public maxFileSize: number | null = null;
50
+ /**
51
+ * Maximum total size in bytes.
52
+ */
53
+ @Input() public maxTotalSize: number | null = null;
54
+ /**
55
+ * Button label for opening the file dialog.
56
+ */
57
+ @Input() public buttonLabel: string = 'Browse';
58
+ /**
59
+ * Placeholder text when no file is selected.
60
+ */
61
+ @Input() public noFileText: string = 'No file selected';
62
+ /**
63
+ * Show a clear button when files are selected.
64
+ */
65
+ @Input() public showClearButton: boolean = true;
66
+ /**
67
+ * Show individual file list.
68
+ */
69
+ @Input() public showFileList: boolean = true;
70
+ /**
71
+ * Show file size in the list.
72
+ */
73
+ @Input() public showFileSize: boolean = true;
74
+
75
+ @ViewChild('fileInput', { static: true }) private readonly fileInput!: ElementRef<HTMLInputElement>;
76
+
77
+ public files: File[] = [];
78
+ public isDragOver: boolean = false;
79
+
80
+ private readonly ownedErrors = new Set([
81
+ 'required',
82
+ 'maxFiles',
83
+ 'maxFileSize',
84
+ 'maxTotalSize',
85
+ 'accept',
86
+ ]);
87
+
88
+ public override ngOnInit(): void {
89
+ super.ngOnInit();
90
+ this.syncFromValue(this.value);
91
+ this.updateErrors();
92
+ }
93
+
94
+ protected override updateView(value: InputFileUploadValue | null): void {
95
+ this.syncFromValue(value);
96
+ if (!value) {
97
+ this.resetNativeInput();
98
+ }
99
+ this.updateErrors();
100
+ }
101
+
102
+ protected override updateDisabledState(_isDisabled: boolean): void {
103
+ // Handled by Angular binding
104
+ }
105
+
106
+ protected override get errorList(): string[] {
107
+ if (!this.control?.errors) return [];
108
+ return Object.keys(this.control.errors).map(key => {
109
+ if (this.errorMessages[key]) {
110
+ return this.errorMessages[key];
111
+ }
112
+
113
+ let template = DEFAULT_INPUT_FILE_UPLOAD_ERROR_MESSAGES[key] || 'Invalid field.';
114
+
115
+ switch (key) {
116
+ case 'maxFiles':
117
+ if (this.maxFiles != null) {
118
+ template = template.replace('{{limit}}', this.maxFiles.toString());
119
+ }
120
+ break;
121
+ case 'maxFileSize':
122
+ if (this.maxFileSize != null) {
123
+ template = template.replace('{{limit}}', this.formatBytes(this.maxFileSize));
124
+ }
125
+ break;
126
+ case 'maxTotalSize':
127
+ if (this.maxTotalSize != null) {
128
+ template = template.replace('{{limit}}', this.formatBytes(this.maxTotalSize));
129
+ }
130
+ break;
131
+ case 'accept':
132
+ if (this.accept) {
133
+ template = template.replace('{{accept}}', this.accept);
134
+ }
135
+ break;
136
+ }
137
+
138
+ return template;
139
+ });
140
+ }
141
+
142
+ protected override get warningList(): string[] {
143
+ return [];
144
+ }
145
+
146
+ public get fileSummary(): string {
147
+ if (!this.files.length) return this.noFileText;
148
+ if (this.files.length === 1) return this.files[0].name;
149
+ return `${this.files.length} files selected`;
150
+ }
151
+
152
+ public get hasFiles(): boolean {
153
+ return this.files.length > 0;
154
+ }
155
+
156
+ public triggerFileDialog(): void {
157
+ if (this.disabled) return;
158
+ this.fileInput.nativeElement.click();
159
+ }
160
+
161
+ public onFileChange(event: Event): void {
162
+ const input = event.target as HTMLInputElement;
163
+ const selectedFiles = Array.from(input.files ?? []);
164
+ if (!selectedFiles.length) {
165
+ return;
166
+ }
167
+ this.handleSelectedFiles(selectedFiles);
168
+ }
169
+
170
+ public onDragOver(event: DragEvent): void {
171
+ if (this.disabled) return;
172
+ event.preventDefault();
173
+ event.stopPropagation();
174
+ this.isDragOver = true;
175
+ }
176
+
177
+ public onDragLeave(event: DragEvent): void {
178
+ if (this.disabled) return;
179
+ event.preventDefault();
180
+ event.stopPropagation();
181
+ this.isDragOver = false;
182
+ }
183
+
184
+ public onDrop(event: DragEvent): void {
185
+ if (this.disabled) return;
186
+ event.preventDefault();
187
+ event.stopPropagation();
188
+ this.isDragOver = false;
189
+
190
+ const droppedFiles = Array.from(event.dataTransfer?.files ?? []);
191
+ if (!droppedFiles.length) {
192
+ return;
193
+ }
194
+
195
+ this.handleSelectedFiles(droppedFiles);
196
+ }
197
+
198
+ public override onBlur(_event: FocusEvent): void {
199
+ this.onTouched();
200
+ }
201
+
202
+ public clearFiles(): void {
203
+ if (this.disabled) return;
204
+ this.files = [];
205
+ this.value = null;
206
+ this.resetNativeInput();
207
+ this.onChange(this.value);
208
+ this.updateErrors();
209
+ this.onTouched();
210
+ }
211
+
212
+ public removeFile(index: number): void {
213
+ if (this.disabled || !this.multiple) {
214
+ this.clearFiles();
215
+ return;
216
+ }
217
+
218
+ this.files = this.files.filter((_, idx) => idx !== index);
219
+ this.value = this.files.length ? [...this.files] : null;
220
+ this.resetNativeInput();
221
+ this.onChange(this.value);
222
+ this.updateErrors();
223
+ this.onTouched();
224
+ }
225
+
226
+ public trackFile(_index: number, file: File): string {
227
+ return `${file.name}-${file.size}-${file.lastModified}`;
228
+ }
229
+
230
+ public formatBytes(bytes: number): string {
231
+ if (bytes < 1024) return `${bytes} B`;
232
+ const units = ['KB', 'MB', 'GB', 'TB'];
233
+ let size = bytes / 1024;
234
+ let unitIndex = 0;
235
+ while (size >= 1024 && unitIndex < units.length - 1) {
236
+ size /= 1024;
237
+ unitIndex += 1;
238
+ }
239
+ return `${size.toFixed(size < 10 ? 1 : 0)} ${units[unitIndex]}`;
240
+ }
241
+
242
+ private syncFromValue(value: InputFileUploadValue | null): void {
243
+ if (!value) {
244
+ this.files = [];
245
+ return;
246
+ }
247
+
248
+ const normalized = Array.isArray(value) ? value : [value];
249
+ this.files = this.multiple ? normalized : normalized.slice(0, 1);
250
+ }
251
+
252
+ private resetNativeInput(): void {
253
+ if (this.fileInput?.nativeElement) {
254
+ this.fileInput.nativeElement.value = '';
255
+ }
256
+ }
257
+
258
+ private handleSelectedFiles(selectedFiles: File[]): void {
259
+ const nextFiles = this.multiple
260
+ ? [...this.files, ...selectedFiles]
261
+ : selectedFiles.slice(0, 1);
262
+
263
+ this.files = nextFiles;
264
+ this.value = this.multiple ? nextFiles : nextFiles[0] ?? null;
265
+
266
+ this.onChange(this.value);
267
+ this.updateErrors();
268
+ this.onTouched();
269
+ }
270
+
271
+ private updateErrors(): void {
272
+ if (!this.control) return;
273
+
274
+ const errors = this.validateFiles();
275
+ const nextErrors = this.mergeErrors(errors);
276
+
277
+ this.control.setErrors(Object.keys(nextErrors).length ? nextErrors : null);
278
+ }
279
+
280
+ private validateFiles(): Record<string, unknown> {
281
+ const errors: Record<string, unknown> = {};
282
+
283
+ if (this.required && !this.files.length) {
284
+ errors['required'] = true;
285
+ }
286
+
287
+ if (this.maxFiles && this.files.length > this.maxFiles) {
288
+ errors['maxFiles'] = true;
289
+ }
290
+
291
+ if (this.maxFileSize && this.files.some(file => file.size > (this.maxFileSize || 0))) {
292
+ errors['maxFileSize'] = true;
293
+ }
294
+
295
+ if (this.maxTotalSize != null && this.totalSize() > this.maxTotalSize) {
296
+ errors['maxTotalSize'] = true;
297
+ }
298
+
299
+ if (this.accept && this.files.some(file => !this.isAccepted(file))) {
300
+ errors['accept'] = true;
301
+ }
302
+
303
+ return errors;
304
+ }
305
+
306
+ private mergeErrors(newErrors: Record<string, unknown>): Record<string, unknown> {
307
+ const currentErrors = this.control?.errors ?? {};
308
+ const nextErrors: Record<string, unknown> = {};
309
+
310
+ for (const [key, value] of Object.entries(currentErrors)) {
311
+ if (!this.ownedErrors.has(key)) {
312
+ nextErrors[key] = value;
313
+ }
314
+ }
315
+
316
+ for (const [key, value] of Object.entries(newErrors)) {
317
+ nextErrors[key] = value;
318
+ }
319
+
320
+ return nextErrors;
321
+ }
322
+
323
+ private totalSize(): number {
324
+ return this.files.reduce((sum, file) => sum + file.size, 0);
325
+ }
326
+
327
+ private isAccepted(file: File): boolean {
328
+ if (!this.accept) return true;
329
+
330
+ const acceptList = this.accept
331
+ .split(',')
332
+ .map(item => item.trim().toLowerCase())
333
+ .filter(Boolean);
334
+
335
+ if (!acceptList.length) return true;
336
+
337
+ const fileName = file.name.toLowerCase();
338
+ const fileType = (file.type || '').toLowerCase();
339
+
340
+ return acceptList.some(accept => {
341
+ if (accept.startsWith('.')) {
342
+ return fileName.endsWith(accept);
343
+ }
344
+ if (accept.endsWith('/*')) {
345
+ const baseType = accept.replace('/*', '');
346
+ return fileType.startsWith(`${baseType}/`);
347
+ }
348
+ return fileType === accept;
349
+ });
350
+ }
351
+ }
@@ -0,0 +1,8 @@
1
+ import { InputTimeMeridiem } from "./input-type";
2
+
3
+ export interface InputTimeParts {
4
+ hour?: number;
5
+ minute?: number;
6
+ second?: number;
7
+ meridiem?: InputTimeMeridiem;
8
+ }
@@ -0,0 +1,51 @@
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
+
9
+ <div class="frg-input__number__container">
10
+ <button
11
+ type="button"
12
+ class="frg-input__number__arrow frg-input__number__arrow--decrement"
13
+ (click)="decrease()"
14
+ aria-label="Decrease value"
15
+ >
16
+
17
+ </button>
18
+
19
+ <input
20
+ [id]="id"
21
+ type="number"
22
+ [placeholder]="placeholder"
23
+ [required]="required"
24
+ [disabled]="disabled"
25
+ [attr.step]="inputStep"
26
+ [attr.min]="min"
27
+ [attr.max]="max"
28
+ [value]="value"
29
+ (input)="onInput($event)"
30
+ (blur)="onBlur($event)"
31
+ />
32
+
33
+ <button
34
+ type="button"
35
+ class="frg-input__number__arrow frg-input__number__arrow--increment"
36
+ (click)="increase()"
37
+ aria-label="Increase value"
38
+ >
39
+ +
40
+ </button>
41
+ </div>
42
+ </div>
43
+
44
+ @if (showValidation) {
45
+ <frg-input-validation
46
+ [errorList]="errorList"
47
+ [warningList]="warningList"
48
+ [isFormInvalid]="hasError"
49
+ >
50
+ </frg-input-validation>
51
+ }
@@ -0,0 +1,140 @@
1
+ @use "sass:color";
2
+ @use './../../../../../assets/styles/scss/variables' as *;
3
+
4
+ :host {
5
+ display: block;
6
+ font-family: $input-font-family;
7
+
8
+ input::-webkit-outer-spin-button,
9
+ input::-webkit-inner-spin-button {
10
+ -webkit-appearance: none;
11
+ margin: 0;
12
+ }
13
+
14
+ input[type="number"] {
15
+ -moz-appearance: textfield;
16
+ appearance: none;
17
+ }
18
+
19
+ .frg-input {
20
+ &__wrapper {
21
+ position: relative;
22
+ box-sizing: border-box;
23
+
24
+ label {
25
+ font-size: $font-size-xs;
26
+ color: $input-text-color;
27
+ padding: $input-padding;
28
+ }
29
+
30
+ &.input-error label {
31
+ color: $color-danger;
32
+ }
33
+
34
+ &.input-warning label {
35
+ color: $color-warning;
36
+ }
37
+
38
+ &::before,
39
+ &::after {
40
+ content: "";
41
+ position: absolute;
42
+ bottom: 0;
43
+ width: 0;
44
+ height: 0.125rem;
45
+ transition: width 0.3s ease, left 0.3s ease, right 0.3s ease;
46
+ }
47
+
48
+ &::before {
49
+ left: -50%;
50
+ background: $input-focus-border-color;
51
+ z-index: 1;
52
+ }
53
+
54
+ &::after {
55
+ right: -50%;
56
+
57
+ z-index: 2;
58
+ }
59
+
60
+ &:focus-within::before,
61
+ &.input-error::before,
62
+ &.input-error::after,
63
+ &.input-warning::after {
64
+ width: 100%;
65
+ }
66
+
67
+ &.input-error::after {
68
+ background: $color-danger;
69
+ right: 0;
70
+ }
71
+
72
+ &.input-warning::after {
73
+ background: $color-warning;
74
+ right: 0;
75
+ }
76
+
77
+ &:focus-within::before,
78
+ &.input-error::before,
79
+ &.input-warning::before {
80
+ left: 0;
81
+ }
82
+
83
+ }
84
+
85
+ &__number {
86
+ &__container {
87
+ display: flex;
88
+ align-items: center;
89
+ box-sizing: border-box;
90
+ position: relative;
91
+ border-bottom: 2px solid $input-border-color;
92
+ width: 100%;
93
+ max-width: 100%;
94
+ overflow: hidden;
95
+
96
+ input[type="number"] {
97
+ flex: 1 1 auto;
98
+ min-width: 0;
99
+ height: 100%;
100
+ border: none;
101
+ margin: 0;
102
+ padding: $input-padding;
103
+ text-align: center;
104
+ font-size: $input-font-size;
105
+ font-family: $input-font-family;
106
+ background: transparent;
107
+ color: $input-text-color;
108
+ outline: none;
109
+
110
+ &:disabled {
111
+ background: $input-disabled-background;
112
+ color: $input-border-color;
113
+ cursor: not-allowed;
114
+ }
115
+ }
116
+ }
117
+
118
+ &__arrow {
119
+ flex: 0 0 auto;
120
+ height: 100%;
121
+ margin: 0;
122
+ border: none;
123
+ background: transparent;
124
+ cursor: pointer;
125
+ font-size: 1.4rem;
126
+ color: $input-text-color;
127
+ user-select: none;
128
+
129
+ &:disabled {
130
+ opacity: 0.45;
131
+ cursor: not-allowed;
132
+ }
133
+
134
+ &:focus {
135
+ outline: none;
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,44 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { By } from '@angular/platform-browser';
3
+ import { InputNumberComponent } from './input-number.component';
4
+
5
+ describe('InputNumberComponent', () => {
6
+ let fixture: ComponentFixture<InputNumberComponent>;
7
+ let component: InputNumberComponent;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [InputNumberComponent]
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(InputNumberComponent);
15
+ component = fixture.componentInstance;
16
+ });
17
+
18
+ it('sets default placeholder for decimal inputs', () => {
19
+ component.type = 'decimal';
20
+ component.precision = 2;
21
+
22
+ fixture.detectChanges();
23
+
24
+ const input = fixture.debugElement.query(By.css('input')).nativeElement as HTMLInputElement;
25
+ expect(input.placeholder).toBe('0.00');
26
+ });
27
+
28
+ it('increments and decrements value via buttons', () => {
29
+ component.value = 1;
30
+
31
+ fixture.detectChanges();
32
+
33
+ const buttons = fixture.debugElement.queryAll(By.css('.frg-input__number__arrow'));
34
+ buttons[1].nativeElement.click();
35
+ fixture.detectChanges();
36
+
37
+ expect(component.value).toBe(2);
38
+
39
+ buttons[0].nativeElement.click();
40
+ fixture.detectChanges();
41
+
42
+ expect(component.value).toBe(1);
43
+ });
44
+ });