@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,23 @@
1
+ export type TBaseStyle =
2
+ | 'default'
3
+ | 'primary'
4
+ | 'secondary'
5
+ | 'tertiary'
6
+ | 'dark'
7
+ | 'light'
8
+ | 'info'
9
+ | 'success'
10
+ | 'warning'
11
+ | 'danger'
12
+ | 'outline-primary'
13
+ | 'outline-secondary'
14
+ | 'outline-tertiary'
15
+ | 'outline-dark'
16
+ | 'outline-light'
17
+ | 'outline-info'
18
+ | 'outline-success'
19
+ | 'outline-warning'
20
+ | 'outline-danger';
21
+
22
+ export type TBaseSize = 'small' | 'medium' | 'large';
23
+ export type TBasePosition = 'top' | 'left' | 'right' | 'bottom';
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Represents a value that can be used in Angular's `ngClass` directive
3
+ * to determine whether a class should be applied.
4
+ * - `boolean`: apply class if true, remove if false
5
+ * - `number`: treated as truthy if non-zero, falsy if zero
6
+ * - `string`: directly represents a class name
7
+ * - `null` or `undefined`: no class applied
8
+ */
9
+ export type NgClassValue = boolean | number | string | null | undefined;
10
+
11
+ /**
12
+ * Describes the different formats supported by a custom implementation
13
+ * of Angular's `ngClass`. It allows:
14
+ * - A single class name as a string
15
+ * - An array of class names
16
+ * - A Set of class names
17
+ * - An object map where keys are class names and values determine whether they should be applied
18
+ * - `null` or `undefined` to apply no classes
19
+ */
20
+ export type TCustomNgClass =
21
+ | string
22
+ | string[]
23
+ | Set<string>
24
+ | { [klass: string]: NgClassValue }
25
+ | null
26
+ | undefined;
27
+
28
+ /**
29
+ * Creates a type that removes the properties of `U` from `T`
30
+ * by marking them as optional and setting their type to `never`.
31
+ * Useful for constructing mutually exclusive types.
32
+ */
33
+ export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
34
+
35
+ /**
36
+ * Constructs an exclusive OR (XOR) type between `T` and `U`.
37
+ * Ensures that either `T` or `U` is allowed, but not both at the same time.
38
+ * - If both are objects, it enforces mutual exclusivity at the property level.
39
+ * - If not objects, it falls back to a simple union (`T | U`).
40
+ */
41
+ export type XOR<T, U> = T | U extends object
42
+ ? (Without<T, U> & U) | (Without<U, T> & T)
43
+ : T | U;
44
+
45
+ /**
46
+ * Represents a generic function type that takes a single argument of any type
47
+ * and returns a value of type `T`.
48
+ *
49
+ * @template T The return type of the function.
50
+ */
51
+ export type GenericFunction<T> = (arg0: unknown) => T;
52
+
53
+ /**
54
+ * Represents a mutually exclusive type between `T` and `K`.
55
+ * Only one of the two types can be used at a time.
56
+ *
57
+ * @template T The first type option.
58
+ * @template K The second type option.
59
+ */
60
+ export type TBehaviourAction<T, K> = XOR<T, K>;
61
+
62
+ /**
63
+ * Represents an array that contains at least one element of type `T`.
64
+ * Ensures that the array is never empty by requiring an element at index 0.
65
+ *
66
+ * @template T The type of the elements in the array.
67
+ */
68
+ export type ArrayOneOrMore<T> = { 0: T } & Array<T>;
69
+
70
+ export type DateFormat =
71
+ | "dd/MM/yyyy"
72
+ | "MM/dd/yyyy"
73
+ | "yyyy-MM-dd"
74
+ | "dd-MM-yyyy"
75
+ | "dd.MM.yyyy"
76
+ | "yyyy/MM/dd"
77
+ | "MMM dd, yyyy"
78
+ | "MMMM dd, yyyy"
79
+ | "dd MMM yyyy"
80
+ | "dd MMMM yyyy"
81
+ | "yyyyMMdd";
82
+
83
+ export type TimeFormat = "HH:mm:ss" | "HH:mm" | "hh:mm:ss a" | "hh:mm a";
84
+
85
+ export type DateTimeFormat =
86
+ | "dd/MM/yyyy HH:mm"
87
+ | "dd/MM/yyyy HH:mm:ss"
88
+ | "MM/dd/yyyy HH:mm"
89
+ | "MM/dd/yyyy hh:mm a"
90
+ | "yyyy-MM-dd'T'HH:mm"
91
+ | "yyyy-MM-dd'T'HH:mm:ss"
92
+ | "dd MMM yyyy HH:mm"
93
+ | "dd MMM yyyy hh:mm a"
94
+ | "MMMM dd, yyyy HH:mm"
95
+ | "MMMM dd, yyyy hh:mm a"
96
+ | "yyyyMMdd HH:mm"
97
+ | "yyyyMMdd HH:mm:ss";
98
+
@@ -0,0 +1,5 @@
1
+ import { FormControl } from '@angular/forms';
2
+
3
+ export type TypeForm<T> = {
4
+ [K in keyof T]: FormControl<T[K]>;
5
+ };
@@ -0,0 +1,53 @@
1
+ import { ActivatedRoute } from '@angular/router';
2
+
3
+ type direction = 'asc' | 'desc';
4
+
5
+ export function generateId(value?: string): string {
6
+ const valueRandom: number = Math.floor(Math.random() * 10000000) + 1;
7
+ return value ? value + '-' + valueRandom : String(valueRandom);
8
+ }
9
+
10
+ export function generateNumberId(): number {
11
+ return Math.floor(Math.random() * 10000000) + 1;
12
+ }
13
+
14
+ export function isObjectEmpty(obj: any): boolean {
15
+ return Object.keys(obj).length <= 0;
16
+ }
17
+
18
+ export function paginationList<T>(
19
+ lista: Array<T>,
20
+ pageSize: number,
21
+ page: number
22
+ ) {
23
+ lista = lista.slice(+pageSize * (+page - 1), +pageSize * +page);
24
+ return lista;
25
+ }
26
+
27
+ export function orderList<T>(
28
+ lista: Array<T>,
29
+ orderFields: any,
30
+ direction: direction
31
+ ) {
32
+ orderFields = Array.isArray(orderFields)
33
+ ? orderFields.join('.')
34
+ : orderFields;
35
+ lista.sort((a: any, b: any) => {
36
+ if (direction === 'asc') {
37
+ return a[orderFields] > b[orderFields] ? 1 : -1;
38
+ } else {
39
+ return a[orderFields] < b[orderFields] ? 1 : -1;
40
+ }
41
+ });
42
+ return lista;
43
+ }
44
+
45
+ export function getActivatedRouteChild(
46
+ activatedRoute: ActivatedRoute
47
+ ): ActivatedRoute {
48
+ if (activatedRoute.firstChild) {
49
+ return getActivatedRouteChild(activatedRoute.firstChild);
50
+ } else {
51
+ return activatedRoute;
52
+ }
53
+ }
@@ -0,0 +1,474 @@
1
+ import { InputTimePartial } from "../components/input/input-type";
2
+ import { DateFormat, DateTimeFormat, TimeFormat } from "../types/common.types";
3
+
4
+ export function isValidDate(dateString: string, format: DateFormat = "yyyy-MM-dd"): boolean {
5
+ if (format !== 'yyyy-MM-dd') {
6
+ const isoString = convertStringToISODate(dateString, format);
7
+
8
+ if (!isoString)
9
+ return false;
10
+
11
+ const dateObj = new Date(isoString);
12
+ return !isNaN(dateObj.getTime());
13
+ }
14
+
15
+ const dateObject: Date = new Date(dateString);
16
+ return !isNaN(dateObject.getTime());
17
+ }
18
+
19
+ /**
20
+ * Checks if a given datetime string matches a given format and represents a valid date/time.
21
+ */
22
+ export function isValidDateTime(
23
+ dateTimeString: string,
24
+ format: DateTimeFormat = "yyyy-MM-dd'T'HH:mm"
25
+ ): boolean {
26
+ if (!dateTimeString)
27
+ return false;
28
+
29
+ // If it's not the standard ISO-like format, convert it manually
30
+ if (format !== "yyyy-MM-dd'T'HH:mm" && format !== "yyyy-MM-dd'T'HH:mm:ss") {
31
+ const isoString = convertStringToISODateTime(dateTimeString, format);
32
+
33
+ if (!isoString)
34
+ return false;
35
+
36
+ const dateObj = new Date(isoString);
37
+ return !isNaN(dateObj.getTime());
38
+ }
39
+
40
+ // If it's already in ISO-like format, just check directly
41
+ const dateObject = new Date(dateTimeString);
42
+ return !isNaN(dateObject.getTime());
43
+ }
44
+
45
+ export function convertStringToISODate(dateString: string, format: DateFormat = "yyyy-MM-dd"): string | null {
46
+ const formatRegex: RegExp = buildDateFormatRegex(format);
47
+ const match = formatRegex.exec(dateString);
48
+
49
+ if (!match?.groups) return null;
50
+
51
+ const { day, month, year } = match.groups;
52
+
53
+ const d = parseInt(day, 10);
54
+ const m = parseInt(month, 10) - 1;
55
+ let y = parseInt(year, 10);
56
+
57
+ if (year.length === 2) {
58
+ y += y >= 70 ? 1900 : 2000;
59
+ }
60
+
61
+ const date = new Date(y, m, d);
62
+
63
+ if (date.getFullYear() !== y || date.getMonth() !== m || date.getDate() !== d) {
64
+ return null;
65
+ }
66
+
67
+ return date.toISOString();
68
+ }
69
+
70
+ /**
71
+ * Converts a date-time string (in a given format) to an ISO 8601 string.
72
+ * Returns null if invalid or if the string doesn't match the format.
73
+ */
74
+ export function convertStringToISODateTime(
75
+ dateTimeString: string,
76
+ format: DateTimeFormat = "yyyy-MM-dd'T'HH:mm"
77
+ ): string | null {
78
+ const formatRegex: RegExp = buildDateTimeFormatRegex(format);
79
+ const match = formatRegex.exec(dateTimeString.trim());
80
+
81
+ if (!match?.groups) return null;
82
+
83
+ const { day, month, year, hour, minute, second, period } = match.groups;
84
+
85
+ const d = parseInt(day, 10);
86
+ const m = parseInt(month, 10) - 1;
87
+ let y = parseInt(year, 10);
88
+ let h = parseInt(hour ?? '0', 10);
89
+ const min = parseInt(minute ?? '0', 10);
90
+ const s = parseInt(second ?? '0', 10);
91
+
92
+ // Handle two-digit years
93
+ if (year.length === 2) {
94
+ y += y >= 70 ? 1900 : 2000;
95
+ }
96
+
97
+ // Handle AM/PM
98
+ if (period) {
99
+ const p = period.toUpperCase();
100
+ if (p === 'PM' && h < 12) h += 12;
101
+ if (p === 'AM' && h === 12) h = 0;
102
+ }
103
+
104
+ const date = new Date(y, m, d, h, min, s);
105
+
106
+ // Validation: ensure components didn’t overflow
107
+ if (
108
+ date.getFullYear() !== y ||
109
+ date.getMonth() !== m ||
110
+ date.getDate() !== d ||
111
+ date.getHours() !== h ||
112
+ date.getMinutes() !== min ||
113
+ date.getSeconds() !== s
114
+ ) {
115
+ return null;
116
+ }
117
+
118
+ return date.toISOString();
119
+ }
120
+
121
+ export function convertStringToDate(dateString: string, format: DateFormat = "yyyy-MM-dd"): Date | null {
122
+ const formatRegex: RegExp = buildDateFormatRegex(format);
123
+ const match = formatRegex.exec(dateString);
124
+
125
+ if (!match?.groups) return null;
126
+
127
+ const { day, month, year } = match.groups;
128
+
129
+ const d = parseInt(day, 10);
130
+ const m = parseInt(month, 10) - 1;
131
+ let y = parseInt(year, 10);
132
+
133
+ if (year.length === 2) {
134
+ y += y >= 70 ? 1900 : 2000;
135
+ }
136
+
137
+ return new Date(y, m, d);
138
+ }
139
+
140
+ export function convertStringToTime(
141
+ timeString: string,
142
+ format: TimeFormat = "HH:mm"
143
+ ): number | null {
144
+ const regex = buildTimeFormatRegex(format);
145
+ const match = regex.exec(timeString);
146
+
147
+ if (!match?.groups) return null;
148
+
149
+ let hours = 0;
150
+ const minutes = match.groups["minute"] ? parseInt(match.groups["minute"], 10) : 0;
151
+ const seconds = match.groups["second"] ? parseInt(match.groups["second"], 10) : 0;
152
+
153
+ if (match.groups["hour24"]) {
154
+ hours = parseInt(match.groups["hour24"], 10);
155
+ } else if (match.groups["hour12"]) {
156
+ hours = parseInt(match.groups["hour12"], 10);
157
+ const period = match.groups["period"]?.toUpperCase();
158
+ if (period) {
159
+ if (hours === 12) hours = period === "AM" ? 0 : 12;
160
+ else if (period === "PM") hours += 12;
161
+ }
162
+ }
163
+
164
+ return hours * 3600 + minutes * 60 + seconds;
165
+ }
166
+
167
+ /**
168
+ * Converts a datetime string (based on a given format) into a Date object.
169
+ * Returns null if parsing fails or values are invalid.
170
+ */
171
+ export function convertStringToDateTime(
172
+ dateTimeString: string,
173
+ format: DateTimeFormat = "yyyy-MM-dd'T'HH:mm"
174
+ ): Date | null {
175
+ const regex = buildDateTimeFormatRegex(format);
176
+ const match = regex.exec(dateTimeString.trim());
177
+
178
+ if (!match?.groups) return null;
179
+
180
+ const separatorMatch = format.match(/( |T)/);
181
+ let datePart: string = format;
182
+ let timePart: string | null = null;
183
+
184
+ if (separatorMatch) {
185
+ const separator = separatorMatch[0];
186
+ const parts = format.split(separator);
187
+ datePart = parts[0];
188
+ timePart = parts[1] ?? null;
189
+ }
190
+
191
+ const dateString = timePart
192
+ ? dateTimeString.split(/T| /)[0]
193
+ : dateTimeString;
194
+
195
+ const timeString = timePart
196
+ ? dateTimeString.split(/T| /)[1]
197
+ : undefined;
198
+
199
+ const date = convertStringToDate(dateString, datePart as any);
200
+ if (!date) return null;
201
+
202
+ let totalSeconds = 0;
203
+ if (timeString && timePart) {
204
+ const seconds = convertStringToTime(timeString, timePart as any);
205
+ if (seconds == null) return null;
206
+ totalSeconds = seconds;
207
+ }
208
+
209
+ const hours = Math.floor(totalSeconds / 3600);
210
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
211
+ const seconds = totalSeconds % 60;
212
+
213
+ date.setHours(hours, minutes, seconds, 0);
214
+
215
+ return date;
216
+ }
217
+
218
+ /**
219
+ * Builds a regex to validate date strings based on the provided format.
220
+ * Supports formats like "dd/MM/yyyy", "MM-dd-yyyy", "yyyy.MM.dd", etc.
221
+ * @param format The date format string
222
+ */
223
+ export function buildDateFormatRegex(format: string): RegExp {
224
+ const escaped = format.replace(/[-/.]/g, m => `\\${m}`);
225
+
226
+ const pattern = escaped
227
+ .replace("dd", "(?<day>\\d{2})")
228
+ .replace("MM", "(?<month>\\d{2})")
229
+ .replace("yyyy", "(?<year>\\d{4})")
230
+ .replace("yy", "(?<year>\\d{2})");
231
+
232
+ return new RegExp(`^${pattern}$`);
233
+ }
234
+
235
+ /**
236
+ * Builds a regex to validate time strings based on the provided format.
237
+ * Supports formats like "HH:mm", "hh:mm a", "HH:mm:ss", etc.
238
+ * @param format The time format string
239
+ */
240
+ export function buildTimeFormatRegex(format: string): RegExp {
241
+ const escaped = format.replace(/[-:. ]/g, m => `\\${m}`);
242
+ const pattern = escaped
243
+ .replace("HH", "(?<hour24>[01]?[0-9]|2[0-3])")
244
+ .replace("hh", "(?<hour12>0?[1-9]|1[0-2])")
245
+ .replace("mm", "(?<minute>[0-5]?[0-9])")
246
+ .replace("ss", "(?<second>[0-5]?[0-9])")
247
+ .replace("a", "(?<period>AM|PM|am|pm)");
248
+
249
+ return new RegExp(`^${pattern}$`);
250
+ }
251
+ /**
252
+ * Builds a regex to match full date-time strings.
253
+ * Handles both date and time tokens in a single format string (with optional AM/PM).
254
+ */
255
+ export function buildDateTimeFormatRegex(format: string): RegExp {
256
+ // Try to find a separator between date and time parts
257
+ const separatorMatch = format.match(/( |T)/);
258
+ if (!separatorMatch) {
259
+ // Fallback: only date
260
+ return buildDateFormatRegex(format);
261
+ }
262
+
263
+ const separator = separatorMatch[0];
264
+
265
+ // Handle formats like "MM/dd/yyyy hh:mm a" or "dd/MM/yyyy HH:mm:ss"
266
+ const firstSplit = format.split(separator);
267
+
268
+ // If there's an AM/PM part, join everything after the first split back together
269
+ const datePart = firstSplit[0];
270
+ const timePart = firstSplit.slice(1).join(separator);
271
+
272
+ const dateRegexSource = buildDateFormatRegex(datePart)
273
+ .source.replace(/^\^|\$$/g, '');
274
+ const timeRegexSource = buildTimeFormatRegex(timePart)
275
+ .source.replace(/^\^|\$$/g, '');
276
+
277
+ const fullPattern = `^${dateRegexSource}${separator}${timeRegexSource}$`;
278
+ return new RegExp(fullPattern);
279
+ }
280
+
281
+ /**
282
+ * Converts a Date object into a string according to the specified format.
283
+ */
284
+ export function formatDateToString(date: Date, format: DateFormat = 'yyyy-MM-dd'): string {
285
+ const day = String(date.getDate()).padStart(2, "0");
286
+ const month = String(date.getMonth() + 1).padStart(2, "0");
287
+ const year = String(date.getFullYear());
288
+
289
+ const shortMonthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
290
+ const longMonthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
291
+
292
+ return format
293
+ .replace("dd", day)
294
+ .replace("MM", month)
295
+ .replace("yyyy", year)
296
+ .replace("yy", year.slice(-2))
297
+ .replace("MMM", shortMonthNames[date.getMonth()])
298
+ .replace("MMMM", longMonthNames[date.getMonth()]);
299
+ }
300
+
301
+ export function formatDateTimeToString(
302
+ date: Date,
303
+ format: DateTimeFormat = "yyyy-MM-dd'T'HH:mm"
304
+ ): string {
305
+ const day = String(date.getDate()).padStart(2, "0");
306
+ const month = String(date.getMonth() + 1).padStart(2, "0");
307
+ const year = String(date.getFullYear());
308
+
309
+ const hours24 = String(date.getHours()).padStart(2, "0");
310
+ const hours12Raw = date.getHours() % 12 || 12;
311
+ const hours12 = String(hours12Raw).padStart(2, "0");
312
+ const minutes = String(date.getMinutes()).padStart(2, "0");
313
+ const seconds = String(date.getSeconds()).padStart(2, "0");
314
+ const ampm = date.getHours() >= 12 ? "PM" : "AM";
315
+
316
+ const shortMonthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
317
+ const longMonthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
318
+
319
+ return format
320
+ // Date replacements
321
+ .replace("dd", day)
322
+ .replace("MM", month)
323
+ .replace("yyyy", year)
324
+ .replace("yy", year.slice(-2))
325
+ .replace("MMM", shortMonthNames[date.getMonth()])
326
+ .replace("MMMM", longMonthNames[date.getMonth()])
327
+ // Time replacements
328
+ .replace("HH", hours24)
329
+ .replace("hh", hours12)
330
+ .replace("mm", minutes)
331
+ .replace("ss", seconds)
332
+ .replace("a", ampm);
333
+ }
334
+
335
+ /** Extracts AM/PM from a time string and returns the core time without it */
336
+ export function extractMeridiem(time: string): { coreTime: string; meridiem?: 'AM' | 'PM' } {
337
+ const meridiemRegex = /\s?(AM|PM)$/i;
338
+ const match = meridiemRegex.exec(time.trim());
339
+ if (match) {
340
+ return { coreTime: time.replace(meridiemRegex, '').trim(), meridiem: match[1].toUpperCase() as 'AM' | 'PM' };
341
+ }
342
+ return { coreTime: time.trim() };
343
+ }
344
+
345
+ /** Safely parse a number and clamp it to a range, or return NaN if invalid */
346
+ export function parseAndClamp(value?: string, min = 0, max = 59): number {
347
+ const num = value ? Number(value) : NaN;
348
+ return !isNaN(num) ? Math.min(Math.max(num, min), max) : NaN;
349
+ }
350
+
351
+ /** Pads a number with leading zero, or returns placeholder if NaN */
352
+ export function padOrPlaceholder(num: number, placeholder: string): string {
353
+ return !isNaN(num) ? String(num).padStart(2, '0') : placeholder;
354
+ }
355
+
356
+ /** Determine meridiem if not explicitly provided */
357
+ export function resolveMeridiem(meridiem?: 'AM' | 'PM', hours?: number): 'AM' | 'PM' {
358
+ if (meridiem) return meridiem;
359
+ if (hours !== undefined && !isNaN(hours)) return hours >= 12 ? 'PM' : 'AM';
360
+ return 'AM';
361
+ }
362
+
363
+ /** Main function refactored to use small utilities */
364
+ export function formatTimeToString(
365
+ time: string,
366
+ format: TimeFormat = 'HH:mm',
367
+ partialTime?: InputTimePartial
368
+ ): string {
369
+ if (!time) return '';
370
+
371
+ const { coreTime, meridiem } = extractMeridiem(time);
372
+ const segments = coreTime.split(':');
373
+
374
+ const hours = parseAndClamp(segments[0], 0, 23);
375
+ const minutes = parseAndClamp(segments[1], 0, 59);
376
+ const seconds = parseAndClamp(segments[2], 0, 59);
377
+
378
+ const h = padOrPlaceholder(hours, 'HH');
379
+ const m = padOrPlaceholder(minutes, 'mm');
380
+ const s = padOrPlaceholder(seconds, 'ss');
381
+ const a = resolveMeridiem(meridiem, hours);
382
+
383
+ if (partialTime) {
384
+ switch (partialTime) {
385
+ case 'hour': return h;
386
+ case 'minute': return m;
387
+ case 'second': return s;
388
+ case 'meridiem': return a;
389
+ }
390
+ }
391
+
392
+ return format
393
+ .replace('HH', h)
394
+ .replace('hh', h)
395
+ .replace('mm', m)
396
+ .replace('ss', s)
397
+ .replace('a', a);
398
+ }
399
+
400
+ /**
401
+ * Converts a time string into total minutes.
402
+ * Supports optional seconds and AM/PM.
403
+ *
404
+ * @param time Time string ("HH:mm", "HH:mm:ss", or "hh:mm AM/PM").
405
+ * @returns Total minutes (including fractional for seconds), or null if invalid.
406
+ */
407
+ export function parseTimeToMinutes(time: string): number | null {
408
+ const regex = /^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM)?$/i;
409
+ const match = regex.exec(time);
410
+
411
+ if (!match) return null;
412
+
413
+ let hours = parseInt(match[1], 10);
414
+ const minutes = parseInt(match[2], 10);
415
+ const seconds = match[3] ? parseInt(match[3], 10) : 0;
416
+ const period = match[4]?.toUpperCase();
417
+
418
+ if (period) {
419
+ if (hours === 12) {
420
+ hours = period === "AM" ? 0 : 12;
421
+ } else if (period === "PM") {
422
+ hours += 12;
423
+ }
424
+ }
425
+
426
+ return hours * 60 + minutes + seconds / 60;
427
+ }
428
+
429
+ /**
430
+ * Determines if the given time format uses a 12-hour (meridiem) format.
431
+ * Example: "hh:mm a" → true, "HH:mm" → false
432
+ */
433
+ export function isMeridiemFormat(format?: TimeFormat | null): boolean {
434
+ if (!format) return false;
435
+ return format.includes('a') || format.includes('A');
436
+ }
437
+
438
+ /**
439
+ * Extracts and returns the time format part of a DateTime format string.
440
+ * Example: "dd/MM/yyyy HH:mm" → "HH:mm"
441
+ */
442
+ export function extractTimeFormat(dateTimeFormat: string): TimeFormat | null {
443
+ const regex = /\b[Hh]{1,2}:mm(?::ss)?(?:\s?[aA])?\b/;
444
+ const match = regex.exec(dateTimeFormat);
445
+
446
+ if (!match) return null;
447
+
448
+ const timePart = match[0].trim();
449
+
450
+ const allowedFormats: TimeFormat[] = ['HH:mm', 'HH:mm:ss', 'hh:mm a', 'hh:mm:ss a'];
451
+ return allowedFormats.includes(timePart as TimeFormat) ? (timePart as TimeFormat) : null;
452
+ }
453
+
454
+ /**
455
+ * Calculates the rotation angle (in degrees) for an hour hand on a 12-hour clock.
456
+ *
457
+ * @param hour - The hour value as a string (0-23 or 0-12).
458
+ * @returns The rotation angle in degrees, where 0 degrees is at 12 o'clock.
459
+ */
460
+ export function calculateHourDegree(hour: string): number {
461
+ const num = Number.parseInt(hour, 10);
462
+ return ((num % 12) * 30 - 90);
463
+ }
464
+
465
+ /**
466
+ * Calculates the rotation angle (in degrees) for a minute hand on a clock.
467
+ *
468
+ * @param minute - The minute value as a string (0-59).
469
+ * @returns The rotation angle in degrees, where 0 degrees is at 12 o'clock.
470
+ */
471
+ export function calculateMinuteDegree(minute: string): number {
472
+ const num = Number.parseInt(minute, 10);
473
+ return (num * 6 - 90);
474
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Normalizes the value of an <input type="number">.
3
+ *
4
+ * - Returns a valid number if the input contains a numeric value
5
+ * - Returns null if the input is empty or not a valid number
6
+ *
7
+ * This helper ensures consistency between the raw input value
8
+ * and the form control value, preventing unintended NaN values.
9
+ *
10
+ * @param input The HTML input element of type "number"
11
+ * @returns number | null
12
+ */
13
+ export function normalizeNumber(input: HTMLInputElement): number | null {
14
+ const num = input.valueAsNumber;
15
+ return isNaN(num) ? null : num;
16
+ }