@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,343 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { InputBase } from '../input-base';
3
+ import {
4
+ DEFAULT_INPUT_NUMBER_ERROR_MESSAGES,
5
+ DEFAULT_INPUT_NUMBER_WARNING_MESSAGES,
6
+ } from '../input-consts';
7
+ import { InputNumberType } from '../input-type';
8
+ import { normalizeNumber } from '../../../utils/number.utils';
9
+ import { InputRequiredLabelPipe } from '../input.pipe';
10
+ import { InputValidationComponent } from '../input-validation/input-validation.component';
11
+
12
+ @Component({
13
+ selector: 'frg-input-number',
14
+ imports: [InputRequiredLabelPipe, InputValidationComponent],
15
+ templateUrl: './input-number.component.html',
16
+ styleUrl: './input-number.component.scss',
17
+ })
18
+ export class InputNumberComponent extends InputBase<number | null> implements OnInit {
19
+ /**
20
+ * @inheritdoc
21
+ */
22
+ @Input() public override label: string = '';
23
+ /**
24
+ * @inheritdoc
25
+ */
26
+ @Input() public override placeholder: string = '';
27
+ /**
28
+ * @inheritdoc
29
+ */
30
+ @Input() public override required: boolean = false;
31
+ /**
32
+ * @inheritdoc
33
+ */
34
+ @Input() public override showValidation: boolean = true;
35
+ /**
36
+ * @inheritdoc
37
+ */
38
+ @Input() public override errorMessages: Record<string, string> = {};
39
+
40
+ /**
41
+ * The type of the input element.
42
+ * Can be 'number' or 'decimal'.
43
+ * Defaults to 'number'.
44
+ */
45
+ @Input() public type: InputNumberType = 'number';
46
+
47
+ /**
48
+ * Minimum allowed value for the input.
49
+ */
50
+ @Input() public min: number | null = null;
51
+
52
+ /**
53
+ * Maximum allowed value for the input.
54
+ */
55
+ @Input() public max: number | null = null;
56
+
57
+ /**
58
+ * Increment/decrement step for the input value.
59
+ */
60
+ @Input() public step: number | null = null;
61
+
62
+ /**
63
+ * Maximum number of decimal places allowed.
64
+ */
65
+ @Input() public precision: number | null = null;
66
+
67
+ /**
68
+ * Enables strict mode for validation.
69
+ * Defaults to false.
70
+ */
71
+ @Input() public validatorStrictMode: boolean = false;
72
+
73
+ /** Internal store for warnings */
74
+ private warnings: Record<string, boolean> = {};
75
+
76
+ /**
77
+ * @inheritdoc
78
+ */
79
+ public override ngOnInit(): void {
80
+ super.ngOnInit();
81
+ this.initPlaceholder();
82
+ }
83
+
84
+ /**
85
+ * Returns the step value for the input based on type and precision.
86
+ */
87
+ public get inputStep(): number {
88
+ if (this.step != null) return this.step;
89
+ if (this.type === 'decimal') return this.precision ? Math.pow(10, -this.precision) : 0.01;
90
+ return 1;
91
+ }
92
+
93
+ /**
94
+ * Handles blur event:
95
+ * - Aligns value to step
96
+ * - Clamps to min/max/precision
97
+ * - Runs validation
98
+ */
99
+ protected override onBlur(event: FocusEvent): void {
100
+ const relatedTarget = event.relatedTarget as HTMLElement | null;
101
+ const isStepButton = relatedTarget?.classList.contains('frg-input__number__arrow');
102
+
103
+ if (this.value != null && !isStepButton) {
104
+ this.validate(this.value);
105
+ const snappedValue = this.step ? this.alignToStep(this.value, this.inputStep) : this.value;
106
+ this.value = this.applyClamping(snappedValue);
107
+ }
108
+
109
+ this.onChange(this.value);
110
+ this.onTouched();
111
+ }
112
+
113
+ /**
114
+ * Handles input event:
115
+ * - Normalizes value
116
+ * - Runs validation
117
+ */
118
+ protected override onInput(event: Event): void {
119
+ const input = event.target as HTMLInputElement;
120
+ this.value = normalizeNumber(input);
121
+
122
+ if (this.value != null) {
123
+ this.validate(this.value);
124
+ }
125
+
126
+ this.onChange(this.value);
127
+ }
128
+
129
+ /**
130
+ * @inheritdoc
131
+ */
132
+ protected updateView(_value: number | null): void {
133
+ // Handled by Angular binding
134
+ }
135
+
136
+ /**
137
+ * @inheritdoc
138
+ */
139
+ protected updateDisabledState(_isDisabled: boolean): void {
140
+ // Handled by Angular binding
141
+ }
142
+
143
+ /**
144
+ * Returns error messages, excluding warnings.
145
+ */
146
+ protected override get errorList(): string[] {
147
+ if (!this.control?.errors) return [];
148
+ return Object.keys(this.control.errors)
149
+ .filter(key => !key.startsWith('warning_'))
150
+ .map(key => this.errorMessages[key] ?? DEFAULT_INPUT_NUMBER_ERROR_MESSAGES[key] ?? 'Invalid field.');
151
+ }
152
+
153
+ /**
154
+ * Returns dynamic warning messages, replacing {{limit}} with actual values.
155
+ */
156
+ protected override get warningList(): string[] {
157
+ return Object.keys(this.warnings).map(key => {
158
+ const template = DEFAULT_INPUT_NUMBER_WARNING_MESSAGES[key] || 'Check this value.';
159
+
160
+ let limit: number | undefined;
161
+ switch (key) {
162
+ case 'min':
163
+ limit = this.min ?? undefined;
164
+ break;
165
+ case 'max':
166
+ limit = this.max ?? undefined;
167
+ break;
168
+ case 'step':
169
+ limit = this.inputStep;
170
+ break;
171
+ case 'precision':
172
+ limit = this.precision ?? undefined;
173
+ break;
174
+ default:
175
+ limit = undefined;
176
+ }
177
+
178
+ return limit != null ? template.replace('{{limit}}', limit.toString()) : template;
179
+ });
180
+ }
181
+
182
+ /**
183
+ * Returns whether any warnings are active.
184
+ */
185
+ protected get hasWarning(): boolean {
186
+ return this.warningList.length > 0;
187
+ }
188
+
189
+ /**
190
+ * Increase value by step, respecting precision, step alignment and max.
191
+ */
192
+ protected increase(): void {
193
+ const step = this.inputStep;
194
+ const baseValue = this.value ?? this.min ?? 0;
195
+
196
+ let newValue: number;
197
+
198
+ if (this.step != null) {
199
+ const snapped = this.alignToStep(baseValue, step);
200
+ newValue = snapped === baseValue ? baseValue + step : snapped;
201
+ } else {
202
+ newValue = baseValue + step;
203
+ }
204
+
205
+ newValue = +newValue.toFixed(this.precision ?? 12);
206
+ newValue = this.applyClamping(newValue);
207
+ this.validate(newValue);
208
+
209
+ if (newValue !== this.value) {
210
+ this.value = newValue;
211
+ this.onChange(this.value);
212
+ this.onTouched();
213
+ }
214
+ }
215
+
216
+ /**
217
+ * Decrease value by step, respecting precision, step alignment and min.
218
+ */
219
+ protected decrease(): void {
220
+ const step = this.inputStep;
221
+ const baseValue = this.value ?? this.min ?? 0;
222
+
223
+ let newValue: number;
224
+
225
+ if (this.step != null) {
226
+ const snapped = this.alignToStep(baseValue, step);
227
+ newValue = snapped === baseValue ? baseValue - step : snapped;
228
+ } else {
229
+ newValue = baseValue - step;
230
+ }
231
+
232
+ newValue = +newValue.toFixed(this.precision ?? 12);
233
+ newValue = this.applyClamping(newValue);
234
+ this.validate(newValue);
235
+
236
+ if (newValue !== this.value) {
237
+ this.value = newValue;
238
+ this.onChange(this.value);
239
+ this.onTouched();
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Clamps a value to respect precision, min, and max
245
+ * @param value Value to clamp
246
+ */
247
+ private applyClamping(value: number): number {
248
+ let clampedValue = value;
249
+
250
+ if (this.precision != null) {
251
+ clampedValue = +clampedValue.toFixed(this.precision);
252
+ }
253
+ if (this.max != null && clampedValue > this.max) {
254
+ clampedValue = this.max;
255
+ }
256
+ if (this.min != null && clampedValue < this.min) {
257
+ clampedValue = this.min;
258
+ }
259
+
260
+ return clampedValue;
261
+ }
262
+
263
+ /**
264
+ * Validates a value against precision, min, max, and step
265
+ * @param value Value to validate
266
+ */
267
+ private validate(value: number): void {
268
+ if (this.precision != null) {
269
+ const decimals = this.countDecimals(value);
270
+ if (decimals > this.precision) {
271
+ this.addWarning('precision');
272
+ } else {
273
+ this.removeWarning('precision');
274
+ }
275
+ }
276
+
277
+ if (this.max != null && value > this.max) {
278
+ this.addWarning('max');
279
+ } else {
280
+ this.removeWarning('max');
281
+ }
282
+
283
+ if (this.min != null && value < this.min) {
284
+ this.addWarning('min');
285
+ } else {
286
+ this.removeWarning('min');
287
+ }
288
+
289
+ if (this.step != null) {
290
+ const base = this.min ?? 0;
291
+ const diff = (value - base) / this.step;
292
+ if (!Number.isInteger(diff)) {
293
+ this.addWarning('step');
294
+ } else {
295
+ this.removeWarning('step');
296
+ }
297
+ }
298
+ }
299
+
300
+ /** Initializes placeholder based on type */
301
+ private initPlaceholder(): void {
302
+ if (!this.placeholder) {
303
+ this.placeholder = this.type === 'decimal' ? (0).toFixed(this.precision ?? 2) : '0';
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Adds a warning flag
309
+ * @param key Warning type
310
+ */
311
+ private addWarning(key: string): void {
312
+ this.warnings[key] = true;
313
+ }
314
+
315
+ /**
316
+ * Removes a warning flag
317
+ * @param key Warning type
318
+ */
319
+ private removeWarning(key: string): void {
320
+ delete this.warnings[key];
321
+ }
322
+
323
+ /**
324
+ * Aligns a value to the nearest multiple of step
325
+ * @param value Value to align
326
+ * @param step Step size
327
+ */
328
+ private alignToStep(value: number, step: number): number {
329
+ const base = this.min ?? 0;
330
+ const offset = value - base;
331
+ const steps = Math.round(offset / step);
332
+ return base + steps * step;
333
+ }
334
+
335
+ /**
336
+ * Counts the number of decimals in a number
337
+ * @param num Number to check
338
+ */
339
+ private countDecimals(num: number): number {
340
+ if (Math.floor(num) === num) return 0;
341
+ return num.toString().split('.')[1]?.length ?? 0;
342
+ }
343
+ }
@@ -0,0 +1,44 @@
1
+ <div
2
+ class="frg-radio-group__wrapper"
3
+ [class.input-error]="hasError"
4
+ [class.input-warning]="hasWarning"
5
+ [ngClass]="{
6
+ 'frg-radio-group__primary': styleType === 'primary',
7
+ 'frg-radio-group__secondary': styleType === 'secondary',
8
+ 'frg-radio-group__tertiary': styleType === 'tertiary',
9
+ 'frg-radio-group__success': styleType === 'success',
10
+ 'frg-radio-group__warning': styleType === 'warning',
11
+ 'frg-radio-group__danger': styleType === 'danger',
12
+ 'frg-radio-group__light': styleType === 'light',
13
+ 'frg-radio-group__dark': styleType === 'dark'
14
+ }"
15
+ >
16
+ @if(label){
17
+ <span class="frg-radio-group__label">{{ label | inputRequiredLabel: required }}</span>
18
+ }
19
+
20
+ <div class="frg-radio-group__list">
21
+ @for (item of items; track item.id) {
22
+ <label class="frg-radio" [class.disabled]="disabled || item.disabled">
23
+ <input
24
+ type="radio"
25
+ [id]="id + '-' + item.id"
26
+ [name]="id"
27
+ [checked]="isSelected(item)"
28
+ [disabled]="disabled || item.disabled"
29
+ (change)="selectItem(item, $event)"
30
+ (blur)="onBlur()"
31
+ />
32
+ <span class="frg-radio__label">{{ item.label }}</span>
33
+ </label>
34
+ }
35
+ </div>
36
+
37
+ @if(showValidation) {
38
+ <frg-input-validation
39
+ [errorList]="errorList"
40
+ [warningList]="warningList"
41
+ [isFormInvalid]="hasError"
42
+ ></frg-input-validation>
43
+ }
44
+ </div>
@@ -0,0 +1,139 @@
1
+ @use './../../../../../assets/styles/scss/variables' as *;
2
+
3
+ :host {
4
+ display: block;
5
+
6
+ @mixin radio-group-style($color) {
7
+ input[type="radio"]::after {
8
+ background: $color;
9
+ }
10
+
11
+ input[type="radio"]:checked {
12
+ border-color: $color;
13
+ }
14
+
15
+ input[type="radio"]:focus-visible {
16
+ box-shadow: 0 0 0 4px rgba($color, 0.14);
17
+ }
18
+ }
19
+
20
+ .frg-radio-group__wrapper {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 0.5rem;
24
+ }
25
+
26
+ .frg-radio-group__wrapper.frg-radio-group__primary {
27
+ @include radio-group-style($color-primary);
28
+ }
29
+
30
+ .frg-radio-group__wrapper.frg-radio-group__secondary {
31
+ @include radio-group-style($color-secondary);
32
+ }
33
+
34
+ .frg-radio-group__wrapper.frg-radio-group__tertiary {
35
+ @include radio-group-style($color-tertiary);
36
+ }
37
+
38
+ .frg-radio-group__wrapper.frg-radio-group__success {
39
+ @include radio-group-style($color-success);
40
+ }
41
+
42
+ .frg-radio-group__wrapper.frg-radio-group__warning {
43
+ @include radio-group-style($color-warning);
44
+ }
45
+
46
+ .frg-radio-group__wrapper.frg-radio-group__danger {
47
+ @include radio-group-style($color-danger);
48
+ }
49
+
50
+ .frg-radio-group__wrapper.frg-radio-group__light {
51
+ @include radio-group-style($color-light);
52
+ }
53
+
54
+ .frg-radio-group__wrapper.frg-radio-group__dark {
55
+ @include radio-group-style($color-dark);
56
+ }
57
+
58
+ .frg-radio-group__label {
59
+ font-size: $font-size-xs;
60
+ color: $input-text-color;
61
+ }
62
+
63
+ .frg-radio-group__list {
64
+ display: grid;
65
+ gap: 0.5rem;
66
+ }
67
+
68
+ .frg-radio {
69
+ display: inline-flex;
70
+ align-items: center;
71
+ gap: 0.5rem;
72
+ cursor: pointer;
73
+ font-size: $font-size-xs;
74
+ color: $input-text-color;
75
+ }
76
+
77
+ .input-error .frg-radio-group__label,
78
+ .input-error .frg-radio {
79
+ color: $color-danger;
80
+ }
81
+
82
+ .input-warning .frg-radio-group__label,
83
+ .input-warning .frg-radio {
84
+ color: $color-warning;
85
+ }
86
+
87
+ input[type="radio"] {
88
+ appearance: none;
89
+ -webkit-appearance: none;
90
+ width: 1rem;
91
+ height: 1rem;
92
+ border-radius: 50%;
93
+ background: transparent;
94
+ border: 1px solid $input-border-color;
95
+ display: inline-grid;
96
+ place-content: center;
97
+ transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
98
+ cursor: pointer;
99
+ }
100
+
101
+ input[type="radio"]::after {
102
+ content: "";
103
+ width: 0.5rem;
104
+ height: 0.5rem;
105
+ border-radius: 50%;
106
+ background: $color-primary;
107
+ transform: scale(0);
108
+ transform-origin: center;
109
+ transition: transform 140ms ease;
110
+ }
111
+
112
+ input[type="radio"]:checked {
113
+ background: transparent;
114
+ border-color: $color-primary;
115
+ }
116
+
117
+ input[type="radio"]:checked::after {
118
+ transform: scale(1);
119
+ }
120
+
121
+ input[type="radio"]:focus {
122
+ outline: none;
123
+ }
124
+
125
+ input[type="radio"]:focus-visible {
126
+ box-shadow: 0 0 0 4px rgba($color-primary, 0.14);
127
+ }
128
+
129
+ input[type="radio"]:disabled {
130
+ cursor: not-allowed;
131
+ opacity: 0.65;
132
+ background: transparent;
133
+ border-color: $input-disabled-border-color;
134
+ }
135
+
136
+ .frg-radio.disabled {
137
+ cursor: not-allowed;
138
+ }
139
+ }
@@ -0,0 +1,58 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { By } from '@angular/platform-browser';
3
+ import { InputRadioGroupComponent, InputRadioGroupItem } from './input-radio-group.component';
4
+
5
+ describe('InputRadioGroupComponent', () => {
6
+ let fixture: ComponentFixture<InputRadioGroupComponent<string>>;
7
+ let component: InputRadioGroupComponent<string>;
8
+
9
+ const items: Array<InputRadioGroupItem<string>> = [
10
+ { id: 'a', label: 'Option A', value: 'a' },
11
+ { id: 'b', label: 'Option B', value: 'b' }
12
+ ];
13
+
14
+ beforeEach(async () => {
15
+ await TestBed.configureTestingModule({
16
+ imports: [InputRadioGroupComponent]
17
+ }).compileComponents();
18
+
19
+ fixture = TestBed.createComponent(InputRadioGroupComponent<string>);
20
+ component = fixture.componentInstance;
21
+ component.items = items;
22
+ });
23
+
24
+ it('selects a value when checked', () => {
25
+ fixture.detectChanges();
26
+
27
+ const input = fixture.debugElement.query(By.css('input[type="radio"]'));
28
+ input.nativeElement.checked = true;
29
+ input.nativeElement.dispatchEvent(new Event('change'));
30
+ fixture.detectChanges();
31
+
32
+ expect(component.value).toEqual('a');
33
+ });
34
+
35
+ it('does not select when group is disabled', () => {
36
+ component.disabled = true;
37
+
38
+ fixture.detectChanges();
39
+
40
+ const input = fixture.debugElement.query(By.css('input[type="radio"]'));
41
+ input.nativeElement.checked = true;
42
+ input.nativeElement.dispatchEvent(new Event('change'));
43
+
44
+ expect(component.value).toBeNull();
45
+ });
46
+
47
+ it('does not select when item is disabled', () => {
48
+ component.items = [{ id: 'a', label: 'Option A', value: 'a', disabled: true }];
49
+
50
+ fixture.detectChanges();
51
+
52
+ const input = fixture.debugElement.query(By.css('input[type="radio"]'));
53
+ input.nativeElement.checked = true;
54
+ input.nativeElement.dispatchEvent(new Event('change'));
55
+
56
+ expect(component.value).toBeNull();
57
+ });
58
+ });
@@ -0,0 +1,132 @@
1
+ import { NgClass } from '@angular/common';
2
+ import { Component, Input } from '@angular/core';
3
+ import { InputBase } from '../input-base';
4
+ import { DEFAULT_INPUT_RADIO_GROUP_ERROR_MESSAGES, DEFAULT_INPUT_RADIO_GROUP_WARNINGS_MESSAGES } from '../input-consts';
5
+ import { InputChoiceStyleType } from '../input-type';
6
+ import { InputValidationComponent } from '../input-validation/input-validation.component';
7
+ import { InputRequiredLabelPipe } from '../input.pipe';
8
+
9
+ export interface InputRadioGroupItem<T> {
10
+ id: string;
11
+ label: string;
12
+ value: T;
13
+ disabled?: boolean;
14
+ }
15
+
16
+ @Component({
17
+ selector: 'frg-input-radio-group',
18
+ imports: [NgClass, InputRequiredLabelPipe, InputValidationComponent],
19
+ templateUrl: './input-radio-group.component.html',
20
+ styleUrl: './input-radio-group.component.scss',
21
+ })
22
+ export class InputRadioGroupComponent<T> extends InputBase<T> {
23
+ /**
24
+ * @inheritdoc
25
+ */
26
+ @Input() public override label: string = '';
27
+ /**
28
+ * @inheritdoc
29
+ */
30
+ @Input() public override required: boolean = false;
31
+ /**
32
+ * @inheritdoc
33
+ */
34
+ @Input() public override disabled: boolean = false;
35
+ /**
36
+ * @inheritdoc
37
+ */
38
+ @Input() public override errorMessages: Record<string, string> = {};
39
+ /**
40
+ * @inheritdoc
41
+ */
42
+ @Input() public override warningMessages: Record<string, string> = {};
43
+ /**
44
+ * @inheritdoc
45
+ */
46
+ @Input() public override showValidation: boolean = true;
47
+ /**
48
+ * Sets the visual style of the radio group.
49
+ */
50
+ @Input() public styleType: InputChoiceStyleType = 'primary';
51
+
52
+ @Input() public items: Array<InputRadioGroupItem<T>> = [];
53
+ @Input() public compareWith: (a: T, b: T) => boolean = (a, b) => a === b;
54
+
55
+ /**
56
+ * Selects a radio item value.
57
+ */
58
+ public selectItem(item: InputRadioGroupItem<T>, event: Event): void {
59
+ if (this.disabled || item.disabled) return;
60
+
61
+ const input = event.target as HTMLInputElement;
62
+ if (!input.checked) return;
63
+
64
+ this.value = item.value;
65
+ this.onChange(this.value);
66
+ this.onTouched();
67
+ }
68
+
69
+ /**
70
+ * Checks if the item is selected.
71
+ */
72
+ public isSelected(item: InputRadioGroupItem<T>): boolean {
73
+ if (this.value === null || this.value === undefined) return false;
74
+ return this.compareWith(this.value, item.value);
75
+ }
76
+
77
+ /**
78
+ * @inheritdoc
79
+ */
80
+ public override onBlur(): void {
81
+ this.onTouched();
82
+ }
83
+
84
+ /**
85
+ * @inheritdoc
86
+ */
87
+ protected updateView(_value: T | null): void {
88
+ // Handled by Angular binding
89
+ }
90
+
91
+ /**
92
+ * @inheritdoc
93
+ */
94
+ protected updateDisabledState(_isDisabled: boolean): void {
95
+ // Handled by Angular binding
96
+ }
97
+
98
+ /**
99
+ * @inheritdoc
100
+ */
101
+ protected override get errorList(): string[] {
102
+ if (!this.control?.errors) return [];
103
+ const errors = this.control.errors;
104
+ return Object.keys(errors).map(key => {
105
+ if (this.errorMessages[key]) {
106
+ return this.errorMessages[key];
107
+ }
108
+ return DEFAULT_INPUT_RADIO_GROUP_ERROR_MESSAGES[key] || 'Invalid field.';
109
+ });
110
+ }
111
+
112
+ /**
113
+ * Returns warning messages. Consumers may pass arbitrary warnings via `warningMessages`.
114
+ * Falls back to DEFAULT_INPUT_RADIO_GROUP_WARNINGS_MESSAGES or a generic message.
115
+ */
116
+ protected override get warningList(): string[] {
117
+ return Object.keys(this.warningMessages).map(key => {
118
+ return (
119
+ this.warningMessages[key] ||
120
+ DEFAULT_INPUT_RADIO_GROUP_WARNINGS_MESSAGES[key] ||
121
+ ''
122
+ );
123
+ });
124
+ }
125
+
126
+ /**
127
+ * Returns whether any warnings are active.
128
+ */
129
+ protected get hasWarning(): boolean {
130
+ return this.warningList.length > 0;
131
+ }
132
+ }