@mediusinc/mng-commons 0.8.0-rc.2 → 0.9.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 (299) hide show
  1. package/assets/i18n/en.json +3 -1
  2. package/assets/i18n/sl.json +3 -1
  3. package/esm2020/lib/api/models/builders/query-param.builder.mjs +58 -58
  4. package/esm2020/lib/api/models/filter-match-type.model.mjs +24 -24
  5. package/esm2020/lib/api/models/filter-param.model.mjs +32 -32
  6. package/esm2020/lib/api/models/index.mjs +8 -8
  7. package/esm2020/lib/api/models/mappers.mjs +12 -12
  8. package/esm2020/lib/api/models/query-mode.model.mjs +17 -17
  9. package/esm2020/lib/api/models/query-param.model.mjs +67 -67
  10. package/esm2020/lib/api/models/query-result.model.mjs +17 -17
  11. package/esm2020/lib/api/models/serialization.model.mjs +1 -1
  12. package/esm2020/lib/api/services/api.abstract.service.mjs +55 -55
  13. package/esm2020/lib/api/services/crud-api.abstract.service.mjs +66 -66
  14. package/esm2020/lib/api/services/get-all-api.abstract.service.mjs +22 -22
  15. package/esm2020/lib/api/services/index.mjs +3 -3
  16. package/esm2020/lib/api/utils/index.mjs +2 -2
  17. package/esm2020/lib/api/utils/medius-rest.util.mjs +152 -152
  18. package/esm2020/lib/api/utils/object-serializer.util.mjs +243 -243
  19. package/esm2020/lib/components/action/action.component.mjs +178 -177
  20. package/esm2020/lib/components/action/editor/action-editor.component.mjs +248 -230
  21. package/esm2020/lib/components/action/index.mjs +3 -3
  22. package/esm2020/lib/components/action/models/action-confirmation-service.model.mjs +1 -1
  23. package/esm2020/lib/components/action/models/action-execution.model.mjs +234 -234
  24. package/esm2020/lib/components/action/models/index.mjs +2 -2
  25. package/esm2020/lib/components/action/route/action-route.component.mjs +125 -125
  26. package/esm2020/lib/components/form/autocomplete/autocomplete.component.mjs +268 -268
  27. package/esm2020/lib/components/form/dropdown/dropdown.component.mjs +160 -160
  28. package/esm2020/lib/components/form/editor/form-editor.component.mjs +189 -189
  29. package/esm2020/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +18 -18
  30. package/esm2020/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +42 -42
  31. package/esm2020/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.mjs +25 -25
  32. package/esm2020/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.mjs +96 -96
  33. package/esm2020/lib/components/form/formly/fields/formly-field-label/formly-field-label.component.mjs +16 -16
  34. package/esm2020/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +179 -179
  35. package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +155 -156
  36. package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +127 -127
  37. package/esm2020/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.mjs +16 -16
  38. package/esm2020/lib/components/form/formly/fields/index.mjs +9 -9
  39. package/esm2020/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.mjs +14 -14
  40. package/esm2020/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.mjs +14 -14
  41. package/esm2020/lib/components/form/formly/wrappers/index.mjs +2 -2
  42. package/esm2020/lib/components/form/index.mjs +3 -3
  43. package/esm2020/lib/components/form/models/form-editor.event.mjs +33 -33
  44. package/esm2020/lib/components/form/models/index.mjs +1 -1
  45. package/esm2020/lib/components/layout/breadcrumb.component.mjs +16 -16
  46. package/esm2020/lib/components/layout/footer.component.mjs +16 -16
  47. package/esm2020/lib/components/layout/index.mjs +6 -6
  48. package/esm2020/lib/components/layout/main-layout.component.mjs +51 -51
  49. package/esm2020/lib/components/layout/menu-item.component.mjs +216 -216
  50. package/esm2020/lib/components/layout/menu.component.mjs +19 -19
  51. package/esm2020/lib/components/layout/services/index.mjs +1 -1
  52. package/esm2020/lib/components/layout/services/main-layout.component.service.mjs +192 -192
  53. package/esm2020/lib/components/layout/topbar.component.mjs +57 -57
  54. package/esm2020/lib/components/tableview/index.mjs +6 -6
  55. package/esm2020/lib/components/tableview/models/index.mjs +1 -1
  56. package/esm2020/lib/components/tableview/models/table.event.mjs +15 -15
  57. package/esm2020/lib/components/tableview/route/tableview-route.abstract.component.mjs +58 -56
  58. package/esm2020/lib/components/tableview/route/tableview-route.component.mjs +53 -53
  59. package/esm2020/lib/components/tableview/table/column-filter/column-filter.component.mjs +102 -102
  60. package/esm2020/lib/components/tableview/table/column-value/column-value.component.mjs +71 -46
  61. package/esm2020/lib/components/tableview/table/table.component.mjs +428 -430
  62. package/esm2020/lib/components/tableview/tableview.component.mjs +92 -92
  63. package/esm2020/lib/config/formly.config.mjs +180 -180
  64. package/esm2020/lib/config/index.mjs +1 -1
  65. package/esm2020/lib/config/models/index.mjs +1 -1
  66. package/esm2020/lib/config/models/mng-config.model.mjs +1 -1
  67. package/esm2020/lib/data-providers/base.data-provider.mjs +16 -16
  68. package/esm2020/lib/data-providers/editor.data-provider.mjs +36 -36
  69. package/esm2020/lib/data-providers/index.mjs +5 -5
  70. package/esm2020/lib/data-providers/lookup.data-provider.mjs +15 -15
  71. package/esm2020/lib/data-providers/table.data-provider.mjs +16 -16
  72. package/esm2020/lib/data-providers/tableview.data-provider.mjs +16 -16
  73. package/esm2020/lib/descriptors/action.descriptor.mjs +566 -623
  74. package/esm2020/lib/descriptors/column.descriptor.mjs +261 -256
  75. package/esm2020/lib/descriptors/editor.descriptor.mjs +147 -155
  76. package/esm2020/lib/descriptors/field-validation.descriptor.mjs +20 -20
  77. package/esm2020/lib/descriptors/field.descriptor.mjs +800 -864
  78. package/esm2020/lib/descriptors/filter.descriptor.mjs +262 -295
  79. package/esm2020/lib/descriptors/index.mjs +10 -12
  80. package/esm2020/lib/descriptors/interfaces/field-config.interface.mjs +2 -0
  81. package/esm2020/lib/descriptors/interfaces/index.mjs +3 -0
  82. package/esm2020/lib/descriptors/interfaces/lookup-descriptor.interface.mjs +2 -0
  83. package/esm2020/lib/descriptors/model.descriptor.mjs +33 -33
  84. package/esm2020/lib/descriptors/table.descriptor.mjs +197 -214
  85. package/esm2020/lib/descriptors/tableview.descriptor.mjs +135 -135
  86. package/esm2020/lib/descriptors/types/action.type.mjs +53 -0
  87. package/esm2020/lib/descriptors/types/column.type.mjs +11 -0
  88. package/esm2020/lib/descriptors/types/editor.type.mjs +8 -0
  89. package/esm2020/lib/descriptors/types/field.type.mjs +53 -0
  90. package/esm2020/lib/descriptors/types/filter.type.mjs +31 -0
  91. package/esm2020/lib/descriptors/types/index.mjs +7 -0
  92. package/esm2020/lib/descriptors/types/table.type.mjs +17 -0
  93. package/esm2020/lib/directives/component.directive.mjs +43 -43
  94. package/esm2020/lib/directives/index.mjs +2 -2
  95. package/esm2020/lib/directives/template.directive.mjs +27 -27
  96. package/esm2020/lib/mng-commons.module.mjs +426 -426
  97. package/esm2020/lib/models/column-value.model.mjs +1 -1
  98. package/esm2020/lib/models/enum.model.mjs +1 -1
  99. package/esm2020/lib/models/error.model.mjs +1 -1
  100. package/esm2020/lib/models/index.mjs +6 -6
  101. package/esm2020/lib/models/menu.model.mjs +1 -1
  102. package/esm2020/lib/models/user.model.mjs +1 -1
  103. package/esm2020/lib/models/view-container.model.mjs +1 -1
  104. package/esm2020/lib/pipes/boolean.pipe.mjs +26 -26
  105. package/esm2020/lib/pipes/enum.pipe.mjs +25 -25
  106. package/esm2020/lib/pipes/i18n-property.pipe.mjs +17 -17
  107. package/esm2020/lib/pipes/index.mjs +5 -5
  108. package/esm2020/lib/pipes/json-path.pipe.mjs +79 -79
  109. package/esm2020/lib/pipes/link-formatter.pipe.mjs +38 -38
  110. package/esm2020/lib/router/index.mjs +1 -1
  111. package/esm2020/lib/router/models/index.mjs +1 -1
  112. package/esm2020/lib/router/models/router.model.mjs +1 -1
  113. package/esm2020/lib/router/route-builder.mjs +431 -431
  114. package/esm2020/lib/services/action-executor.service.mjs +536 -535
  115. package/esm2020/lib/services/commons.service.mjs +328 -344
  116. package/esm2020/lib/services/configuration.service.mjs +110 -110
  117. package/esm2020/lib/services/error-mapper.service.mjs +13 -13
  118. package/esm2020/lib/services/index.mjs +6 -6
  119. package/esm2020/lib/services/internal/commons-init.provider.mjs +3 -3
  120. package/esm2020/lib/services/internal/commons-init.service.mjs +43 -43
  121. package/esm2020/lib/services/internal/index.mjs +2 -2
  122. package/esm2020/lib/services/navigation.service.mjs +47 -47
  123. package/esm2020/lib/services/providers/config-service.provider.mjs +29 -29
  124. package/esm2020/lib/services/providers/formly-config.provider.mjs +30 -30
  125. package/esm2020/lib/services/providers/index.mjs +2 -2
  126. package/esm2020/lib/services/tokens/browser-storage.token.mjs +5 -5
  127. package/esm2020/lib/services/tokens/commons-init.token.mjs +2 -2
  128. package/esm2020/lib/services/tokens/default-setting.token.mjs +2 -2
  129. package/esm2020/lib/services/tokens/index.mjs +4 -4
  130. package/esm2020/lib/services/tokens/module-config.token.mjs +2 -2
  131. package/esm2020/lib/services/view-container.component.service.mjs +34 -34
  132. package/esm2020/lib/types/index.mjs +2 -2
  133. package/esm2020/lib/types/type.decorator.mjs +12 -12
  134. package/esm2020/lib/types/type.model.mjs +2 -2
  135. package/esm2020/lib/utils/action-data-provider.util.mjs +144 -144
  136. package/esm2020/lib/utils/editor-formly.util.mjs +211 -210
  137. package/esm2020/lib/utils/enum.util.mjs +81 -81
  138. package/esm2020/lib/utils/i18n.util.mjs +232 -232
  139. package/esm2020/lib/utils/index.mjs +7 -7
  140. package/esm2020/lib/utils/model.util.mjs +60 -60
  141. package/esm2020/lib/utils/notification.util.mjs +45 -45
  142. package/esm2020/lib/utils/route.util.mjs +23 -23
  143. package/esm2020/lib/utils/styles.util.mjs +41 -41
  144. package/esm2020/lib/utils/type.util.mjs +76 -76
  145. package/esm2020/mediusinc-mng-commons.mjs +4 -4
  146. package/esm2020/public-api.mjs +42 -40
  147. package/fesm2015/mediusinc-mng-commons.mjs +9874 -9861
  148. package/fesm2015/mediusinc-mng-commons.mjs.map +1 -1
  149. package/fesm2020/mediusinc-mng-commons.mjs +9739 -9727
  150. package/fesm2020/mediusinc-mng-commons.mjs.map +1 -1
  151. package/lib/api/models/builders/query-param.builder.d.ts +13 -13
  152. package/lib/api/models/filter-match-type.model.d.ts +23 -23
  153. package/lib/api/models/filter-param.model.d.ts +23 -23
  154. package/lib/api/models/index.d.ts +8 -8
  155. package/lib/api/models/mappers.d.ts +6 -6
  156. package/lib/api/models/query-mode.model.d.ts +16 -16
  157. package/lib/api/models/query-param.model.d.ts +31 -31
  158. package/lib/api/models/query-result.model.d.ts +23 -23
  159. package/lib/api/models/serialization.model.d.ts +8 -8
  160. package/lib/api/services/api.abstract.service.d.ts +24 -24
  161. package/lib/api/services/crud-api.abstract.service.d.ts +22 -22
  162. package/lib/api/services/get-all-api.abstract.service.d.ts +14 -14
  163. package/lib/api/services/index.d.ts +3 -3
  164. package/lib/api/utils/index.d.ts +2 -2
  165. package/lib/api/utils/medius-rest.util.d.ts +15 -14
  166. package/lib/api/utils/object-serializer.util.d.ts +33 -33
  167. package/lib/components/action/action.component.d.ts +69 -68
  168. package/lib/components/action/editor/action-editor.component.d.ts +64 -62
  169. package/lib/components/action/index.d.ts +3 -3
  170. package/lib/components/action/models/action-confirmation-service.model.d.ts +6 -6
  171. package/lib/components/action/models/action-execution.model.d.ts +129 -129
  172. package/lib/components/action/models/index.d.ts +2 -2
  173. package/lib/components/action/route/action-route.component.d.ts +31 -31
  174. package/lib/components/form/autocomplete/autocomplete.component.d.ts +53 -53
  175. package/lib/components/form/dropdown/dropdown.component.d.ts +44 -44
  176. package/lib/components/form/editor/form-editor.component.d.ts +45 -45
  177. package/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.d.ts +12 -12
  178. package/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.d.ts +14 -14
  179. package/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.d.ts +13 -12
  180. package/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.d.ts +21 -21
  181. package/lib/components/form/formly/fields/formly-field-label/formly-field-label.component.d.ts +6 -6
  182. package/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.d.ts +45 -44
  183. package/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.d.ts +22 -22
  184. package/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +37 -37
  185. package/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.d.ts +6 -6
  186. package/lib/components/form/formly/fields/index.d.ts +9 -9
  187. package/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.d.ts +6 -6
  188. package/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.d.ts +6 -6
  189. package/lib/components/form/formly/wrappers/index.d.ts +2 -2
  190. package/lib/components/form/index.d.ts +3 -3
  191. package/lib/components/form/models/form-editor.event.d.ts +37 -37
  192. package/lib/components/form/models/index.d.ts +1 -1
  193. package/lib/components/layout/breadcrumb.component.d.ts +8 -8
  194. package/lib/components/layout/footer.component.d.ts +9 -9
  195. package/lib/components/layout/index.d.ts +6 -6
  196. package/lib/components/layout/main-layout.component.d.ts +20 -20
  197. package/lib/components/layout/menu-item.component.d.ts +37 -37
  198. package/lib/components/layout/menu.component.d.ts +10 -10
  199. package/lib/components/layout/services/index.d.ts +1 -1
  200. package/lib/components/layout/services/main-layout.component.service.d.ts +65 -65
  201. package/lib/components/layout/topbar.component.d.ts +24 -24
  202. package/lib/components/tableview/index.d.ts +6 -6
  203. package/lib/components/tableview/models/index.d.ts +1 -1
  204. package/lib/components/tableview/models/table.event.d.ts +17 -17
  205. package/lib/components/tableview/route/tableview-route.abstract.component.d.ts +20 -20
  206. package/lib/components/tableview/route/tableview-route.component.d.ts +18 -18
  207. package/lib/components/tableview/table/column-filter/column-filter.component.d.ts +32 -31
  208. package/lib/components/tableview/table/column-value/column-value.component.d.ts +29 -19
  209. package/lib/components/tableview/table/table.component.d.ts +105 -104
  210. package/lib/components/tableview/tableview.component.d.ts +41 -41
  211. package/lib/config/formly.config.d.ts +15 -15
  212. package/lib/config/index.d.ts +1 -1
  213. package/lib/config/models/index.d.ts +1 -1
  214. package/lib/config/models/mng-config.model.d.ts +34 -34
  215. package/lib/data-providers/base.data-provider.d.ts +14 -14
  216. package/lib/data-providers/editor.data-provider.d.ts +25 -25
  217. package/lib/data-providers/index.d.ts +5 -5
  218. package/lib/data-providers/lookup.data-provider.d.ts +14 -14
  219. package/lib/data-providers/table.data-provider.d.ts +14 -14
  220. package/lib/data-providers/tableview.data-provider.d.ts +15 -15
  221. package/lib/descriptors/action.descriptor.d.ts +227 -277
  222. package/lib/descriptors/column.descriptor.d.ts +81 -86
  223. package/lib/descriptors/editor.descriptor.d.ts +37 -44
  224. package/lib/descriptors/field-validation.descriptor.d.ts +18 -18
  225. package/lib/descriptors/field.descriptor.d.ts +287 -342
  226. package/lib/descriptors/filter.descriptor.d.ts +97 -127
  227. package/lib/descriptors/index.d.ts +9 -11
  228. package/lib/descriptors/{field.descriptor.interface.d.ts → interfaces/field-config.interface.d.ts} +9 -9
  229. package/lib/descriptors/interfaces/index.d.ts +2 -0
  230. package/lib/descriptors/{lookup.descriptor.d.ts → interfaces/lookup-descriptor.interface.d.ts} +17 -17
  231. package/lib/descriptors/model.descriptor.d.ts +15 -15
  232. package/lib/descriptors/table.descriptor.d.ts +66 -80
  233. package/lib/descriptors/tableview.descriptor.d.ts +42 -42
  234. package/lib/descriptors/types/action.type.d.ts +45 -0
  235. package/lib/descriptors/types/column.type.d.ts +9 -0
  236. package/lib/descriptors/types/editor.type.d.ts +6 -0
  237. package/lib/descriptors/types/field.type.d.ts +44 -0
  238. package/lib/descriptors/types/filter.type.d.ts +27 -0
  239. package/lib/descriptors/types/index.d.ts +6 -0
  240. package/lib/descriptors/types/table.type.d.ts +13 -0
  241. package/lib/directives/component.directive.d.ts +16 -16
  242. package/lib/directives/index.d.ts +2 -2
  243. package/lib/directives/template.directive.d.ts +13 -13
  244. package/lib/mng-commons.module.d.ts +86 -86
  245. package/lib/models/column-value.model.d.ts +4 -4
  246. package/lib/models/enum.model.d.ts +6 -6
  247. package/lib/models/error.model.d.ts +14 -14
  248. package/lib/models/index.d.ts +6 -6
  249. package/lib/models/menu.model.d.ts +25 -25
  250. package/lib/models/user.model.d.ts +8 -8
  251. package/lib/models/view-container.model.d.ts +6 -6
  252. package/lib/pipes/boolean.pipe.d.ts +7 -7
  253. package/lib/pipes/enum.pipe.d.ts +8 -8
  254. package/lib/pipes/i18n-property.pipe.d.ts +8 -8
  255. package/lib/pipes/index.d.ts +5 -5
  256. package/lib/pipes/json-path.pipe.d.ts +13 -13
  257. package/lib/pipes/link-formatter.pipe.d.ts +11 -11
  258. package/lib/router/index.d.ts +1 -1
  259. package/lib/router/models/index.d.ts +1 -1
  260. package/lib/router/models/router.model.d.ts +22 -22
  261. package/lib/router/route-builder.d.ts +86 -86
  262. package/lib/services/action-executor.service.d.ts +149 -149
  263. package/lib/services/commons.service.d.ts +72 -72
  264. package/lib/services/configuration.service.d.ts +36 -36
  265. package/lib/services/error-mapper.service.d.ts +7 -7
  266. package/lib/services/index.d.ts +6 -6
  267. package/lib/services/internal/commons-init.provider.d.ts +3 -3
  268. package/lib/services/internal/commons-init.service.d.ts +16 -16
  269. package/lib/services/internal/index.d.ts +2 -2
  270. package/lib/services/navigation.service.d.ts +14 -14
  271. package/lib/services/providers/config-service.provider.d.ts +6 -6
  272. package/lib/services/providers/formly-config.provider.d.ts +4 -4
  273. package/lib/services/providers/index.d.ts +2 -2
  274. package/lib/services/tokens/browser-storage.token.d.ts +2 -2
  275. package/lib/services/tokens/commons-init.token.d.ts +3 -3
  276. package/lib/services/tokens/default-setting.token.d.ts +2 -2
  277. package/lib/services/tokens/index.d.ts +4 -4
  278. package/lib/services/tokens/module-config.token.d.ts +3 -3
  279. package/lib/services/view-container.component.service.d.ts +22 -22
  280. package/lib/types/index.d.ts +2 -2
  281. package/lib/types/type.decorator.d.ts +4 -4
  282. package/lib/types/type.model.d.ts +20 -20
  283. package/lib/utils/action-data-provider.util.d.ts +20 -20
  284. package/lib/utils/editor-formly.util.d.ts +10 -10
  285. package/lib/utils/enum.util.d.ts +50 -50
  286. package/lib/utils/i18n.util.d.ts +56 -56
  287. package/lib/utils/index.d.ts +7 -7
  288. package/lib/utils/model.util.d.ts +8 -8
  289. package/lib/utils/notification.util.d.ts +11 -11
  290. package/lib/utils/route.util.d.ts +4 -4
  291. package/lib/utils/styles.util.d.ts +14 -14
  292. package/lib/utils/type.util.d.ts +36 -36
  293. package/mediusinc-mng-commons.d.ts +5 -5
  294. package/package.json +3 -3
  295. package/public-api.d.ts +30 -28
  296. package/scss/mng-overrides/_theme_datatable.scss +2 -0
  297. package/esm2020/lib/descriptors/field.descriptor.interface.mjs +0 -2
  298. package/esm2020/lib/descriptors/lookup.descriptor.mjs +0 -2
  299. package/mediusinc-mng-commons-0.8.0-rc.2.tgz +0 -0
