@ldquocc/dynamic-form 0.0.8 → 0.0.9

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 (298) hide show
  1. package/ng-package.json +15 -0
  2. package/package.json +20 -31
  3. package/src/lib/dynamic-form.component.html +121 -0
  4. package/src/lib/dynamic-form.component.scss +7 -0
  5. package/src/lib/dynamic-form.component.spec.ts +21 -0
  6. package/src/lib/dynamic-form.component.ts +237 -0
  7. package/src/lib/dynamic-form.service.spec.ts +16 -0
  8. package/src/lib/dynamic-form.service.ts +9 -0
  9. package/src/lib/shared/base/base-select.component.ts +183 -0
  10. package/src/lib/shared/base/base-value-accessor.ts +192 -0
  11. package/{lib/shared/components/component.d.ts → src/lib/shared/components/component.ts} +34 -14
  12. package/src/lib/shared/components/d-form-testing/d-form-testing.component.html +197 -0
  13. package/src/lib/shared/components/d-form-testing/d-form-testing.component.less +12 -0
  14. package/src/lib/shared/components/d-form-testing/d-form-testing.component.spec.ts +22 -0
  15. package/src/lib/shared/components/d-form-testing/d-form-testing.component.ts +197 -0
  16. package/src/lib/shared/components/dynamic-field/dynamic-field.component.html +218 -0
  17. package/src/lib/shared/components/dynamic-field/dynamic-field.component.scss +28 -0
  18. package/src/lib/shared/components/dynamic-field/dynamic-field.component.spec.ts +21 -0
  19. package/src/lib/shared/components/dynamic-field/dynamic-field.component.ts +67 -0
  20. package/src/lib/shared/components/field-user-config/field-user-config.component.html +38 -0
  21. package/src/lib/shared/components/field-user-config/field-user-config.component.scss +29 -0
  22. package/src/lib/shared/components/field-user-config/field-user-config.component.ts +33 -0
  23. package/src/lib/shared/components/fields/components/suffix/suffix.component.html +42 -0
  24. package/src/lib/shared/components/fields/components/suffix/suffix.component.scss +3 -0
  25. package/src/lib/shared/components/fields/components/suffix/suffix.component.spec.ts +22 -0
  26. package/src/lib/shared/components/fields/components/suffix/suffix.component.ts +32 -0
  27. package/src/lib/shared/components/fields/date/date-picker/date-picker.component.html +20 -0
  28. package/src/lib/shared/components/fields/date/date-picker/date-picker.component.scss +5 -0
  29. package/src/lib/shared/components/fields/date/date-picker/date-picker.component.spec.ts +21 -0
  30. package/src/lib/shared/components/fields/date/date-picker/date-picker.component.ts +148 -0
  31. package/src/lib/shared/components/fields/date/date-range/date-range.component.html +33 -0
  32. package/src/lib/shared/components/fields/date/date-range/date-range.component.scss +22 -0
  33. package/src/lib/shared/components/fields/date/date-range/date-range.component.spec.ts +21 -0
  34. package/src/lib/shared/components/fields/date/date-range/date-range.component.ts +133 -0
  35. package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.html +31 -0
  36. package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.scss +3 -0
  37. package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.spec.ts +21 -0
  38. package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.ts +148 -0
  39. package/src/lib/shared/components/fields/input/input-password/input-password.component.html +18 -0
  40. package/src/lib/shared/components/fields/input/input-password/input-password.component.scss +0 -0
  41. package/src/lib/shared/components/fields/input/input-password/input-password.component.spec.ts +21 -0
  42. package/src/lib/shared/components/fields/input/input-password/input-password.component.ts +56 -0
  43. package/src/lib/shared/components/fields/input/input-text/input-text.component.html +73 -0
  44. package/src/lib/shared/components/fields/input/input-text/input-text.component.scss +0 -0
  45. package/src/lib/shared/components/fields/input/input-text/input-text.component.spec.ts +21 -0
  46. package/src/lib/shared/components/fields/input/input-text/input-text.component.ts +98 -0
  47. package/src/lib/shared/components/fields/select/multi-select/multi-select.component.html +73 -0
  48. package/src/lib/shared/components/fields/select/multi-select/multi-select.component.scss +21 -0
  49. package/src/lib/shared/components/fields/select/multi-select/multi-select.component.spec.ts +21 -0
  50. package/src/lib/shared/components/fields/select/multi-select/multi-select.component.ts +212 -0
  51. package/src/lib/shared/components/fields/select/single-select/single-select.component.html +55 -0
  52. package/src/lib/shared/components/fields/select/single-select/single-select.component.scss +1 -0
  53. package/src/lib/shared/components/fields/select/single-select/single-select.component.spec.ts +21 -0
  54. package/src/lib/shared/components/fields/select/single-select/single-select.component.ts +217 -0
  55. package/src/lib/shared/components/fields/select/single-select/sl.component.old.txt +337 -0
  56. package/src/lib/shared/components/fields/select/single-select/sl.component.old2.txt +340 -0
  57. package/src/lib/shared/components/fields/select/tree-select/tree-select.component.html +38 -0
  58. package/src/lib/shared/components/fields/select/tree-select/tree-select.component.scss +1 -0
  59. package/src/lib/shared/components/fields/select/tree-select/tree-select.component.spec.ts +21 -0
  60. package/src/lib/shared/components/fields/select/tree-select/tree-select.component.ts +401 -0
  61. package/src/lib/shared/components/fields/textarea/textarea.component.html +29 -0
  62. package/src/lib/shared/components/fields/textarea/textarea.component.scss +17 -0
  63. package/src/lib/shared/components/fields/textarea/textarea.component.spec.ts +21 -0
  64. package/src/lib/shared/components/fields/textarea/textarea.component.ts +76 -0
  65. package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.html +30 -0
  66. package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.scss +22 -0
  67. package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.spec.ts +22 -0
  68. package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.ts +217 -0
  69. package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.html +101 -0
  70. package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.scss +117 -0
  71. package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.spec.ts +22 -0
  72. package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.ts +480 -0
  73. package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.html +82 -0
  74. package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.less +80 -0
  75. package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.spec.ts +22 -0
  76. package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.ts +288 -0
  77. package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.html +104 -0
  78. package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.scss +37 -0
  79. package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.spec.ts +21 -0
  80. package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.ts +317 -0
  81. package/src/lib/shared/config/dynamic-form.config.ts +11 -0
  82. package/src/lib/shared/consts/common/common.const.ts +5 -0
  83. package/src/lib/shared/consts/common/field-dependency.const.ts +1 -0
  84. package/src/lib/shared/consts/common/file.const.ts +130 -0
  85. package/{lib/shared/consts/common/index.d.ts → src/lib/shared/consts/common/index.ts} +4 -4
  86. package/src/lib/shared/consts/common/sample-test.const.ts +1648 -0
  87. package/src/lib/shared/consts/common/standalone-import.const.ts +51 -0
  88. package/src/lib/shared/consts/controls/control.const.ts +11 -0
  89. package/{lib/shared/consts/controls/index.d.ts → src/lib/shared/consts/controls/index.ts} +1 -1
  90. package/src/lib/shared/consts/fields/date-field.const.ts +12 -0
  91. package/src/lib/shared/consts/fields/field.const.ts +23 -0
  92. package/{lib/shared/consts/fields/index.d.ts → src/lib/shared/consts/fields/index.ts} +5 -5
  93. package/src/lib/shared/consts/fields/input-field.const.ts +4 -0
  94. package/src/lib/shared/consts/fields/input-formatted-field.const.ts +35 -0
  95. package/src/lib/shared/consts/fields/radio-field.const.ts +31 -0
  96. package/src/lib/shared/consts/fields/select-field.const.ts +7 -0
  97. package/src/lib/shared/consts/fields/upload-field.const.ts +1 -0
  98. package/src/lib/shared/consts/validators/index.ts +0 -0
  99. package/src/lib/shared/consts/validators/pattern.const.ts +117 -0
  100. package/src/lib/shared/enums/common/component-ui.enum.ts +8 -0
  101. package/src/lib/shared/enums/common/field-dependency.enum.ts +10 -0
  102. package/src/lib/shared/enums/common/file-size-type.enum.ts +6 -0
  103. package/{lib/shared/enums/common/index.d.ts → src/lib/shared/enums/common/index.ts} +4 -4
  104. package/src/lib/shared/enums/common/output-value-type.enum.ts +22 -0
  105. package/src/lib/shared/enums/common/view-mode.enum.ts +4 -0
  106. package/src/lib/shared/enums/controls/control.enum.ts +12 -0
  107. package/{lib/shared/enums/controls/index.d.ts → src/lib/shared/enums/controls/index.ts} +1 -1
  108. package/src/lib/shared/enums/fields/date-field.enum.ts +4 -0
  109. package/src/lib/shared/enums/fields/field.enum.ts +21 -0
  110. package/{lib/shared/enums/fields/index.d.ts → src/lib/shared/enums/fields/index.ts} +6 -6
  111. package/src/lib/shared/enums/fields/input-field.enum.ts +6 -0
  112. package/src/lib/shared/enums/fields/input-formatted-field.enum.ts +6 -0
  113. package/src/lib/shared/enums/fields/select-field.enum.ts +4 -0
  114. package/src/lib/shared/enums/fields/upload-field.enum.ts +5 -0
  115. package/src/lib/shared/enums/form/dynamic-form.enum.ts +6 -0
  116. package/{lib/shared/enums/form/index.d.ts → src/lib/shared/enums/form/index.ts} +1 -1
  117. package/{lib/shared/enums/validators/index.d.ts → src/lib/shared/enums/validators/index.ts} +2 -2
  118. package/src/lib/shared/enums/validators/regex.enum.ts +47 -0
  119. package/src/lib/shared/enums/validators/validators.enum.ts +17 -0
  120. package/src/lib/shared/factories/auto-numeric-options.factory.ts +14 -0
  121. package/src/lib/shared/models/common/api-config.model.ts +7 -0
  122. package/src/lib/shared/models/common/api-response.model.ts +20 -0
  123. package/src/lib/shared/models/common/common.model.ts +39 -0
  124. package/src/lib/shared/models/common/field-dependency.model.ts +27 -0
  125. package/src/lib/shared/models/common/file-config.model.ts +22 -0
  126. package/{lib/shared/models/common/index.d.ts → src/lib/shared/models/common/index.ts} +7 -7
  127. package/src/lib/shared/models/common/obj-field.model.ts +68 -0
  128. package/src/lib/shared/models/common/object-storage.model.ts +15 -0
  129. package/{lib/shared/models/common/output-value-type.model.d.ts → src/lib/shared/models/common/output-value-type.model.ts} +4 -4
  130. package/src/lib/shared/models/common/table-models.ts +16 -0
  131. package/{lib/shared/models/common/view-mode.model.d.ts → src/lib/shared/models/common/view-mode.model.ts} +1 -1
  132. package/{lib/shared/models/controls/control.model.d.ts → src/lib/shared/models/controls/control.model.ts} +3 -2
  133. package/{lib/shared/models/controls/index.d.ts → src/lib/shared/models/controls/index.ts} +1 -1
  134. package/src/lib/shared/models/fields/date/base-date-field.model.ts +52 -0
  135. package/src/lib/shared/models/fields/date/date-picker-field.model.ts +43 -0
  136. package/src/lib/shared/models/fields/date/date-range-field.model.ts +52 -0
  137. package/{lib/shared/models/fields/date/index.d.ts → src/lib/shared/models/fields/date/index.ts} +3 -3
  138. package/src/lib/shared/models/fields/field-grid.model.ts +10 -0
  139. package/src/lib/shared/models/fields/field-group.model.ts +50 -0
  140. package/src/lib/shared/models/fields/field-user-config.model.ts +8 -0
  141. package/src/lib/shared/models/fields/field.model.ts +184 -0
  142. package/{lib/shared/models/fields/index.d.ts → src/lib/shared/models/fields/index.ts} +2 -2
  143. package/{lib/shared/models/fields/input/index.d.ts → src/lib/shared/models/fields/input/index.ts} +4 -4
  144. package/src/lib/shared/models/fields/input/input-field.model.ts +111 -0
  145. package/src/lib/shared/models/fields/input/input-formatted-field.model.ts +38 -0
  146. package/src/lib/shared/models/fields/input/input-password-field.model.ts +38 -0
  147. package/src/lib/shared/models/fields/input/input-text-field.model.ts +26 -0
  148. package/src/lib/shared/models/fields/radio/index.ts +0 -0
  149. package/src/lib/shared/models/fields/radio/radio-base-field.model.ts +84 -0
  150. package/src/lib/shared/models/fields/select/index.ts +0 -0
  151. package/src/lib/shared/models/fields/select/multi-select-field.model.ts +46 -0
  152. package/src/lib/shared/models/fields/select/select-base-field.model.ts +125 -0
  153. package/src/lib/shared/models/fields/select/single-select-field.model.ts +43 -0
  154. package/src/lib/shared/models/fields/select/tree-select-field.model.ts +44 -0
  155. package/src/lib/shared/models/fields/textarea/index.ts +0 -0
  156. package/src/lib/shared/models/fields/textarea/textarea-field.model.ts +97 -0
  157. package/src/lib/shared/models/fields/upload/avatar-upload-field.model.ts +33 -0
  158. package/src/lib/shared/models/fields/upload/base-upload-field.model.ts +105 -0
  159. package/{lib/shared/models/fields/upload/index.d.ts → src/lib/shared/models/fields/upload/index.ts} +5 -5
  160. package/src/lib/shared/models/fields/upload/multi-file-upload-field.model.ts +34 -0
  161. package/src/lib/shared/models/fields/upload/multi-image-upload-field.model.ts +42 -0
  162. package/src/lib/shared/models/fields/upload/single-file-upload-field.model.ts +33 -0
  163. package/{lib/shared/models/form/dynamic-form.model.d.ts → src/lib/shared/models/form/dynamic-form.model.ts} +1 -1
  164. package/{lib/shared/models/form/index.d.ts → src/lib/shared/models/form/index.ts} +1 -1
  165. package/src/lib/shared/models/validations/index.ts +1 -0
  166. package/src/lib/shared/models/validations/validations.model.ts +14 -0
  167. package/src/lib/shared/services/dynamic-form.service.spec.ts +16 -0
  168. package/src/lib/shared/services/dynamic-form.service.ts +251 -0
  169. package/src/lib/shared/services/field.service.spec.ts +16 -0
  170. package/src/lib/shared/services/field.service.ts +152 -0
  171. package/src/lib/shared/services/file.service.spec.ts +16 -0
  172. package/src/lib/shared/services/file.service.ts +53 -0
  173. package/src/lib/shared/services/form-config.service.ts +53 -0
  174. package/src/lib/shared/services/form-data.service.spec.ts +16 -0
  175. package/src/lib/shared/services/form-data.service.ts +114 -0
  176. package/src/lib/shared/services/form-utils.ts +52 -0
  177. package/src/lib/shared/services/suffix.service.spec.ts +16 -0
  178. package/src/lib/shared/services/suffix.service.ts +16 -0
  179. package/src/lib/shared/services/validation.service.spec.ts +16 -0
  180. package/src/lib/shared/services/validation.service.ts +38 -0
  181. package/src/lib/shared/utils/common/common.utils.ts +52 -0
  182. package/{lib/shared/utils/common/index.d.ts → src/lib/shared/utils/common/index.ts} +1 -1
  183. package/src/lib/shared/utils/date/date.utils.ts +129 -0
  184. package/{lib/shared/utils/date/index.d.ts → src/lib/shared/utils/date/index.ts} +1 -1
  185. package/src/lib/shared/utils/dynamic-field/dynamic-field.ts +0 -0
  186. package/src/lib/shared/utils/dynamic-field/index.ts +0 -0
  187. package/src/lib/shared/utils/dynamic-form/dynamic-form.ts +114 -0
  188. package/src/lib/shared/utils/dynamic-form/index.ts +0 -0
  189. package/src/lib/shared/utils/fields/fields.ts +78 -0
  190. package/{lib/shared/utils/fields/index.d.ts → src/lib/shared/utils/fields/index.ts} +1 -1
  191. package/src/lib/shared/utils/file/file.utils.ts +37 -0
  192. package/{lib/shared/utils/file/index.d.ts → src/lib/shared/utils/file/index.ts} +1 -1
  193. package/src/lib/shared/utils/validators/custom-validators.ts +158 -0
  194. package/src/lib/shared/utils/validators/default-error-message.ts +42 -0
  195. package/{lib/shared/utils/validators/index.d.ts → src/lib/shared/utils/validators/index.ts} +3 -3
  196. package/src/lib/shared/utils/validators/pattern.ts +26 -0
  197. package/{public-api.d.ts → src/public-api.ts} +68 -28
  198. package/tsconfig.lib.json +15 -0
  199. package/tsconfig.lib.prod.json +11 -0
  200. package/tsconfig.spec.json +15 -0
  201. package/fesm2022/ldquocc-dynamic-form.mjs +0 -4938
  202. package/fesm2022/ldquocc-dynamic-form.mjs.map +0 -1
  203. package/index.d.ts +0 -5
  204. package/lib/dynamic-form.component.d.ts +0 -67
  205. package/lib/shared/base/base-select.component.d.ts +0 -19
  206. package/lib/shared/base/base-value-accessor.d.ts +0 -69
  207. package/lib/shared/components/dynamic-field/dynamic-field.component.d.ts +0 -23
  208. package/lib/shared/components/field-user-config/field-user-config.component.d.ts +0 -10
  209. package/lib/shared/components/fields/components/suffix/suffix.component.d.ts +0 -12
  210. package/lib/shared/components/fields/date/date-picker/date-picker.component.d.ts +0 -17
  211. package/lib/shared/components/fields/date/date-range/date-range.component.d.ts +0 -17
  212. package/lib/shared/components/fields/input/input-formatted/input-formatted.component.d.ts +0 -20
  213. package/lib/shared/components/fields/input/input-password/input-password.component.d.ts +0 -12
  214. package/lib/shared/components/fields/input/input-text/input-text.component.d.ts +0 -14
  215. package/lib/shared/components/fields/select/multi-select/multi-select.component.d.ts +0 -21
  216. package/lib/shared/components/fields/select/single-select/single-select.component.d.ts +0 -21
  217. package/lib/shared/components/fields/select/tree-select/tree-select.component.d.ts +0 -28
  218. package/lib/shared/components/fields/textarea/textarea.component.d.ts +0 -14
  219. package/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.d.ts +0 -25
  220. package/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.d.ts +0 -76
  221. package/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.d.ts +0 -27
  222. package/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.d.ts +0 -29
  223. package/lib/shared/config/dynamic-form.config.d.ts +0 -9
  224. package/lib/shared/consts/common/common.const.d.ts +0 -5
  225. package/lib/shared/consts/common/field-dependency.const.d.ts +0 -1
  226. package/lib/shared/consts/common/file.const.d.ts +0 -148
  227. package/lib/shared/consts/common/standalone-import.const.d.ts +0 -7
  228. package/lib/shared/consts/controls/control.const.d.ts +0 -1
  229. package/lib/shared/consts/fields/date-field.const.d.ts +0 -7
  230. package/lib/shared/consts/fields/field.const.d.ts +0 -4
  231. package/lib/shared/consts/fields/input-field.const.d.ts +0 -4
  232. package/lib/shared/consts/fields/input-formatted-field.const.d.ts +0 -4
  233. package/lib/shared/consts/fields/radio-field.const.d.ts +0 -10
  234. package/lib/shared/consts/fields/select-field.const.d.ts +0 -6
  235. package/lib/shared/consts/fields/upload-field.const.d.ts +0 -1
  236. package/lib/shared/consts/validators/pattern.const.d.ts +0 -2
  237. package/lib/shared/enums/common/field-dependency.enum.d.ts +0 -9
  238. package/lib/shared/enums/common/file-size-type.enum.d.ts +0 -6
  239. package/lib/shared/enums/common/output-value-type.enum.d.ts +0 -19
  240. package/lib/shared/enums/common/view-mode.enum.d.ts +0 -4
  241. package/lib/shared/enums/controls/control.enum.d.ts +0 -11
  242. package/lib/shared/enums/fields/date-field.enum.d.ts +0 -4
  243. package/lib/shared/enums/fields/field.enum.d.ts +0 -20
  244. package/lib/shared/enums/fields/input-field.enum.d.ts +0 -6
  245. package/lib/shared/enums/fields/input-formatted-field.enum.d.ts +0 -6
  246. package/lib/shared/enums/fields/select-field.enum.d.ts +0 -4
  247. package/lib/shared/enums/fields/upload-field.enum.d.ts +0 -5
  248. package/lib/shared/enums/form/dynamic-form.enum.d.ts +0 -6
  249. package/lib/shared/enums/validators/regex.enum.d.ts +0 -38
  250. package/lib/shared/enums/validators/validators.enum.d.ts +0 -14
  251. package/lib/shared/factories/auto-numeric-options.factory.d.ts +0 -5
  252. package/lib/shared/models/common/api-config.model.d.ts +0 -4
  253. package/lib/shared/models/common/api-response.model.d.ts +0 -19
  254. package/lib/shared/models/common/common.model.d.ts +0 -29
  255. package/lib/shared/models/common/field-dependency.model.d.ts +0 -16
  256. package/lib/shared/models/common/file-config.model.d.ts +0 -11
  257. package/lib/shared/models/common/obj-field.model.d.ts +0 -59
  258. package/lib/shared/models/common/object-storage.model.d.ts +0 -15
  259. package/lib/shared/models/common/table-models.d.ts +0 -15
  260. package/lib/shared/models/fields/date/base-date-field.model.d.ts +0 -19
  261. package/lib/shared/models/fields/date/date-picker-field.model.d.ts +0 -12
  262. package/lib/shared/models/fields/date/date-range-field.model.d.ts +0 -12
  263. package/lib/shared/models/fields/field-grid.model.d.ts +0 -9
  264. package/lib/shared/models/fields/field-group.model.d.ts +0 -21
  265. package/lib/shared/models/fields/field-user-config.model.d.ts +0 -3
  266. package/lib/shared/models/fields/field.model.d.ts +0 -57
  267. package/lib/shared/models/fields/input/input-field.model.d.ts +0 -31
  268. package/lib/shared/models/fields/input/input-formatted-field.model.d.ts +0 -13
  269. package/lib/shared/models/fields/input/input-password-field.model.d.ts +0 -11
  270. package/lib/shared/models/fields/input/input-text-field.model.d.ts +0 -9
  271. package/lib/shared/models/fields/radio/radio-base-field.model.d.ts +0 -26
  272. package/lib/shared/models/fields/select/multi-select-field.model.d.ts +0 -11
  273. package/lib/shared/models/fields/select/select-base-field.model.d.ts +0 -40
  274. package/lib/shared/models/fields/select/single-select-field.model.d.ts +0 -9
  275. package/lib/shared/models/fields/select/tree-select-field.model.d.ts +0 -10
  276. package/lib/shared/models/fields/textarea/textarea-field.model.d.ts +0 -20
  277. package/lib/shared/models/fields/upload/avatar-upload-field.model.d.ts +0 -9
  278. package/lib/shared/models/fields/upload/base-upload-field.model.d.ts +0 -25
  279. package/lib/shared/models/fields/upload/multi-file-upload-field.model.d.ts +0 -10
  280. package/lib/shared/models/fields/upload/multi-image-upload-field.model.d.ts +0 -12
  281. package/lib/shared/models/fields/upload/single-file-upload-field.model.d.ts +0 -11
  282. package/lib/shared/services/dynamic-form.service.d.ts +0 -48
  283. package/lib/shared/services/field.service.d.ts +0 -41
  284. package/lib/shared/services/file.service.d.ts +0 -20
  285. package/lib/shared/services/form-config.service.d.ts +0 -10
  286. package/lib/shared/services/form-data.service.d.ts +0 -53
  287. package/lib/shared/services/form-utils.d.ts +0 -5
  288. package/lib/shared/services/suffix.service.d.ts +0 -12
  289. package/lib/shared/services/validation.service.d.ts +0 -10
  290. package/lib/shared/utils/common/common.utils.d.ts +0 -7
  291. package/lib/shared/utils/date/date.utils.d.ts +0 -6
  292. package/lib/shared/utils/dynamic-form/dynamic-form.d.ts +0 -11
  293. package/lib/shared/utils/fields/fields.d.ts +0 -20
  294. package/lib/shared/utils/file/file.utils.d.ts +0 -4
  295. package/lib/shared/utils/validators/custom-validators.d.ts +0 -11
  296. package/lib/shared/utils/validators/default-error-message.d.ts +0 -6
  297. package/lib/shared/utils/validators/pattern.d.ts +0 -4
  298. /package/{styles → src/lib/shared/styles}/_common-form.scss +0 -0
