@verisoft/ui-primeng 19.0.1-1 → 20.1.0

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 (280) hide show
  1. package/.eslintrc.json +43 -0
  2. package/README.md +377 -3
  3. package/assets/.gitkeep +0 -0
  4. package/assets/sass/main.scss +9 -26
  5. package/assets/sass/themes/_verisoft_theme.scss +2 -0
  6. package/assets/sass/vendors/_bootstrap.scss +2 -2
  7. package/assets/sass/vendors/_primeng.scss +1 -2
  8. package/jest.config.ts +22 -0
  9. package/ng-package.json +14 -0
  10. package/package.json +14 -27
  11. package/project.json +36 -0
  12. package/{index.d.ts → src/index.ts} +4 -0
  13. package/src/lib/components/breadcrumb/breadcrumb.component.html +11 -0
  14. package/src/lib/components/breadcrumb/breadcrumb.component.scss +18 -0
  15. package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +21 -0
  16. package/src/lib/components/breadcrumb/breadcrumb.component.stories.ts +36 -0
  17. package/src/lib/components/breadcrumb/breadcrumb.component.ts +27 -0
  18. package/src/lib/components/breadcrumb/breadcrumb.pipe.ts +13 -0
  19. package/src/lib/components/button/button-severity.pipe.ts +20 -0
  20. package/src/lib/components/button/button.component.html +20 -0
  21. package/src/lib/components/button/button.component.scss +0 -0
  22. package/src/lib/components/button/button.component.spec.ts +21 -0
  23. package/src/lib/components/button/button.component.ts +49 -0
  24. package/src/lib/components/calendar/calendar.component.html +53 -0
  25. package/src/lib/components/calendar/calendar.component.scss +0 -0
  26. package/src/lib/components/calendar/calendar.component.spec.ts +21 -0
  27. package/src/lib/components/calendar/calendar.component.ts +70 -0
  28. package/src/lib/components/checkbox/checkbox.component.html +20 -0
  29. package/src/lib/components/checkbox/checkbox.component.scss +15 -0
  30. package/src/lib/components/checkbox/checkbox.component.spec.ts +21 -0
  31. package/src/lib/components/checkbox/checkbox.component.stories.ts +72 -0
  32. package/src/lib/components/checkbox/checkbox.component.ts +46 -0
  33. package/src/lib/components/confirm-dialog/confirm-dialog.component.html +51 -0
  34. package/src/lib/components/confirm-dialog/confirm-dialog.component.scss +3 -0
  35. package/src/lib/components/confirm-dialog/confirm-dialog.component.spec.ts +21 -0
  36. package/src/lib/components/confirm-dialog/confirm-dialog.component.stories.ts +74 -0
  37. package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +73 -0
  38. package/src/lib/components/dropdown/dropdown.component.html +93 -0
  39. package/src/lib/components/dropdown/dropdown.component.scss +16 -0
  40. package/src/lib/components/dropdown/dropdown.component.spec.ts +21 -0
  41. package/src/lib/components/dropdown/dropdown.component.ts +139 -0
  42. package/src/lib/components/dropdown-button/dropdown-button.component.html +1 -0
  43. package/src/lib/components/dropdown-button/dropdown-button.component.ts +20 -0
  44. package/src/lib/components/dropdown-button/index.ts +1 -0
  45. package/src/lib/components/errors/error.component.html +7 -0
  46. package/src/lib/components/errors/error.component.scss +3 -0
  47. package/src/lib/components/errors/error.component.ts +34 -0
  48. package/src/lib/components/errors/index.ts +1 -0
  49. package/src/lib/components/feature-list/directives/feature-list-column.directive.ts +32 -0
  50. package/src/lib/components/feature-list/directives/feature-list-filter-field.directive.ts +8 -0
  51. package/src/lib/components/feature-list/feature-list-filter.pipe.ts +21 -0
  52. package/src/lib/components/feature-list/feature-list-page.component.ts +32 -0
  53. package/src/lib/components/feature-list/feature-list-page.model.ts +42 -0
  54. package/src/lib/components/feature-list/feature-list.component.html +59 -0
  55. package/src/lib/components/feature-list/feature-list.component.scss +10 -0
  56. package/src/lib/components/feature-list/feature-list.component.ts +341 -0
  57. package/src/lib/components/filter/directives/filter-field.directive.ts +34 -0
  58. package/src/lib/components/filter/filter.component.html +68 -0
  59. package/src/lib/components/filter/filter.component.scss +0 -0
  60. package/src/lib/components/filter/filter.component.spec.ts +21 -0
  61. package/src/lib/components/filter/filter.component.stories.ts +23 -0
  62. package/src/lib/components/filter/filter.component.ts +281 -0
  63. package/src/lib/components/filter/filter.model.ts +18 -0
  64. package/src/lib/components/form-field/form-field.component.html +42 -0
  65. package/src/lib/components/form-field/form-field.component.scss +0 -0
  66. package/src/lib/components/form-field/form-field.component.spec.ts +21 -0
  67. package/src/lib/components/form-field/form-field.component.stories.ts +69 -0
  68. package/src/lib/components/form-field/form-field.component.ts +37 -0
  69. package/src/lib/components/header/header.component.html +84 -0
  70. package/src/lib/components/header/header.component.scss +0 -0
  71. package/src/lib/components/header/header.component.spec.ts +21 -0
  72. package/src/lib/components/header/header.component.stories.ts +24 -0
  73. package/src/lib/components/header/header.component.ts +65 -0
  74. package/src/lib/components/header/services/header-provider.service.ts +15 -0
  75. package/src/lib/components/icon/icon.component.html +2 -0
  76. package/src/lib/components/icon/icon.component.scss +51 -0
  77. package/src/lib/components/icon/icon.component.ts +86 -0
  78. package/src/lib/components/icon/index.ts +2 -0
  79. package/src/lib/components/input-group/input-group.component.html +34 -0
  80. package/src/lib/components/input-group/input-group.component.spec.ts +21 -0
  81. package/src/lib/components/input-group/input-group.component.ts +58 -0
  82. package/src/lib/components/loader/loader.component.html +5 -0
  83. package/src/lib/components/loader/loader.component.scss +0 -0
  84. package/src/lib/components/loader/loader.component.spec.ts +21 -0
  85. package/src/lib/components/loader/loader.component.ts +16 -0
  86. package/src/lib/components/multiselect/multiselect.component.html +67 -0
  87. package/src/lib/components/multiselect/multiselect.component.scss +0 -0
  88. package/src/lib/components/multiselect/multiselect.component.spec.ts +21 -0
  89. package/src/lib/components/multiselect/multiselect.component.ts +120 -0
  90. package/src/lib/components/number-input/number-input.component.html +22 -0
  91. package/src/lib/components/number-input/number-input.component.spec.ts +21 -0
  92. package/src/lib/components/number-input/number-input.component.ts +55 -0
  93. package/src/lib/components/page-header/page-header.component.html +35 -0
  94. package/src/lib/components/page-header/page-header.component.scss +0 -0
  95. package/src/lib/components/page-header/page-header.component.spec.ts +21 -0
  96. package/src/lib/components/page-header/page-header.component.ts +31 -0
  97. package/src/lib/components/password/password.component.html +24 -0
  98. package/src/lib/components/password/password.component.scss +0 -0
  99. package/src/lib/components/password/password.component.spec.ts +21 -0
  100. package/src/lib/components/password/password.component.ts +56 -0
  101. package/src/lib/components/radiobutton/radiobutton.component.html +34 -0
  102. package/src/lib/components/radiobutton/radiobutton.component.scss +6 -0
  103. package/src/lib/components/radiobutton/radiobutton.component.spec.ts +21 -0
  104. package/src/lib/components/radiobutton/radiobutton.component.stories.ts +71 -0
  105. package/src/lib/components/radiobutton/radiobutton.component.ts +61 -0
  106. package/src/lib/components/section/section.component.html +25 -0
  107. package/src/lib/components/section/section.component.scss +0 -0
  108. package/src/lib/components/section/section.component.spec.ts +21 -0
  109. package/src/lib/components/section/section.component.ts +31 -0
  110. package/src/lib/components/shared-components/.eslintrc.json +42 -0
  111. package/src/lib/components/shared-components/action-button-group/action-button-group.component.html +25 -0
  112. package/src/lib/components/shared-components/action-button-group/action-button-group.component.scss +0 -0
  113. package/src/lib/components/shared-components/action-button-group/action-button-group.component.spec.ts +21 -0
  114. package/src/lib/components/shared-components/action-button-group/action-button-group.component.ts +111 -0
  115. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.html +10 -0
  116. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.scss +0 -0
  117. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.spec.ts +21 -0
  118. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.ts +69 -0
  119. package/src/lib/components/shared-components/dynamic-component/dynamic-component-factory.service.ts +142 -0
  120. package/src/lib/components/shared-components/dynamic-component/dynamic-component.component.ts +56 -0
  121. package/{lib/components/shared-components/dynamic-component/index.d.ts → src/lib/components/shared-components/dynamic-component/index.ts} +2 -2
  122. package/src/lib/components/shared-components/generic-field/generic-field.component.html +98 -0
  123. package/src/lib/components/shared-components/generic-field/generic-field.component.spec.ts +21 -0
  124. package/src/lib/components/shared-components/generic-field/generic-field.component.ts +90 -0
  125. package/{lib/components/shared-components/generic-field/index.d.ts → src/lib/components/shared-components/generic-field/index.ts} +1 -1
  126. package/src/lib/components/shared-components/generic-form/generic-form.component.html +46 -0
  127. package/src/lib/components/shared-components/generic-form/generic-form.component.spec.ts +21 -0
  128. package/src/lib/components/shared-components/generic-form/generic-form.component.ts +56 -0
  129. package/src/lib/components/shared-components/generic-form/generic-form.model.spec.ts +82 -0
  130. package/src/lib/components/shared-components/generic-form/generic-form.model.ts +68 -0
  131. package/{lib/components/shared-components/generic-form/index.d.ts → src/lib/components/shared-components/generic-form/index.ts} +2 -2
  132. package/{lib/components/shared-components/index.d.ts → src/lib/components/shared-components/index.ts} +4 -6
  133. package/src/lib/components/side-menu/side-menu.component.html +53 -0
  134. package/src/lib/components/side-menu/side-menu.component.scss +0 -0
  135. package/src/lib/components/side-menu/side-menu.component.spec.ts +21 -0
  136. package/src/lib/components/side-menu/side-menu.component.ts +96 -0
  137. package/src/lib/components/side-menu/side-menu.module.ts +66 -0
  138. package/src/lib/components/slider/slider.component.html +19 -0
  139. package/src/lib/components/slider/slider.component.spec.ts +21 -0
  140. package/src/lib/components/slider/slider.component.ts +56 -0
  141. package/src/lib/components/snackbar/services/snackbar.service.ts +45 -0
  142. package/src/lib/components/snackbar/snackbar.component.html +3 -0
  143. package/src/lib/components/snackbar/snackbar.component.scss +0 -0
  144. package/src/lib/components/snackbar/snackbar.component.spec.ts +21 -0
  145. package/src/lib/components/snackbar/snackbar.component.stories.ts +70 -0
  146. package/src/lib/components/snackbar/snackbar.component.ts +25 -0
  147. package/src/lib/components/stepper/stepper.component.html +35 -0
  148. package/src/lib/components/stepper/stepper.component.spec.ts +21 -0
  149. package/src/lib/components/stepper/stepper.component.ts +39 -0
  150. package/src/lib/components/switch/switch.component.html +18 -0
  151. package/src/lib/components/switch/switch.component.scss +0 -0
  152. package/src/lib/components/switch/switch.component.spec.ts +21 -0
  153. package/src/lib/components/switch/switch.component.stories.ts +65 -0
  154. package/src/lib/components/switch/switch.component.ts +52 -0
  155. package/src/lib/components/tab-view/tab-view-item.component.ts +22 -0
  156. package/src/lib/components/tab-view/tab-view.component.html +41 -0
  157. package/src/lib/components/tab-view/tab-view.component.ts +55 -0
  158. package/src/lib/components/table/table-filter.pipe.ts +59 -0
  159. package/src/lib/components/table/table.component.html +127 -0
  160. package/src/lib/components/table/table.component.scss +11 -0
  161. package/src/lib/components/table/table.component.spec.ts +21 -0
  162. package/src/lib/components/table/table.component.stories.ts +55 -0
  163. package/src/lib/components/table/table.component.ts +288 -0
  164. package/src/lib/components/table/table.models.ts +26 -0
  165. package/src/lib/components/tag/index.ts +2 -0
  166. package/src/lib/components/tag/tag.component.html +12 -0
  167. package/src/lib/components/tag/tag.component.scss +33 -0
  168. package/src/lib/components/tag/tag.component.ts +83 -0
  169. package/src/lib/components/textarea/textarea.component.html +40 -0
  170. package/src/lib/components/textarea/textarea.component.scss +5 -0
  171. package/src/lib/components/textarea/textarea.component.spec.ts +21 -0
  172. package/src/lib/components/textarea/textarea.component.stories.ts +98 -0
  173. package/src/lib/components/textarea/textarea.component.ts +62 -0
  174. package/src/lib/components/textfield/textfield.component.html +82 -0
  175. package/src/lib/components/textfield/textfield.component.scss +23 -0
  176. package/src/lib/components/textfield/textfield.component.spec.ts +21 -0
  177. package/src/lib/components/textfield/textfield.component.stories.ts +85 -0
  178. package/src/lib/components/textfield/textfield.component.ts +68 -0
  179. package/src/lib/components/tooltip/index.ts +1 -0
  180. package/src/lib/components/tooltip/tooltip.component.html +3 -0
  181. package/src/lib/components/tooltip/tooltip.component.ts +17 -0
  182. package/src/lib/icons.ts +36 -0
  183. package/src/lib/interceptors/http-error-message.interceptor.ts +35 -0
  184. package/src/lib/pages/not-found-page/not-found-page.component.html +26 -0
  185. package/src/lib/pages/not-found-page/not-found-page.component.scss +0 -0
  186. package/src/lib/pages/not-found-page/not-found-page.component.spec.ts +21 -0
  187. package/src/lib/pages/not-found-page/not-found-page.component.ts +16 -0
  188. package/src/tab-view.ts +1 -0
  189. package/src/test-setup.ts +8 -0
  190. package/tsconfig.json +29 -0
  191. package/tsconfig.lib.json +18 -0
  192. package/tsconfig.lib.prod.json +9 -0
  193. package/tsconfig.spec.json +16 -0
  194. package/fesm2022/verisoft-ui-primeng.mjs +0 -2880
  195. package/fesm2022/verisoft-ui-primeng.mjs.map +0 -1
  196. package/lib/components/breadcrumb/breadcrumb.component.d.ts +0 -6
  197. package/lib/components/breadcrumb/breadcrumb.pipe.d.ts +0 -9
  198. package/lib/components/button/button-severity.pipe.d.ts +0 -9
  199. package/lib/components/button/button.component.d.ts +0 -20
  200. package/lib/components/calendar/calendar.component.d.ts +0 -17
  201. package/lib/components/checkbox/checkbox.component.d.ts +0 -10
  202. package/lib/components/confirm-dialog/confirm-dialog.component.d.ts +0 -15
  203. package/lib/components/dropdown/dropdown.component.d.ts +0 -38
  204. package/lib/components/dropdown-button/dropdown-button.component.d.ts +0 -14
  205. package/lib/components/dropdown-button/index.d.ts +0 -1
  206. package/lib/components/errors/error.component.d.ts +0 -16
  207. package/lib/components/errors/index.d.ts +0 -1
  208. package/lib/components/form-field/form-field.component.d.ts +0 -12
  209. package/lib/components/header/header.component.d.ts +0 -23
  210. package/lib/components/header/services/header-provider.service.d.ts +0 -10
  211. package/lib/components/input-group/input-group.component.d.ts +0 -9
  212. package/lib/components/loader/loader.component.d.ts +0 -6
  213. package/lib/components/multiselect/multiselect.component.d.ts +0 -34
  214. package/lib/components/number-input/number-input.component.d.ts +0 -14
  215. package/lib/components/page-header/page-header.component.d.ts +0 -10
  216. package/lib/components/password/password.component.d.ts +0 -11
  217. package/lib/components/radiobutton/radiobutton.component.d.ts +0 -10
  218. package/lib/components/section/section.component.d.ts +0 -12
  219. package/lib/components/shared-components/action-button-group/action-button-group.component.d.ts +0 -28
  220. package/lib/components/shared-components/action-button-group/components/action-button/action-button.component.d.ts +0 -24
  221. package/lib/components/shared-components/dynamic-component/dynamic-component-factory.service.d.ts +0 -17
  222. package/lib/components/shared-components/dynamic-component/dynamic-component.component.d.ts +0 -16
  223. package/lib/components/shared-components/feature-list/directives/feature-list-column.directive.d.ts +0 -10
  224. package/lib/components/shared-components/feature-list/directives/feature-list-filter-field.directive.d.ts +0 -6
  225. package/lib/components/shared-components/feature-list/feature-list-filter.pipe.d.ts +0 -9
  226. package/lib/components/shared-components/feature-list/feature-list-page.component.d.ts +0 -9
  227. package/lib/components/shared-components/feature-list/feature-list-page.model.d.ts +0 -23
  228. package/lib/components/shared-components/feature-list/feature-list.component.d.ts +0 -62
  229. package/lib/components/shared-components/filter/directives/filter-field.directive.d.ts +0 -20
  230. package/lib/components/shared-components/filter/filter.component.d.ts +0 -53
  231. package/lib/components/shared-components/filter/filter.model.d.ts +0 -2
  232. package/lib/components/shared-components/generic-field/generic-field.component.d.ts +0 -28
  233. package/lib/components/shared-components/generic-form/generic-form.component.d.ts +0 -15
  234. package/lib/components/shared-components/generic-form/generic-form.model.d.ts +0 -4
  235. package/lib/components/side-menu/side-menu.component.d.ts +0 -27
  236. package/lib/components/side-menu/side-menu.module.d.ts +0 -13
  237. package/lib/components/slider/slider.component.d.ts +0 -12
  238. package/lib/components/snackbar/services/snackbar.service.d.ts +0 -12
  239. package/lib/components/snackbar/snackbar.component.d.ts +0 -9
  240. package/lib/components/stepper/stepper.component.d.ts +0 -17
  241. package/lib/components/switch/switch.component.d.ts +0 -9
  242. package/lib/components/tab-view/tab-view-item.component.d.ts +0 -12
  243. package/lib/components/tab-view/tab-view.component.d.ts +0 -17
  244. package/lib/components/table/table-filter.pipe.d.ts +0 -13
  245. package/lib/components/table/table.component.d.ts +0 -67
  246. package/lib/components/table/table.models.d.ts +0 -4
  247. package/lib/components/textarea/textarea.component.d.ts +0 -12
  248. package/lib/components/textfield/textfield.component.d.ts +0 -12
  249. package/lib/components/tooltip/index.d.ts +0 -1
  250. package/lib/components/tooltip/tooltip.component.d.ts +0 -10
  251. package/lib/icons.d.ts +0 -2
  252. package/lib/interceptors/http-error-message.interceptor.d.ts +0 -11
  253. /package/{lib/components/breadcrumb/index.d.ts → src/lib/components/breadcrumb/index.ts} +0 -0
  254. /package/{lib/components/button/index.d.ts → src/lib/components/button/index.ts} +0 -0
  255. /package/{lib/components/calendar/index.d.ts → src/lib/components/calendar/index.ts} +0 -0
  256. /package/{lib/components/checkbox/index.d.ts → src/lib/components/checkbox/index.ts} +0 -0
  257. /package/{lib/components/confirm-dialog/index.d.ts → src/lib/components/confirm-dialog/index.ts} +0 -0
  258. /package/{lib/components/dropdown/index.d.ts → src/lib/components/dropdown/index.ts} +0 -0
  259. /package/{lib/components/shared-components/feature-list/index.d.ts → src/lib/components/feature-list/index.ts} +0 -0
  260. /package/{lib/components/shared-components/filter/index.d.ts → src/lib/components/filter/index.ts} +0 -0
  261. /package/{lib/components/form-field/index.d.ts → src/lib/components/form-field/index.ts} +0 -0
  262. /package/{lib/components/header/index.d.ts → src/lib/components/header/index.ts} +0 -0
  263. /package/{lib/components/input-group/index.d.ts → src/lib/components/input-group/index.ts} +0 -0
  264. /package/{lib/components/loader/index.d.ts → src/lib/components/loader/index.ts} +0 -0
  265. /package/{lib/components/multiselect/index.d.ts → src/lib/components/multiselect/index.ts} +0 -0
  266. /package/{lib/components/number-input/index.d.ts → src/lib/components/number-input/index.ts} +0 -0
  267. /package/{lib/components/page-header/index.d.ts → src/lib/components/page-header/index.ts} +0 -0
  268. /package/{lib/components/password/index.d.ts → src/lib/components/password/index.ts} +0 -0
  269. /package/{lib/components/radiobutton/index.d.ts → src/lib/components/radiobutton/index.ts} +0 -0
  270. /package/{lib/components/section/index.d.ts → src/lib/components/section/index.ts} +0 -0
  271. /package/{lib/components/shared-components/action-button-group/index.d.ts → src/lib/components/shared-components/action-button-group/index.ts} +0 -0
  272. /package/{lib/components/side-menu/index.d.ts → src/lib/components/side-menu/index.ts} +0 -0
  273. /package/{lib/components/slider/index.d.ts → src/lib/components/slider/index.ts} +0 -0
  274. /package/{lib/components/snackbar/index.d.ts → src/lib/components/snackbar/index.ts} +0 -0
  275. /package/{lib/components/stepper/index.d.ts → src/lib/components/stepper/index.ts} +0 -0
  276. /package/{lib/components/switch/index.d.ts → src/lib/components/switch/index.ts} +0 -0
  277. /package/{lib/components/tab-view/index.d.ts → src/lib/components/tab-view/index.ts} +0 -0
  278. /package/{lib/components/table/index.d.ts → src/lib/components/table/index.ts} +0 -0
  279. /package/{lib/components/textarea/index.d.ts → src/lib/components/textarea/index.ts} +0 -0
  280. /package/{lib/components/textfield/index.d.ts → src/lib/components/textfield/index.ts} +0 -0