@@ -1,82 +1,82 @@
1
- export class EnumUtil {
2
- /**
3
- * Returns array of names for constants in enum.
4
- * @param enumType Enum object.
5
- */
6
- static getConstantNames(enumType) {
7
- return EnumUtil.getConstantNamesFromEnumObject(enumType);
8
- }
9
- /**
10
- * Returns array of names for constants in enum.
11
- * @param enumObj Enum object.
12
- */
13
- static getConstantNamesFromEnumObject(enumObj) {
14
- // in number enum, the numbers are also represented in objects and should be filtered out
15
- return Object.keys(enumObj).filter(v => isNaN(+v));
16
- }
17
- /**
18
- * Returns array of string values for constants in enum.
19
- * @param enumType Enum object.
20
- */
21
- static getConstantValuesAsString(enumType) {
22
- return Object.keys(enumType).map(v => enumType[v]);
23
- }
24
- /**
25
- * Returns array of number values for constants in enum.
26
- * @param enumType Enum object.
27
- */
28
- static getConstantValuesAsNumber(enumType) {
29
- return Object.keys(enumType)
30
- .filter(v => !isNaN(+v))
31
- .map(v => +v);
32
- }
33
- /**
34
- * Returns array of type EnumValue for all constants in enum.
35
- * @param enumType Enum object.
36
- * @param nameAsValue If use name of constant as value (optional, default: false).
37
- * @param titlePath Base path for title to use as translation (optional).
38
- */
39
- static fromConstantsAsEnumValueArray(enumType, nameAsValue = false, titlePath) {
40
- return EnumUtil.getConstantNames(enumType).map(n => ({ name: n, title: `${titlePath ? `${titlePath}.` : ''}${n}`, value: nameAsValue ? n : enumType[n] }));
41
- }
42
- /**
43
- * Returns array of type EnumValue for provided values in enum.
44
- * @param enumType Enum object.
45
- * @param nameAsValue If use name of constant as value (optional, default: false).
46
- * @param titlePath Base path for title to use as translation (optional).
47
- */
48
- static fromValuesAsEnumValueArray(enumType, values, nameAsValue = false, titlePath) {
49
- return values.map(v => {
50
- const k = EnumUtil.getConstantName(enumType, v);
51
- return { name: k, title: `${titlePath ? `${titlePath}.` : ''}${k}`, value: nameAsValue ? k : v };
52
- });
53
- }
54
- /**
55
- * Gets constant name for value.
56
- * @param enumType Enum object.
57
- * @param value Value of enum constant.
58
- */
59
- static getConstantName(enumType, value) {
60
- if (typeof value === 'string') {
61
- return EnumUtil.getConstantNames(enumType).find(c => enumType[c] === value) ?? null;
62
- }
63
- else {
64
- return typeof enumType[value] !== 'undefined' ? enumType[value] : null;
65
- }
66
- }
67
- /**
68
- * Gets constant name for value.
69
- * @param enumObj Enum object.
70
- * @param value Value of enum constant.
71
- */
72
- static getConstantNameFromEnumObject(enumObj, value) {
73
- const enumObjAny = enumObj;
74
- if (typeof value === 'string') {
75
- return EnumUtil.getConstantNamesFromEnumObject(enumObj).find(c => enumObjAny[c] === value) ?? null;
76
- }
77
- else {
78
- return typeof enumObjAny[value] !== 'undefined' ? enumObjAny[value] : null;
79
- }
80
- }
81
- }
1
+ export class EnumUtil {
2
+ /**
3
+ * Returns array of names for constants in enum.
4
+ * @param enumType Enum object.
5
+ */
6
+ static getConstantNames(enumType) {
7
+ return EnumUtil.getConstantNamesFromEnumObject(enumType);
8
+ }
9
+ /**
10
+ * Returns array of names for constants in enum.
11
+ * @param enumObj Enum object.
12
+ */
13
+ static getConstantNamesFromEnumObject(enumObj) {
14
+ // in number enum, the numbers are also represented in objects and should be filtered out
15
+ return Object.keys(enumObj).filter(v => isNaN(+v));
16
+ }
17
+ /**
18
+ * Returns array of string values for constants in enum.
19
+ * @param enumType Enum object.
20
+ */
21
+ static getConstantValuesAsString(enumType) {
22
+ return Object.keys(enumType).map(v => enumType[v]);
23
+ }
24
+ /**
25
+ * Returns array of number values for constants in enum.
26
+ * @param enumType Enum object.
27
+ */
28
+ static getConstantValuesAsNumber(enumType) {
29
+ return Object.keys(enumType)
30
+ .filter(v => !isNaN(+v))
31
+ .map(v => +v);
32
+ }
33
+ /**
34
+ * Returns array of type EnumValue for all constants in enum.
35
+ * @param enumType Enum object.
36
+ * @param nameAsValue If use name of constant as value (optional, default: false).
37
+ * @param titlePath Base path for title to use as translation (optional).
38
+ */
39
+ static fromConstantsAsEnumValueArray(enumType, nameAsValue = false, titlePath) {
40
+ return EnumUtil.getConstantNames(enumType).map(n => ({ name: n, title: `${titlePath ? `${titlePath}.` : ''}${n}`, value: nameAsValue ? n : enumType[n] }));
41
+ }
42
+ /**
43
+ * Returns array of type EnumValue for provided values in enum.
44
+ * @param enumType Enum object.
45
+ * @param nameAsValue If use name of constant as value (optional, default: false).
46
+ * @param titlePath Base path for title to use as translation (optional).
47
+ */
48
+ static fromValuesAsEnumValueArray(enumType, values, nameAsValue = false, titlePath) {
49
+ return values.map(v => {
50
+ const k = EnumUtil.getConstantName(enumType, v);
51
+ return { name: k, title: `${titlePath ? `${titlePath}.` : ''}${k}`, value: nameAsValue ? k : v };
52
+ });
53
+ }
54
+ /**
55
+ * Gets constant name for value.
56
+ * @param enumType Enum object.
57
+ * @param value Value of enum constant.
58
+ */
59
+ static getConstantName(enumType, value) {
60
+ if (typeof value === 'string') {
61
+ return EnumUtil.getConstantNames(enumType).find(c => enumType[c] === value) ?? null;
62
+ }
63
+ else {
64
+ return typeof enumType[value] !== 'undefined' ? enumType[value] : null;
65
+ }
66
+ }
67
+ /**
68
+ * Gets constant name for value.
69
+ * @param enumObj Enum object.
70
+ * @param value Value of enum constant.
71
+ */
72
+ static getConstantNameFromEnumObject(enumObj, value) {
73
+ const enumObjAny = enumObj;
74
+ if (typeof value === 'string') {
75
+ return EnumUtil.getConstantNamesFromEnumObject(enumObj).find(c => enumObjAny[c] === value) ?? null;
76
+ }
77
+ else {
78
+ return typeof enumObjAny[value] !== 'undefined' ? enumObjAny[value] : null;
79
+ }
80
+ }
81
+ }
82
82
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW51bS51dGlsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2xpYi91dGlscy9lbnVtLnV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsTUFBTSxPQUFPLFFBQVE7SUFDakI7OztPQUdHO0lBQ0ksTUFBTSxDQUFDLGdCQUFnQixDQUFDLFFBQWtCO1FBQzdDLE9BQU8sUUFBUSxDQUFDLDhCQUE4QixDQUFDLFFBQVEsQ0FBQyxDQUFDO0lBQzdELENBQUM7SUFFRDs7O09BR0c7SUFDSSxNQUFNLENBQUMsOEJBQThCLENBQUMsT0FBZTtRQUN4RCx5RkFBeUY7UUFDekYsT0FBTyxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDdkQsQ0FBQztJQUVEOzs7T0FHRztJQUNJLE1BQU0sQ0FBQyx5QkFBeUIsQ0FBQyxRQUFrQjtRQUN0RCxPQUFPLE1BQU0sQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsUUFBUS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