@@ -0,0 +1,39 @@
1
+ import { NzUploadFile } from 'ng-zorro-antd/upload';
2
+ import { ObjectStorage } from './object-storage.model';
3
+ import { FormMode } from '../form';
4
+
5
+ export interface ExtendUploadFile {
6
+ fromServer?: boolean;
7
+ markedForDelete?: boolean;
8
+ objStorage: ObjectStorage;
9
+ }
10
+
11
+ export interface MyUploadFile extends NzUploadFile {
12
+ fromServer?: boolean;
13
+ markedForDelete?: boolean;
14
+ objStorage: ObjectStorage;
15
+ isTemp: boolean;
16
+ previewUrl: string;
17
+ // Trạng thái upload tùy chỉnh: loading → success | error.
18
+ // Dùng tên khác để tránh xung đột với NzUploadFile.status (UploadFileStatus).
19
+ uploadStatus?: 'loading' | 'success' | 'error';
20
+ }
21
+
22
+ export class Suffix {
23
+ key!: string;
24
+ label?: string;
25
+ class?: string;
26
+ description: string;
27
+ icon?: {
28
+ type: 'mdi' | 'zorro';
29
+ value: string;
30
+ class?: string;
31
+ };
32
+ visibleOn?: FormMode[]; // nếu undefined => hiển thị tất cả mode
33
+
34
+ constructor(init: Partial<Suffix>) {
35
+ this.visibleOn = ['add', 'edit'];
36
+ this.description = '';
37
+ Object.assign(this, init);
38
+ }
39
+ }
@@ -0,0 +1,27 @@
1
+ import { COMBINE_DEPEND_TYPES } from '../../consts/common';
2
+
3
+ export interface FieldDependency {
4
+ // Key của field sẽ phụ thuộc.
5
+ fieldKey: string;
6
+
7
+ // Tên pararms sẽ dùng gọi api sau dấu ? theo giá trị của field đang phụ thuộc (có thể hiểu là parent).
8
+ paramKey: string;
9
+
10
+ // Label của field sẽ phụ thuộc.
11
+ fieldLabel?: string;
12
+
13
+ // Xử lý biến đổi giá trị nếu cần.
14
+ mapFn?: (value: any) => any;
15
+ }
16
+
17
+ /**
18
+ * FieldDependencyType:
19
+ * - 'all' → cần tất cả field cha có giá trị mới gọi API
20
+ * - 'any' → chỉ cần 1 field cha có giá trị cũng gọi API theo từng cha
21
+ */
22
+ export type FieldDependencyType = 'all' | 'any';
23
+
24
+ export interface LastChangedParent {
25
+ key: string;
26
+ value: unknown;
27
+ }
@@ -0,0 +1,22 @@
1
+ export interface ApiFileConfig {
2
+ // Upload url để upload file đến máy chủ.
3
+ uploadUrl: string;
4
+
5
+ // Delete url để xóa file khỏi máy chủ.
6
+ deleteUrl: string;
7
+
8
+ uploadByPath?: boolean;
9
+
10
+ uploadPath?: string;
11
+
12
+ isOriginName?: boolean;
13
+
14
+ // Custom upload theo mimeTypes.
15
+ perMimeTypeConfig?: Record<
16
+ string,
17
+ {
18
+ uploadUrl?: string;
19
+ buildFormData?: (file: File, extraParams?: Record<string, any>) => FormData;
20
+ }
21
+ >;
22
+ }
@@ -1,7 +1,7 @@
1
- export * from "./api-config.model";
2
- export * from "./field-dependency.model";
3
- export * from "./api-response.model";
4
- export * from "./object-storage.model";
5
- export * from "./output-value-type.model";
6
- export * from "./file-config.model";
7
- export * from "./view-mode.model";
1
+ export * from "./api-config.model";
2
+ export * from "./field-dependency.model";
3
+ export * from "./api-response.model";
4
+ export * from "./object-storage.model";
5
+ export * from "./output-value-type.model";
6
+ export * from "./file-config.model";
7
+ export * from "./view-mode.model";
@@ -0,0 +1,68 @@
1
+ import { RawColumn, TableCellTypeEnum } from './table-models';
2
+ import { BaseField } from '../fields/field.model';
3
+
4
+ export class ObjField {
5
+ required!: number;
6
+ componentUI!: string;
7
+ appliedFields?: string[];
8
+ allowShare: number = 0;
9
+ allowView?: number;
10
+ allowSort?: number;
11
+ allowStatistic?: number;
12
+ code!: string;
13
+ createdAt!: string;
14
+ dataType!: string;
15
+ id!: string;
16
+ name!: string;
17
+ nameEn!: string;
18
+ objClassCode!: string;
19
+ objClassSubCode!: string;
20
+ codeOnDb?: string;
21
+ value?: any;
22
+ apiURL?: string;
23
+ seqNum?: number;
24
+ parentCode?: string;
25
+ parentCondition?: string;
26
+ parentApiBindValue!: string;
27
+ preventEdit?: number;
28
+ minSize?: number;
29
+ maxSize?: number;
30
+ minValue?: string;
31
+ maxValue?: string;
32
+ validateRegex?: string;
33
+ extra?: string; // JSON string khi parse sẽ thành Extra model.
34
+ note?: string;
35
+ transportType?: any;
36
+ iconData?: string;
37
+ objTypeGroupCode?: string;
38
+ viewType?: string;
39
+ }
40
+
41
+ interface FieldFormConfig {
42
+ formTypes: string[]; // mảng string động, từng giá trị là tên key truy cập cấu hình ở prop configs bên dưới.
43
+ configs: Record<string, BaseField<any>>; // config theo key formType.
44
+ }
45
+
46
+ export interface Extra {
47
+ // form.
48
+ form?: FieldFormConfig;
49
+
50
+ // table.
51
+ table?: Partial<RawColumn> & {
52
+ cellType: TableCellTypeEnum;
53
+ seqNum: number;
54
+ valueConfig?: {
55
+ params: string[];
56
+ body: string;
57
+ };
58
+ subValueConfig?: {
59
+ params: string[];
60
+ body: string;
61
+ };
62
+ dateFormat: string;
63
+ };
64
+ // ..........................
65
+
66
+ // chart.
67
+ // ..........................
68
+ }
@@ -0,0 +1,15 @@
1
+ export interface ObjectStorage {
2
+ id: string;
3
+ uid?: string; // Để xem là phần tử nào trong mảng NzUploadFile
4
+ name?: string;
5
+ contentType?: string;
6
+ size?: number;
7
+ bucket?: string;
8
+ isDir?: boolean;
9
+ createdAt?: string;
10
+ updatedAt?: string;
11
+ path?: string;
12
+ isPublic?: boolean;
13
+ originalName?: string;
14
+ nameAlias?: string;
15
+ }
@@ -1,4 +1,4 @@
1
- export type SelectOutputValueType = 'single' | 'object' | 'sourceObject';
2
- export type DatePickerOutputValueType = 'string' | 'date';
3
- export type DateRangeOutputValueType = 'string' | 'string-array' | 'date-array';
4
- export type UploadOutputValueType = 'file' | 'object-storage' | 'object';
1
+ export type SelectOutputValueType = 'single' | 'object' | 'sourceObject';
2
+ export type DatePickerOutputValueType = 'string' | 'date';
3
+ export type DateRangeOutputValueType = 'string' | 'string-array' | 'date-array';
4
+ export type UploadOutputValueType = 'file' | 'object-storage' | 'object';
@@ -0,0 +1,16 @@
1
+ export enum TableCellTypeEnum {
2
+ ACTION = 'action',
3
+ CHECK = 'check',
4
+ SUBTEXT = 'subtext',
5
+ IMAGE = 'image',
6
+ BADGE = 'badge',
7
+ INDEX = 'index',
8
+ TEXT = 'text',
9
+ ICON_TEXT = 'icon-text',
10
+ SWAP_FUNC = 'swap',
11
+ EMPTY = 'empty',
12
+ }
13
+
14
+ export interface RawColumn {
15
+ [key: string]: any;
16
+ }
@@ -1 +1 @@
1
- export type ViewMode = 'form' | 'text';
1
+ export type ViewMode = 'form' | 'text';
@@ -1,2 +1,3 @@
1
- import { CONTROL_TYPES } from '../../consts/controls';
2
- export type ControlType = (typeof CONTROL_TYPES)[number];
1
+ import { CONTROL_TYPES } from '../../consts/controls';
2
+
3
+ export type ControlType = (typeof CONTROL_TYPES)[number];
@@ -1 +1 @@
1
- export * from './control.model';
1
+ export * from './control.model';
@@ -0,0 +1,52 @@
1
+ import { FormControl } from '@angular/forms';
2
+ import { BaseField } from '../field.model';
3
+ import { DATE_FIELD_TYPES } from '../../../consts/fields';
4
+ import { ControlTypeEnum } from '../../../enums/controls';
5
+
6
+ export type DateFieldType = (typeof DATE_FIELD_TYPES)[number];
7
+
8
+ /**
9
+ * Interface base chung cho Các dạng Date.
10
+ */
11
+ export abstract class BaseDateField<K> extends BaseField<K> {
12
+ // Dạng date hiển thị.
13
+ format: string;
14
+
15
+ // Cho phép chọn ngày quá khứ?
16
+ allowPastDates?: boolean;
17
+
18
+ // Cho phép chọn ngày tương lai?
19
+ allowFutureDates?: boolean;
20
+
21
+ /**
22
+ * Props validation chung cho các dạng Date.
23
+ */
24
+
25
+ constructor(init: Partial<BaseDateField<K>>) {
26
+ super(init);
27
+
28
+ /**
29
+ * Gán giá trị cho các props cần giá trị mặc định ở Date.
30
+ */
31
+ this.controlType = ControlTypeEnum.Date;
32
+
33
+ this.allowPastDates = true;
34
+ this.allowFutureDates = true;
35
+ this.format = 'dd-MM-yyyy';
36
+
37
+ // this.value = undefined;
38
+
39
+ Object.assign(this, init);
40
+ }
41
+
42
+ // Tạo Form Control cho Input Field.
43
+ override toFormControl(): FormControl {
44
+ const commonValidators = this.getCommonValidators();
45
+ const customValidators = this.getCustomValidators();
46
+ return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
47
+ }
48
+
49
+ abstract override getDefaultValue(): K;
50
+
51
+ abstract override toFormValue(modelValue: unknown): K;
52
+ }
@@ -0,0 +1,43 @@
1
+ import { DatePickerOutputValueTypeEnum } from '../../../enums/common';
2
+ import { FieldTypeEnum } from '../../../enums/fields';
3
+ import { normalizeToDate } from '../../../utils/date';
4
+ import { DatePickerOutputValueType } from '../../common';
5
+ import { BaseDateField } from './base-date-field.model';
6
+
7
+ const DEFAULT_DATE_PICKER_VALUE = '';
8
+
9
+ /**
10
+ * Interface của Date type là Picker.
11
+ */
12
+ export class DatePickerField extends BaseDateField<string | Date | null> {
13
+ // Dữ liệu sẽ gửi từ form khi submit.
14
+ outputAs!: DatePickerOutputValueType;
15
+
16
+ // Custom function to disable dates
17
+ disabledDateFn?: (current: Date) => boolean;
18
+
19
+ constructor(init: Partial<DatePickerField>) {
20
+ super(init);
21
+
22
+ /**
23
+ * Gán giá trị cho các props cần giá trị mặc định ở Date picker.
24
+ */
25
+ this.type = FieldTypeEnum.DatePicker;
26
+ this.value = DEFAULT_DATE_PICKER_VALUE;
27
+ this.initialValue = DEFAULT_DATE_PICKER_VALUE;
28
+ this.outputAs = DatePickerOutputValueTypeEnum.String;
29
+ Object.assign(this, init);
30
+ }
31
+
32
+ override getDefaultValue(): string | Date {
33
+ return DEFAULT_DATE_PICKER_VALUE;
34
+ }
35
+
36
+ override toFormValue(modelValue: unknown): Date | null {
37
+ const value = modelValue as string | Date;
38
+
39
+ if (!value) return null;
40
+
41
+ return normalizeToDate(value);
42
+ }
43
+ }
@@ -0,0 +1,52 @@
1
+ import { DateRangeOutputValueTypeEnum } from "../../../enums/common";
2
+ import { FieldTypeEnum } from "../../../enums/fields";
3
+ import { normalizeToDate } from "../../../utils/date";
4
+ import { DateRangeOutputValueType } from "../../common";
5
+ import { BaseDateField } from "./base-date-field.model";
6
+
7
+ const DEFAULT_DATE_RANGE_VALUE: string[] | Date[] = [];
8
+
9
+ /**
10
+ * Interface của Date type là Range.
11
+ */
12
+ export class DateRangeField extends BaseDateField<string | string[] | Date[]> {
13
+ // Dữ liệu sẽ gửi từ form khi submit.
14
+ outputAs!: DateRangeOutputValueType;
15
+
16
+ // Placeholder cho Date range (mảng gồm ngày bắt đầu và kết thúc)
17
+ placeholders?: string[];
18
+
19
+ constructor(init: Partial<DateRangeField>) {
20
+ super(init);
21
+
22
+ /**
23
+ * Gán giá trị cho các props cần giá trị mặc định ở Date range.
24
+ */
25
+ this.type = FieldTypeEnum.DateRange;
26
+ this.value = DEFAULT_DATE_RANGE_VALUE;
27
+ this.initialValue = DEFAULT_DATE_RANGE_VALUE;
28
+ this.outputAs = DateRangeOutputValueTypeEnum.StringArray;
29
+ Object.assign(this, init);
30
+ }
31
+
32
+ override getDefaultValue(): string[] | Date[] {
33
+ return DEFAULT_DATE_RANGE_VALUE;
34
+ }
35
+
36
+ override toFormValue(modelValue: unknown): string[] | Date[] {
37
+ let value = modelValue as string | string[] | Date[];
38
+
39
+ if (typeof value === "string") {
40
+ value = value.split(",").map((dateStr) => dateStr.trim());
41
+ }
42
+
43
+ let dateRange: Date[] = [];
44
+
45
+ if (value?.length === 2) {
46
+ const startDate = normalizeToDate(value[0]);
47
+ const endDate = normalizeToDate(value[1]);
48
+ if (startDate && endDate) dateRange = [startDate, endDate];
49
+ }
50
+ return dateRange;
51
+ }
52
+ }
@@ -1,3 +1,3 @@
1
- export * from './base-date-field.model';
2
- export * from './date-picker-field.model';
3
- export * from './date-range-field.model';
1
+ export * from './base-date-field.model';
2
+ export * from './date-picker-field.model';
3
+ export * from './date-range-field.model';
@@ -0,0 +1,10 @@
1
+ import { EmbeddedProperty } from "ng-zorro-antd/grid";
2
+
3
+ export interface FieldGrid {
4
+ xs?: string | number | EmbeddedProperty | null;
5
+ sm?: string | number | EmbeddedProperty | null;
6
+ md?: string | number | EmbeddedProperty | null;
7
+ lg?: string | number | EmbeddedProperty | null;
8
+ xl?: string | number | EmbeddedProperty | null;
9
+ xxl?: string | number | EmbeddedProperty | null;
10
+ }
@@ -0,0 +1,50 @@
1
+ import { TemplateRef } from '@angular/core';
2
+ import { BaseField } from './field.model';
3
+
4
+ // Dữ liệu sau khi đã tiến hành xử lý gom nhóm từ fields và groups.
5
+ export class GroupedFields {
6
+ noGroup: BaseField<any>[];
7
+ grouped: {
8
+ group: FieldGroup;
9
+ fields: BaseField<any>[];
10
+ }[];
11
+
12
+ constructor(init: Partial<GroupedFields>) {
13
+ this.noGroup = [];
14
+ this.grouped = [];
15
+
16
+ Object.assign(this, init);
17
+ }
18
+ }
19
+
20
+ // Đại diện cho 1 group.
21
+ export class FieldGroup {
22
+ // Nhãn của nhóm field.
23
+ label!: string;
24
+
25
+ // Mã nhóm field.
26
+ code!: string;
27
+
28
+ template?: TemplateRef<any>;
29
+
30
+ // Thứ tự hiển thị nhóm field.
31
+ order!: number;
32
+
33
+ // Có mở sẵn collapse hay không?
34
+ isActive: boolean;
35
+
36
+ showArrow: boolean;
37
+
38
+ required: boolean;
39
+
40
+ disabled: boolean;
41
+
42
+ constructor(init: Partial<FieldGroup>) {
43
+ this.isActive = false;
44
+ this.showArrow = true;
45
+ this.disabled = false;
46
+ this.required = false;
47
+
48
+ Object.assign(this, init);
49
+ }
50
+ }
@@ -0,0 +1,8 @@
1
+ export interface FieldUserConfig {
2
+ // Tại form public, cho phép người dùng bật/tắt required của một field đang thao tác.
3
+ allowOverrideRequired?: boolean;
4
+
5
+ // Sau này có thể mở rộng thêm:
6
+ // allowToggleVisibility?: boolean;
7
+ // allowToggleReadonly?: boolean;
8
+ }
@@ -0,0 +1,184 @@
1
+ import { FormControl, ValidatorFn, Validators } from "@angular/forms";
2
+ import { FIELD_TYPES } from "../../consts/fields";
3
+ import { matchFieldsValidator } from "../../utils/validators/custom-validators";
4
+ import { FieldGrid } from "./field-grid.model";
5
+ import { NzLabelAlignType } from "ng-zorro-antd/form";
6
+ import {
7
+ CommonValidaterEnum,
8
+ CustomValidaterEnum,
9
+ } from "../../enums/validators";
10
+ import { ControlType } from "../controls";
11
+ import { FormMode } from "../form";
12
+ import { FormModeEnum } from "../../enums/form";
13
+ import { uuidGenerator } from "../../utils/common";
14
+ import { ViewMode } from "../common";
15
+ import { ViewModeEnum } from "../../enums/common";
16
+ import { FieldUserConfig } from "../fields/field-user-config.model";
17
+
18
+ /**
19
+ * typeof FIELD_TYPES[number] có nghĩa là:
20
+ - FIELD_TYPES là readonly ['input', 'select', 'checkbox']
21
+ - FIELD_TYPES[number] = FIELD_TYPES[0] | FIELD_TYPES[1] | ... = 'input' | 'select' | 'checkbox'
22
+ => FieldType = 'input' | 'select' | 'checkbox'
23
+ */
24
+ export type FieldType = (typeof FIELD_TYPES)[number];
25
+
26
+ /**
27
+ * Abstract class chung cho Field.
28
+ */
29
+ export abstract class BaseField<T> {
30
+ id: string;
31
+
32
+ // Giá trị Binding với Reactive Form dùng ở formControlName.
33
+ key!: string;
34
+
35
+ // Nhãn hiển thị tên của Field.
36
+ label!: string;
37
+
38
+ // Giá trị của Field.
39
+ value?: T;
40
+
41
+ // Giá trị ban đầu để reset.
42
+ initialValue?: T;
43
+
44
+ // Giá gốc từ model.
45
+ modelValue?: T;
46
+
47
+ // Loại Field: input-text, single-select,...
48
+ type!: FieldType;
49
+
50
+ // Loại control: input, select,... gom nhóm các dạng field.
51
+ controlType!: ControlType;
52
+
53
+ // Nhãn hint.
54
+ placeholder?: string;
55
+
56
+ // Hiển thị text khi hover.
57
+ tooltip?: string;
58
+
59
+ /** Props validation chung */
60
+ required: boolean;
61
+
62
+ /** Props validation custom chung */
63
+ matchField?: string;
64
+
65
+ icon?: string;
66
+
67
+ // Custom error message theo validation props.
68
+ errorMessages?: Record<string, string>;
69
+
70
+ // Grid layout của Field.
71
+ grid: FieldGrid;
72
+
73
+ // Grid layout của Label nằm trong Field.
74
+ labelGrid: FieldGrid;
75
+
76
+ // Vị trí của Label khi ở trong một khối cụ thể.
77
+ labelAlign: NzLabelAlignType;
78
+
79
+ // Grid layout của Control nằm trong Field.
80
+ controlGrid: FieldGrid;
81
+
82
+ // Ẩn field và không thao tác bất kì gì liên quan.
83
+ isHidden: boolean;
84
+
85
+ // Vô hiệu hóa field.
86
+ isDisabled: boolean;
87
+
88
+ // Đánh dấu giá trị của field sẽ cần cho field khác có thuộc tính dependsOn.
89
+ isParent: boolean;
90
+
91
+ // Cho phép gán first data ở cả mode add hoặc edit hay không.
92
+ allowSetValue: FormMode[];
93
+
94
+ // Gom nhóm field theo mã của nhóm. Mã này sẽ config theo code của FieldGroup model và config ở FE.
95
+ groupCode?: string; // Không thuộc nhóm thì bỏ trống hoặc điền None.
96
+
97
+ // Mode view: form (view theo control được disable) hoặc text (chỉ hiện thị text có thể là paragraph). Riêng upload thì không áp dụng vì không phân biệt control.
98
+ viewMode: ViewMode;
99
+
100
+ // Nhãn phu hiển thị tên của Field.
101
+ sublabel?: string;
102
+
103
+ // Thứ tự hiển thị của field
104
+ seqNum: number = 0;
105
+
106
+ // Cho phép field phát sự kiện change khi thay đổi giá trị.
107
+ enableFieldChange: boolean;
108
+
109
+ // Cấu hình các tính năng cho phép người dùng tự thay đổi trên field
110
+ userConfigs?: FieldUserConfig;
111
+
112
+ constructor(init?: Partial<BaseField<T>>) {
113
+ if (!init?.key || !init?.label) {
114
+ throw new Error("key, label, and type are required");
115
+ }
116
+
117
+ /**
118
+ * Gán giá trị cho các props cần giá trị mặc định ở BaseField.
119
+ */
120
+ this.id = uuidGenerator();
121
+ this.required = false;
122
+ this.grid = { xs: 24 };
123
+ this.labelGrid = { xs: 24 };
124
+ this.controlGrid = { xs: 24 };
125
+ this.labelAlign = "left";
126
+ this.isHidden = false;
127
+ this.isDisabled = false;
128
+ this.isParent = false;
129
+ this.allowSetValue = [
130
+ FormModeEnum.Add,
131
+ FormModeEnum.Edit,
132
+ FormModeEnum.View,
133
+ ];
134
+ this.viewMode = ViewModeEnum.form;
135
+ this.enableFieldChange = false;
136
+
137
+ Object.assign(this, init);
138
+ }
139
+
140
+ // Tạo control cho từng loại field.
141
+ abstract toFormControl(): FormControl;
142
+
143
+ // Default value ban đầu cho từng loại field.
144
+ abstract getDefaultValue(): T;
145
+
146
+ abstract toFormValue(modelValue: unknown): T;
147
+
148
+ // Tạo các validate chung cho các props ở abstract. this khi gọi trong class con sẽ đại diện cho đối tượng tạo từ class đó.
149
+ protected getCommonValidators(): ValidatorFn[] {
150
+ const validators: ValidatorFn[] = [];
151
+
152
+ if (this.required) validators.push(Validators.required);
153
+
154
+ return validators;
155
+ }
156
+
157
+ // Tạo các validate custom chung cho các props ở abstract. this khi gọi trong class con sẽ đại diện cho đối tượng tạo từ class đó.
158
+ protected getCustomValidators(): ValidatorFn[] {
159
+ const validators: ValidatorFn[] = [];
160
+
161
+ if (this.matchField) validators.push(matchFieldsValidator(this.matchField));
162
+
163
+ return validators;
164
+ }
165
+
166
+ getErrorMessage(
167
+ errorKey: string,
168
+ errorValue: any,
169
+ allFields: BaseField<any>[],
170
+ ): string {
171
+ if (errorKey === CommonValidaterEnum.Required) {
172
+ return `${this.label || "Trường này"} là bắt buộc`;
173
+ }
174
+
175
+ if (errorKey === CustomValidaterEnum.MatchField) {
176
+ const matchKey = this.matchField;
177
+ const targetLabel =
178
+ allFields.find((f) => f.key === matchKey)?.label || matchKey;
179
+ return `${this.label} không khớp với ${targetLabel}`;
180
+ }
181
+
182
+ return "";
183
+ }
184
+ }
@@ -1,2 +1,2 @@
1
- export * from "./field.model";
2
- export * from "./field-user-config.model";
1
+ export * from "./field.model";
2
+ export * from "./field-user-config.model";
@@ -1,4 +1,4 @@
1
- export * from "./input-field.model";
2
- export * from "./input-text-field.model";
3
- export * from "./input-password-field.model";
4
- export * from "./input-formatted-field.model";
1
+ export * from "./input-field.model";
2
+ export * from "./input-text-field.model";
3
+ export * from "./input-password-field.model";
4
+ export * from "./input-formatted-field.model";