@@ -0,0 +1,69 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ EventEmitter,
5
+ inject,
6
+ Input,
7
+ OnChanges,
8
+ Output,
9
+ SimpleChanges,
10
+ } from '@angular/core';
11
+ import {
12
+ ACTION_BUTTON_GROUP_COMPONENT_TOKEN,
13
+ ActionButton,
14
+ ActionButtonGroupCore,
15
+ ControlSeverityType,
16
+ FieldSizeType,
17
+ } from '@verisoft/ui-core';
18
+ import { Observable, Subject } from 'rxjs';
19
+ import { Icons } from '../../../../../icons';
20
+ import { ButtonComponent } from '../../../../button';
21
+
22
+ @Component({
23
+ selector: 'v-action-button',
24
+ imports: [ButtonComponent],
25
+ templateUrl: './action-button.component.html',
26
+ styleUrl: './action-button.component.scss',
27
+ changeDetection: ChangeDetectionStrategy.OnPush
28
+ })
29
+ export class ActionButtonComponent implements ActionButton, OnChanges {
30
+ @Input() disabled = false;
31
+ @Input() toolTip?: string;
32
+ @Input() id?: string;
33
+ @Input() icon?: string;
34
+ @Input() outlined = false;
35
+ @Input() raised = false;
36
+ @Input() severity?: ControlSeverityType;
37
+ @Input() label?: string;
38
+ @Input() size?: FieldSizeType;
39
+ // eslint-disable-next-line @angular-eslint/no-output-native
40
+ @Output() click = new EventEmitter<MouseEvent>();
41
+
42
+ icons = Icons
43
+
44
+ private propertyChangeSubject = new Subject();
45
+
46
+ propertyChanged: Observable<unknown> =
47
+ this.propertyChangeSubject.asObservable();
48
+
49
+ buttonGroup: ActionButtonGroupCore | null = inject<ActionButtonGroupCore>(
50
+ ACTION_BUTTON_GROUP_COMPONENT_TOKEN,
51
+ {
52
+ optional: true,
53
+ }
54
+ );
55
+
56
+ ngOnChanges(changes: SimpleChanges): void {
57
+ const isValueChange = Object.keys(changes).some(
58
+ (x) => !changes[x].firstChange
59
+ );
60
+ if (isValueChange) {
61
+ this.propertyChangeSubject.next(null);
62
+ }
63
+ }
64
+
65
+ handleClick(event: MouseEvent) {
66
+ event.stopPropagation();
67
+ this.click.emit(event);
68
+ }
69
+ }
@@ -0,0 +1,142 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import {
3
+ Injectable,
4
+ ViewContainerRef,
5
+ Type,
6
+ ComponentFactoryResolver,
7
+ Injector,
8
+ ComponentRef,
9
+ ComponentFactory,
10
+ OnChanges,
11
+ SimpleChanges,
12
+ SimpleChange,
13
+ EventEmitter,
14
+ OnDestroy,
15
+ } from '@angular/core';
16
+ import { ExtendedComponent } from '@verisoft/ui-core';
17
+ import { Subscription } from 'rxjs';
18
+
19
+ @Injectable({
20
+ providedIn: 'root',
21
+ })
22
+ export class DynamicComponentFactoryService implements OnDestroy {
23
+ constructor(private componentFactoryResolver: ComponentFactoryResolver) { }
24
+
25
+ ngOnDestroy(): void {
26
+ this.unsubscribeComponentEvents(this);
27
+ }
28
+
29
+ async createDynamicComponent<TComponent>(
30
+ componentType: Type<TComponent>,
31
+ viewContainerRef: ViewContainerRef,
32
+ inputs: ExtendedComponent<TComponent>,
33
+ injector: Injector | undefined = undefined
34
+ ) {
35
+ const componentFactory =
36
+ this.componentFactoryResolver.resolveComponentFactory(componentType);
37
+ viewContainerRef.clear();
38
+ const component = viewContainerRef.createComponent(
39
+ componentFactory,
40
+ undefined,
41
+ injector
42
+ );
43
+ this.setComponentDataInt(componentFactory, component, inputs);
44
+ this.fireComponentEvents(component.instance, inputs);
45
+ return component;
46
+ }
47
+
48
+ setComponentData<TComponent>(
49
+ component: ComponentRef<TComponent>,
50
+ inputs: Partial<TComponent>
51
+ ) {
52
+ const factory = this.componentFactoryResolver.resolveComponentFactory(
53
+ component.componentType
54
+ );
55
+
56
+ this.setComponentDataInt(factory, component, inputs);
57
+ }
58
+
59
+ private unsubscribeComponentEvents<TComponent>(instance: TComponent) {
60
+ const subscriptionStoreKey = '__outputSubscriptions__';
61
+ const subscriptions = (instance as any)[subscriptionStoreKey] as Map<string, Subscription>;
62
+
63
+ if (subscriptions) {
64
+ subscriptions.forEach((sub) => sub.unsubscribe());
65
+ subscriptions.clear();
66
+ }
67
+ }
68
+
69
+ private fireComponentEvents<TComponent>(
70
+ instance: TComponent,
71
+ inputs: ExtendedComponent<TComponent>
72
+ ) {
73
+ if (!instance || typeof instance !== 'object') return;
74
+
75
+ this.fireInputComponentEvents(instance, inputs);
76
+ this.fireOutputComponentEvents(instance, inputs);
77
+ }
78
+
79
+ private setComponentDataInt<TComponent>(
80
+ factory: ComponentFactory<TComponent>,
81
+ component: ComponentRef<TComponent>,
82
+ inputs: Partial<TComponent>
83
+ ) {
84
+ if (inputs) {
85
+ const propertyNames = factory.inputs.map((x) => x.propName);
86
+ const inputsHash = new Set(propertyNames);
87
+ Object.keys(inputs)
88
+ .filter((x) => inputsHash.has(x))
89
+ .forEach((x) => {
90
+ (<{ [key: string]: unknown }>component.instance)[x] = (<
91
+ { [key: string]: unknown }
92
+ >inputs)[x];
93
+ });
94
+ }
95
+ }
96
+
97
+ private fireInputComponentEvents<TComponent>(
98
+ instance: TComponent,
99
+ inputs: ExtendedComponent<TComponent>
100
+ ) {
101
+ const onChangeComponent = instance as unknown as OnChanges;
102
+ if (onChangeComponent.ngOnChanges && inputs) {
103
+ const changeEventArgs = Object.keys(inputs).reduce((changes: SimpleChanges, key: string) => {
104
+ const inputValue = (inputs as { [key: string]: unknown })[key];
105
+ changes[key] = new SimpleChange(undefined, inputValue, true);
106
+ return changes;
107
+ }, {} as SimpleChanges);
108
+
109
+ onChangeComponent.ngOnChanges(changeEventArgs);
110
+ }
111
+ }
112
+
113
+ private fireOutputComponentEvents<TComponent>(
114
+ instance: TComponent & object,
115
+ inputs: ExtendedComponent<TComponent>
116
+ ) {
117
+ const outputs = Object.keys(inputs).filter((key) => {
118
+ const emitter = (instance as Record<string, any>)[key];
119
+ return emitter instanceof EventEmitter;
120
+ });
121
+
122
+ const subscriptionStoreKey = '__outputSubscriptions__';
123
+ if (!(subscriptionStoreKey in instance)) {
124
+ (instance as any)[subscriptionStoreKey] = new Map<string, Subscription>();
125
+ }
126
+ const subscriptions = (instance as any)[subscriptionStoreKey] as Map<string, Subscription>;
127
+
128
+ for (const outputKey of outputs) {
129
+ const eventEmitter = (instance as Record<string, any>)[outputKey] as EventEmitter<any>;
130
+ const callback = inputs[outputKey] as (value: any) => void;
131
+
132
+ if (eventEmitter && typeof callback === 'function') {
133
+ if (subscriptions.has(outputKey)) {
134
+ subscriptions.get(outputKey)!.unsubscribe();
135
+ }
136
+
137
+ const subscription = eventEmitter.subscribe((value: any) => callback(value));
138
+ subscriptions.set(outputKey, subscription);
139
+ }
140
+ }
141
+ }
142
+ }
@@ -0,0 +1,56 @@
1
+ import {
2
+ AfterViewInit,
3
+ ChangeDetectionStrategy,
4
+ ChangeDetectorRef,
5
+ Component,
6
+ inject,
7
+ Injector,
8
+ Input,
9
+ OnChanges,
10
+ Type,
11
+ ViewChild,
12
+ ViewContainerRef,
13
+ } from '@angular/core';
14
+ import { ExtendedComponent } from '@verisoft/ui-core';
15
+ import { DynamicComponentFactoryService } from './dynamic-component-factory.service';
16
+
17
+ @Component({
18
+ selector: 'v-dynamic-component',
19
+ standalone: true,
20
+ changeDetection: ChangeDetectionStrategy.OnPush,
21
+ template: `<ng-container #dynamicContainer></ng-container>`,
22
+ })
23
+ export class DynamicComponent<TComponent> implements AfterViewInit, OnChanges {
24
+ @Input() componentType!: Type<TComponent>;
25
+
26
+ @Input() data!: ExtendedComponent<TComponent>;
27
+
28
+ @ViewChild('dynamicContainer', { read: ViewContainerRef, static: true })
29
+ container!: ViewContainerRef;
30
+
31
+ private factoryServices = inject(DynamicComponentFactoryService);
32
+
33
+ private changeDetectorRef = inject(ChangeDetectorRef);
34
+
35
+ private injector = inject(Injector);
36
+
37
+ ngOnChanges(): void {
38
+ this.createComponent();
39
+ }
40
+
41
+ ngAfterViewInit(): void {
42
+ this.createComponent();
43
+ this.changeDetectorRef.detectChanges();
44
+ }
45
+
46
+ private createComponent() {
47
+ if (this.container) {
48
+ this.factoryServices.createDynamicComponent(
49
+ this.componentType,
50
+ this.container,
51
+ this.data,
52
+ this.injector
53
+ );
54
+ }
55
+ }
56
+ }
@@ -1,2 +1,2 @@
1
- export * from './dynamic-component-factory.service';
2
- export * from './dynamic-component.component';
1
+ export * from './dynamic-component-factory.service';
2
+ export * from './dynamic-component.component';
@@ -0,0 +1,98 @@
1
+ @if (!type || type === fieldTypes.text) {
2
+ <v-textfield
3
+ [label]="label"
4
+ [floatLabel]="floatLabel === true"
5
+ [size]="size"
6
+ [formControl]="formControl"
7
+ />
8
+ } @else if (type === fieldTypes.dropdown && !datasource) {
9
+ <v-dropdown
10
+ [label]="!floatLabel ? label : ''"
11
+ [floatLabel]="floatLabel ? label : ''"
12
+ [testId]="testId"
13
+ [options]="options"
14
+ [optionLabel]="optionLabel"
15
+ [optionValue]="optionValue ?? optionLabel"
16
+ [loading]="loading"
17
+ [forceMinWidth]="true"
18
+ [formControl]="formControl"
19
+ [showFilter]="showFilter ?? false"
20
+ [localSearch]="localSearch ?? false"
21
+ (changeEvent)="changed.emit($event)"
22
+ (clearEvent)="cleared.emit($event)"
23
+ (lazyLoadEvent)="lazyLoad.emit($any($event))"
24
+ (showEvent)="showed.emit($event)"
25
+ />
26
+ } @else if (type === fieldTypes.dropdown && datasource) {
27
+ <v-dropdown
28
+ useDatasource
29
+ [forceMinWidth]="true"
30
+ [datasource]="datasource"
31
+ [optionLabel]="optionLabel"
32
+ [optionValue]="optionValue ?? optionLabel"
33
+ [label]="!floatLabel ? label : ''"
34
+ [floatLabel]="floatLabel ? label : ''"
35
+ [testId]="testId"
36
+ [loading]="loading"
37
+ [formControl]="formControl"
38
+ [showFilter]="showFilter ?? false"
39
+ [filterField]="filterField ?? 'fulltext'"
40
+ [localSearch]="localSearch ?? false"
41
+ (changeEvent)="changed.emit($event)"
42
+ (clearEvent)="cleared.emit($event)"
43
+ (lazyLoadEvent)="lazyLoad.emit($any($event))"
44
+ (showEvent)="showed.emit($event)"
45
+ />
46
+ } @else if (type === fieldTypes.multiselect && !datasource) {
47
+ <v-multiselect
48
+ [label]="!floatLabel ? label : ''"
49
+ [floatLabel]="floatLabel ? label : ''"
50
+ [testId]="testId"
51
+ [options]="options"
52
+ [optionLabel]="optionLabel"
53
+ [optionValue]="optionValue ?? optionLabel"
54
+ [loading]="loading"
55
+ [formControl]="formControl"
56
+ (changeEvent)="changed.emit($event)"
57
+ (clearEvent)="cleared.emit($event)"
58
+ (lazyLoadEvent)="lazyLoad.emit($any($event))"
59
+ (showEvent)="showed.emit($event)"
60
+ />
61
+ } @else if (type === fieldTypes.multiselect && datasource) {
62
+ <v-multiselect
63
+ useDatasource
64
+ [datasource]="datasource"
65
+ [optionLabel]="optionLabel"
66
+ [optionValue]="optionValue ?? optionLabel"
67
+ [label]="!floatLabel ? label : ''"
68
+ [floatLabel]="floatLabel ? label : ''"
69
+ [testId]="testId"
70
+ [loading]="loading"
71
+ [formControl]="formControl"
72
+ (changeEvent)="changed.emit($event)"
73
+ (clearEvent)="cleared.emit($event)"
74
+ (lazyLoadEvent)="lazyLoad.emit($any($event))"
75
+ (showEvent)="showed.emit($event)"
76
+ />
77
+ } @else if (type === fieldTypes.checkbox) {
78
+ <v-checkbox
79
+ [label]="label"
80
+ [testId]="testId"
81
+ [formControl]="formControl"
82
+ [indeterminate]="true"
83
+ />
84
+ } @else if (type === fieldTypes.simplecheckbox) {
85
+ <v-checkbox
86
+ [label]="label"
87
+ [testId]="testId"
88
+ [formControl]="formControl"
89
+ />
90
+ } @else if (type === fieldTypes.calendar) {
91
+ <v-calendar
92
+ [label]="!floatLabel ? label : ''"
93
+ [floatLabel]="floatLabel ? label : ''"
94
+ [testId]="testId"
95
+ [formControl]="formControl"
96
+ [icon]="icons.calendar"
97
+ />
98
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { GenericFieldComponent } from './generic-field.component';
3
+
4
+ describe('GenericFieldComponent', () => {
5
+ let component: GenericFieldComponent<string>;
6
+ let fixture: ComponentFixture<GenericFieldComponent<string>>;
7
+
8
+ beforeEach(async () => {
9
+ await TestBed.configureTestingModule({
10
+ imports: [GenericFieldComponent],
11
+ }).compileComponents();
12
+
13
+ fixture = TestBed.createComponent(GenericFieldComponent<string>);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });
@@ -0,0 +1,90 @@
1
+
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ Component,
5
+ EventEmitter,
6
+ Input,
7
+ Output,
8
+ } from '@angular/core';
9
+ import { ReactiveFormsModule } from '@angular/forms';
10
+ import {
11
+ DatasourceType,
12
+ FilterEvent,
13
+ LazyLoadEvent,
14
+ } from '@verisoft/core';
15
+ import {
16
+ BaseFormInputComponent,
17
+ DatasourceDirective,
18
+ FieldSize,
19
+ FieldSizeType,
20
+ GENERIC_FIELD_COMPONENT_TOKEN,
21
+ GenericFieldCore,
22
+ GenericFieldType,
23
+ GenericFieldTypeType,
24
+ } from '@verisoft/ui-core';
25
+ import { Icons } from '../../../icons';
26
+ import { CalendarComponent } from '../../calendar';
27
+ import { CheckboxComponent } from '../../checkbox';
28
+ import { DropdownComponent } from '../../dropdown';
29
+ import { MultiselectComponent } from '../../multiselect';
30
+ import { TextfieldComponent } from '../../textfield';
31
+
32
+ @Component({
33
+ selector: 'v-generic-field',
34
+ imports: [
35
+ DropdownComponent,
36
+ CalendarComponent,
37
+ MultiselectComponent,
38
+ TextfieldComponent,
39
+ ReactiveFormsModule,
40
+ CheckboxComponent,
41
+ DatasourceDirective
42
+ ],
43
+ providers: [
44
+ {
45
+ provide: GENERIC_FIELD_COMPONENT_TOKEN,
46
+ useExisting: GenericFieldComponent,
47
+ },
48
+ ],
49
+ templateUrl: './generic-field.component.html',
50
+ changeDetection: ChangeDetectionStrategy.OnPush
51
+ })
52
+ export class GenericFieldComponent<T>
53
+ extends BaseFormInputComponent
54
+ implements GenericFieldCore<T>
55
+ {
56
+ @Input() type?: GenericFieldTypeType = GenericFieldType.text;
57
+
58
+ @Input() floatLabel?: boolean;
59
+
60
+ @Input() optionLabel: string | undefined;
61
+
62
+ @Input() optionValue: string | undefined;
63
+
64
+ @Input() options: T[] | undefined;
65
+
66
+ @Input() size?: FieldSizeType = FieldSize.medium;
67
+
68
+ @Input() loading = false;
69
+
70
+ @Input() lazy = false;
71
+
72
+ @Input() filter = true;
73
+
74
+ @Input() datasource?: DatasourceType<T>
75
+
76
+ @Input() filterField?: string;
77
+
78
+ @Input() showFilter?: boolean;
79
+
80
+ @Input() localSearch?: boolean;
81
+
82
+ @Output() changed = new EventEmitter<any>();
83
+ @Output() showed = new EventEmitter<any>();
84
+ @Output() cleared = new EventEmitter<any>();
85
+ @Output() lazyLoad = new EventEmitter<LazyLoadEvent>();
86
+ @Output() filtered = new EventEmitter<FilterEvent>();
87
+
88
+ fieldTypes = GenericFieldType;
89
+ icons = Icons;
90
+ }
@@ -1 +1 @@
1
- export * from './generic-field.component';
1
+ export * from './generic-field.component';
@@ -0,0 +1,46 @@
1
+ @if (formGroupComputed) {
2
+ <div
3
+ class="v-generic-form"
4
+ [ngClass]="showAsRow ? 'd-flex flex-row' : 'row'"
5
+ [formGroup]="formGroupComputed"
6
+ >
7
+ @for(field of fields; track field) { @if (columnClass) {
8
+ <div class="v-generic-form__column {{ columnClass }}">
9
+ <v-generic-field
10
+ [type]="field.type"
11
+ [label]="field.label ?? 'NOT SET' | translate"
12
+ [floatLabel]="field.floatLabel"
13
+ [testId]="field.testId"
14
+ [options]="field.options"
15
+ [optionLabel]="field.optionLabel"
16
+ [optionValue]="field.optionValue ?? field.optionLabel"
17
+ [options]="field.options"
18
+ [size]="field.size"
19
+ [formControlName]="field.name"
20
+ [datasource]="field.datasource"
21
+ [showFilter]="field.showFilter"
22
+ [filterField]="field.filterField"
23
+ [localSearch]="field.localSearch"
24
+ ></v-generic-field>
25
+ </div>
26
+ } @else {
27
+ <v-generic-field
28
+ class="me-4"
29
+ [type]="field.type"
30
+ [label]="field.label ?? 'NOT SET' | translate"
31
+ [floatLabel]="field.floatLabel"
32
+ [testId]="field.testId"
33
+ [options]="field.options"
34
+ [optionLabel]="field.optionLabel"
35
+ [optionValue]="field.optionValue ?? field.optionLabel"
36
+ [options]="field.options"
37
+ [size]="field.size"
38
+ [formControlName]="field.name"
39
+ [datasource]="field.datasource"
40
+ [showFilter]="field.showFilter"
41
+ [filterField]="field.filterField"
42
+ [localSearch]="field.localSearch"
43
+ ></v-generic-field>
44
+ } }
45
+ </div>
46
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { GenericFormComponent } from './generic-form.component';
3
+
4
+ describe('GenericFormComponent', () => {
5
+ let component: GenericFormComponent;
6
+ let fixture: ComponentFixture<GenericFormComponent>;
7
+
8
+ beforeEach(async () => {
9
+ await TestBed.configureTestingModule({
10
+ imports: [GenericFormComponent],
11
+ }).compileComponents();
12
+
13
+ fixture = TestBed.createComponent(GenericFormComponent);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });
@@ -0,0 +1,56 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ Component,
5
+ Input,
6
+ OnChanges,
7
+ SimpleChanges,
8
+ } from '@angular/core';
9
+ import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms';
10
+ import { TranslateModule } from '@ngx-translate/core';
11
+ import { GenericFieldDefinition } from '@verisoft/ui-core';
12
+ import { GenericFieldComponent } from '../generic-field';
13
+ import {
14
+ generateFormGroup,
15
+ getColumnClass,
16
+ } from './generic-form.model';
17
+
18
+ @Component({
19
+ selector: 'v-generic-form',
20
+ imports: [
21
+ CommonModule,
22
+ GenericFieldComponent,
23
+ ReactiveFormsModule,
24
+ TranslateModule,
25
+ ],
26
+ templateUrl: './generic-form.component.html',
27
+ changeDetection: ChangeDetectionStrategy.OnPush
28
+ })
29
+ export class GenericFormComponent implements OnChanges {
30
+ @Input() formGroup?: UntypedFormGroup;
31
+
32
+ @Input() fields?: GenericFieldDefinition[];
33
+
34
+ @Input() columns?: number;
35
+
36
+ @Input() showAsRow!: boolean;
37
+
38
+ formGroupComputed!: UntypedFormGroup;
39
+
40
+ columnClass?: string;
41
+
42
+ ngOnChanges(changes: SimpleChanges): void {
43
+ if (changes['fields'] || changes['formGroup']) {
44
+ this.formGroupComputed = generateFormGroup(
45
+ this.fields,
46
+ this.formGroupComputed,
47
+ this.formGroup,
48
+ !!changes['formGroup']
49
+ );
50
+ }
51
+
52
+ if (changes['columns']) {
53
+ this.columnClass = getColumnClass(this.columns);
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,82 @@
1
+ import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
2
+ import { generateFormGroup, GenericFieldDefinition } from './generic-form.model';
3
+
4
+ describe('GenericFormModel', () => {
5
+ describe('generateFormGroup', () => {
6
+ const fields = [{ name: 'name' }, { name: 'age' }];
7
+
8
+ const containsField = (formGroup: UntypedFormGroup, field: GenericFieldDefinition) => expect(formGroup.get(field.name)).toBeDefined();
9
+
10
+ test('Should create a new group when no group was provided', () => {
11
+ const formGroup = generateFormGroup([], undefined, undefined, false);
12
+
13
+ expect(formGroup).toBeDefined();
14
+ });
15
+
16
+ test('Should create a new group when no fields are provided', () => {
17
+ const formGroup = generateFormGroup(
18
+ undefined,
19
+ undefined,
20
+ undefined,
21
+ false
22
+ );
23
+
24
+ expect(formGroup).toBeDefined();
25
+ });
26
+
27
+ test('Should create a new group with defined control when fields are provided', () => {
28
+ const formGroup = generateFormGroup(fields, undefined, undefined, false);
29
+
30
+ expect(formGroup).toBeDefined();
31
+ containsField(formGroup, fields[0]);
32
+ containsField(formGroup, fields[1]);
33
+ });
34
+
35
+ test('Should used input group and creates control when fields are provided and formgroup does not have a controls', () => {
36
+ const inputGroup = new UntypedFormGroup({});
37
+
38
+ const formGroup = generateFormGroup(fields, undefined, inputGroup, false);
39
+
40
+ expect(formGroup).toBe(inputGroup);
41
+ containsField(formGroup, fields[0]);
42
+ });
43
+
44
+ test('Should not remove control from input group when input group is provided and fields does not contain control definition.', () => {
45
+ const inputGroup = new UntypedFormGroup({
46
+ student: new UntypedFormControl(),
47
+ });
48
+
49
+ const formGroup = generateFormGroup(fields, undefined, inputGroup, false);
50
+
51
+ expect(formGroup.get('student')).toBeDefined();
52
+ });
53
+
54
+ test('Should use existing group when input group is provided but have already defined group.', () => {
55
+ const inputGroup = new UntypedFormGroup({
56
+ student: new UntypedFormControl(),
57
+ });
58
+
59
+ const lastGroup = new UntypedFormGroup({
60
+ });
61
+
62
+ const formGroup = generateFormGroup(fields, lastGroup, inputGroup, false);
63
+
64
+ expect(formGroup).toBe(lastGroup);
65
+ containsField(formGroup, fields[0]);
66
+ });
67
+
68
+ test('Should use existing a new input group when last form group exists, but input group was changed.', () => {
69
+ const inputGroup = new UntypedFormGroup({
70
+ student: new UntypedFormControl(),
71
+ });
72
+
73
+ const lastGroup = new UntypedFormGroup({
74
+ });
75
+
76
+ const formGroup = generateFormGroup(fields, lastGroup, inputGroup, true);
77
+
78
+ expect(formGroup).toBe(inputGroup);
79
+ containsField(formGroup, fields[0]);
80
+ });
81
+ });
82
+ });