@zohodesk/library-platform 1.1.7 → 1.1.8-alpha.1

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 (307) hide show
  1. package/es/bc/sdk/ResourceNamesEnum.js +1 -0
  2. package/es/bc/zfield/FieldApiTypes.js +20 -0
  3. package/es/bc/zform/Properties.js +9 -0
  4. package/es/bc/zform/Symbol.js +7 -0
  5. package/es/bc/zlist/Constants.js +3 -1
  6. package/es/bc/zlist/Properties.js +3 -0
  7. package/es/bc/zrecord/Constants.js +3 -0
  8. package/es/cc/date/Properties.js +9 -0
  9. package/es/cc/fields/field/FormDefaultUIType.js +1 -1
  10. package/es/cc/fields/field/Properties.js +63 -0
  11. package/es/cc/fields/multi-select/Properties.js +9 -0
  12. package/es/cc/fields/pick-list/Properties.js +9 -0
  13. package/es/cc/fields/text/Properties.js +9 -0
  14. package/es/cc/form/Properties.js +71 -0
  15. package/es/cc/form-connected/Constants.js +8 -0
  16. package/es/cc/form-connected/Properties.js +87 -0
  17. package/es/cc/form-connected/SdkContract.js +61 -0
  18. package/es/cc/form-connected/index.js +2 -0
  19. package/es/cc/highlighted-value/Properties.js +10 -0
  20. package/es/cc/index.js +1 -1
  21. package/es/cc/multi-select/Properties.js +9 -0
  22. package/es/cc/select/Properties.js +12 -0
  23. package/es/cc/table-connected/Properties.js +8 -0
  24. package/es/cc/table-connected/constants/Events.js +1 -0
  25. package/es/cc/textarea/Properties.js +11 -0
  26. package/es/cc/textbox/Properties.js +11 -0
  27. package/es/index.js +4 -2
  28. package/es/library/behaviours/field-focus/frameworks/ui/EventHandlersFactory.js +26 -0
  29. package/es/library/behaviours/field-focus/frameworks/ui/FocusFieldBehaviourFactory.js +20 -0
  30. package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +3 -1
  31. package/es/library/dot/components/action-location/usecases/interactors/PropertiesChangeUseCase.js +1 -1
  32. package/es/library/dot/components/form/adapters/presenter/TransformState.js +14 -54
  33. package/es/library/dot/components/form/frameworks/ui/DefaultComponentRegister.js +2 -5
  34. package/es/library/dot/components/form/frameworks/ui/FormView.js +21 -39
  35. package/es/library/dot/components/form/frameworks/ui/css/Form.module.css +29 -4
  36. package/es/library/dot/components/form/frameworks/ui/sub-components/Footer.js +27 -0
  37. package/es/library/dot/components/form/frameworks/ui/sub-components/Header.js +24 -0
  38. package/es/library/dot/components/form/frameworks/ui/sub-components/MiddleSection.js +24 -0
  39. package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +7 -2
  40. package/es/library/dot/components/form/frameworks/ui/sub-components/SectionsLayout.js +20 -0
  41. package/es/library/dot/components/form/frameworks/ui/sub-components/SectionsWithRightPanelLayout.js +42 -0
  42. package/es/library/dot/components/form-fields/checkbox/frameworks/ui/Checkbox.js +4 -3
  43. package/es/library/dot/components/form-fields/checkbox/frameworks/ui/CheckboxView.js +19 -17
  44. package/es/library/dot/components/form-fields/currency/frameworks/ui/Currency.js +3 -3
  45. package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +20 -17
  46. package/es/library/dot/components/form-fields/date/frameworks/ui/Date.js +2 -3
  47. package/es/library/dot/components/form-fields/date/frameworks/ui/DateView.js +22 -19
  48. package/es/library/dot/components/form-fields/datetime/frameworks/ui/DateTime.js +2 -3
  49. package/es/library/dot/components/form-fields/datetime/frameworks/ui/DateTimeView.js +21 -18
  50. package/es/library/dot/components/form-fields/decimal/frameworks/ui/Decimal.js +2 -3
  51. package/es/library/dot/components/form-fields/decimal/frameworks/ui/DecimalView.js +22 -19
  52. package/es/library/dot/components/form-fields/email/frameworks/ui/Email.js +2 -3
  53. package/es/library/dot/components/form-fields/email/frameworks/ui/EmailView.js +22 -19
  54. package/es/library/dot/components/form-fields/field/FieldItem.js +36 -0
  55. package/es/library/dot/components/form-fields/field/css/FieldItem.module.css +13 -0
  56. package/es/library/dot/components/form-fields/index.js +2 -1
  57. package/es/library/dot/components/form-fields/lookup/frameworks/ui/EventHandlerFactory.js +70 -0
  58. package/es/library/dot/components/form-fields/lookup/frameworks/ui/Lookup.js +13 -0
  59. package/es/library/dot/components/form-fields/lookup/frameworks/ui/LookupView.js +51 -0
  60. package/es/library/dot/components/form-fields/multi-select/frameworks/ui/MultiSelect.js +2 -3
  61. package/es/library/dot/components/form-fields/multi-select/frameworks/ui/MultiSelectView.js +21 -18
  62. package/es/library/dot/components/form-fields/number/frameworks/ui/Number.js +2 -3
  63. package/es/library/dot/components/form-fields/number/frameworks/ui/NumberView.js +22 -19
  64. package/es/library/dot/components/form-fields/percentage/frameworks/ui/Percentage.js +2 -3
  65. package/es/library/dot/components/form-fields/percentage/frameworks/ui/PercentageView.js +22 -19
  66. package/es/library/dot/components/form-fields/phone/frameworks/ui/Phone.js +2 -3
  67. package/es/library/dot/components/form-fields/phone/frameworks/ui/PhoneView.js +22 -19
  68. package/es/library/dot/components/form-fields/pick-list/frameworks/ui/PickList.js +2 -3
  69. package/es/library/dot/components/form-fields/pick-list/frameworks/ui/PickListView.js +21 -18
  70. package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextArea.js +4 -3
  71. package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextAreaView.js +21 -18
  72. package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBox.js +2 -3
  73. package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBoxView.js +21 -18
  74. package/es/library/dot/components/form-fields/url/frameworks/ui/Url.js +2 -3
  75. package/es/library/dot/components/form-fields/url/frameworks/ui/UrlView.js +22 -19
  76. package/es/library/dot/components/section/frameworks/ui/SectionView.js +1 -1
  77. package/es/library/dot/components/table-list/frameworks/ui/sub-components/ErrorState.js +3 -3
  78. package/es/library/dot/legacy-to-new-arch/action-icon/frameworks/ui/ActionIconView.js +1 -1
  79. package/es/library/dot/legacy-to-new-arch/date/frameworks/ui/DateView.js +18 -1
  80. package/es/library/dot/legacy-to-new-arch/date/frameworks/ui/css/DateView.module.css +3 -0
  81. package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/HighlightedValueView.js +6 -1
  82. package/es/library/dot/{components/form-fields/ephi-tag/frameworks/ui/css/EPHITag.module.css → legacy-to-new-arch/highlighted-value/frameworks/ui/css/HighlightedValue.module.css} +1 -1
  83. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/LabelView.js +16 -12
  84. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/css/Label.module.css +3 -5
  85. package/es/library/dot/legacy-to-new-arch/multi-select/frameworks/ui/MultiSelectView.js +23 -3
  86. package/es/library/dot/legacy-to-new-arch/multi-select/frameworks/ui/css/MultiSelectView.module.css +37 -0
  87. package/es/library/dot/legacy-to-new-arch/select/frameworks/ui/SelectView.js +16 -4
  88. package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +23 -5
  89. package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/css/TextAreaView.module.css +40 -0
  90. package/es/library/dot/legacy-to-new-arch/textbox/frameworks/ui/TextBoxView.js +13 -3
  91. package/es/platform/client-actions/bc/zclient-actions/SdkContract.js +35 -0
  92. package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/ClientActionResource.js +105 -0
  93. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionLocationUseCase.js +20 -0
  94. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionUIComponentPropertiesUseCase.js +20 -0
  95. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionsUseCase.js +18 -0
  96. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/UpdateClientActionUIComponentPropertiesUseCase.js +32 -0
  97. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientAction.js +12 -0
  98. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientActionManager.js +45 -0
  99. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/UIComponentMapping.js +10 -0
  100. package/es/platform/client-actions/behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory.js +29 -0
  101. package/es/platform/client-actions/cc/action-event-mediator/Properties.js +9 -0
  102. package/es/platform/client-actions/cc/dynamic-action-component/Properties.js +1 -1
  103. package/es/platform/client-actions/components/action-event-mediator/applications/usecases/PropertiesChangeUseCase.js +1 -1
  104. package/es/platform/client-actions/components/action-event-mediator/domain/entities/ActionEventMediatorEntity.js +7 -3
  105. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediatorView.js +3 -1
  106. package/es/platform/client-actions/components/dynamic-component/frameworks/ui/DynamicActionComponentView.js +4 -2
  107. package/es/platform/client-actions/components/interfaces/ActionViewModel.js +1 -0
  108. package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRenderer.module.css +5 -1
  109. package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRendererView.js +4 -1
  110. package/es/platform/components/app/adapters/resources/AppResource.js +13 -0
  111. package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +88 -6
  112. package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +31 -58
  113. package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +6 -9
  114. package/es/platform/components/form-connected/frameworks/FormConnectedView.js +16 -2
  115. package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +2 -2
  116. package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +17 -3
  117. package/es/platform/components/table-connected/frameworks/ListSdkFactory.js +2 -2
  118. package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +6 -1
  119. package/es/platform/data-source/http-template/deleteRecords.js +1 -1
  120. package/es/platform/data-source/http-template/fetchLookupFields.js +24 -0
  121. package/es/platform/data-source/http-template/fetchValidationRules.js +2 -1
  122. package/es/platform/data-source/http-template/getClientActions.js +2 -2
  123. package/es/platform/data-source/http-template/moveToTrash.js +28 -0
  124. package/es/platform/data-source/index.js +5 -1
  125. package/es/platform/data-source/utils/validation-rules/FieldConditions.js +167 -0
  126. package/es/platform/data-source/utils/validation-rules/TransFormValidationRules.js +98 -0
  127. package/es/platform/sdk/adapters/gateways/Service.js +4 -0
  128. package/es/platform/sdk/application/usecases/GetResourcesUseCase.js +12 -0
  129. package/es/platform/sdk/domain/entities/ResourceManager.js +21 -11
  130. package/es/platform/sdk/frameworks/Sdk.js +20 -2
  131. package/es/platform/sdk/frameworks/SdkRegistry.js +9 -0
  132. package/es/platform/zdata-source/applications/usecases/SuccessUseCase.js +1 -1
  133. package/es/platform/zform/adapters/controllers/FieldBlurController.js +26 -0
  134. package/es/platform/zform/adapters/controllers/LookupFieldController.js +23 -0
  135. package/es/platform/zform/adapters/controllers/MyFromSuccessController.js +8 -2
  136. package/es/platform/zform/adapters/controllers/SubmitValidationCompletedController.js +21 -0
  137. package/es/platform/zform/adapters/controllers/ValidateFieldRequestController.js +10 -5
  138. package/es/platform/zform/adapters/controllers/ValidationRulesExecutionResultController.js +23 -0
  139. package/es/platform/zform/adapters/controllers/ValidationRulesRequestController.js +2 -4
  140. package/es/platform/zform/adapters/controllers/ValidationRulesSuccessController.js +2 -4
  141. package/es/platform/zform/adapters/gateway/Service.js +19 -7
  142. package/es/platform/zform/adapters/presenter/FormTranslator.js +87 -5
  143. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +61 -4
  144. package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +7 -3
  145. package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +5 -9
  146. package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +7 -3
  147. package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +7 -3
  148. package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +6 -9
  149. package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +6 -9
  150. package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +7 -10
  151. package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +6 -3
  152. package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +6 -9
  153. package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +6 -9
  154. package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +6 -9
  155. package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +6 -3
  156. package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +5 -9
  157. package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +8 -8
  158. package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +6 -9
  159. package/es/platform/zform/adapters/presenter/utils/DefaultClientActions.js +130 -0
  160. package/es/platform/zform/applications/usecases/AbstractUseCase.js +3 -1
  161. package/es/platform/zform/applications/usecases/FieldBlurUseCase.js +39 -0
  162. package/es/platform/zform/applications/usecases/FieldValueChangeRequestUseCase.js +9 -13
  163. package/es/platform/zform/applications/usecases/FocusFieldUseCase.js +19 -0
  164. package/es/platform/zform/applications/usecases/FormSubmitUseCase.js +19 -38
  165. package/es/platform/zform/applications/usecases/GetFieldErrorMessageUseCase.js +16 -0
  166. package/es/platform/zform/applications/usecases/InitializeUseCase.js +16 -0
  167. package/es/platform/zform/applications/usecases/InsertValidationRuleSuccessUseCase.js +22 -0
  168. package/es/platform/zform/applications/usecases/LookupFieldSuccessUseCase.js +40 -0
  169. package/es/platform/zform/applications/usecases/MyFormSuccessUseCase.js +97 -13
  170. package/es/platform/zform/applications/usecases/MyLayoutSuccessUseCase.js +4 -33
  171. package/es/platform/zform/applications/usecases/SetFieldErrorMessageUseCase.js +4 -4
  172. package/es/platform/zform/applications/usecases/SetFieldValueUseCase.js +4 -21
  173. package/es/platform/zform/applications/usecases/SetFieldsValuesUseCase.js +4 -26
  174. package/es/platform/zform/applications/usecases/SubmitValidationCompletedUseCase.js +62 -0
  175. package/es/platform/zform/applications/usecases/ValidateFieldUseCase.js +33 -0
  176. package/es/platform/zform/applications/usecases/ValidationRulesExecutionResultUseCase.js +23 -0
  177. package/es/platform/zform/domain/ZField.js +32 -7
  178. package/es/platform/zform/domain/ZForm.js +114 -45
  179. package/es/platform/zform/domain/interfaces/IZForm.js +5 -1
  180. package/es/platform/zform/domain/interfaces/ValidationConditions.js +142 -0
  181. package/es/platform/zform/frameworks/layout-rules/calculateLayoutRulesResult.js +1 -1
  182. package/es/platform/zform/frameworks/layout-rules/runSingleFieldCondition.js +1 -1
  183. package/es/platform/zform/frameworks/layout-rules/validator.js +0 -1
  184. package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +42 -138
  185. package/es/platform/zform/frameworks/ui/ZFormBehaviourFactory.js +4 -9
  186. package/es/platform/zform/frameworks/validation-rules/DefaultCustomValidators.js +340 -0
  187. package/es/platform/zform/frameworks/validation-rules/Validator.js +98 -16
  188. package/es/platform/zform/frameworks/validation-rules/formUtils.js +7 -0
  189. package/es/platform/zform/frameworks/validation-rules/localization_utils.js +15 -0
  190. package/es/platform/zform/frameworks/validation-rules/utils.js +402 -351
  191. package/es/platform/zform/frameworks/validation-rules/validationRules.js +80 -79
  192. package/es/platform/zlist/adapters/presenters/TableTranslator.js +3 -2
  193. package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +4 -1
  194. package/es/platform/zlist/domain/entities/List.js +11 -4
  195. package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +7 -3
  196. package/es/platform/zrecord/applications/usecases/SetRecordsUseCase.js +11 -1
  197. package/package.json +11 -12
  198. package/es/bc/field-validation/Constants.js +0 -4
  199. package/es/bc/field-validation/EventHandlers.js +0 -1
  200. package/es/bc/field-validation/Events.js +0 -106
  201. package/es/bc/field-validation/FieldTypes.js +0 -20
  202. package/es/bc/field-validation/Properties.js +0 -11
  203. package/es/bc/field-validation/index.js +0 -5
  204. package/es/cc/ephi-tag/Properties.js +0 -1
  205. package/es/cc/ephi-tag/index.js +0 -1
  206. package/es/cc/info-icon/Properties.js +0 -10
  207. package/es/cc/info-icon/index.js +0 -1
  208. package/es/library/behaviours/field-validation/adapters/controllers/AbstractController.js +0 -9
  209. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldController.js +0 -32
  210. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldsController.js +0 -31
  211. package/es/library/behaviours/field-validation/adapters/gateway/Repository.js +0 -23
  212. package/es/library/behaviours/field-validation/adapters/gateway/Service.js +0 -18
  213. package/es/library/behaviours/field-validation/applications/interfaces/input/FieldData.js +0 -17
  214. package/es/library/behaviours/field-validation/applications/usecases/AbstractUseCase.js +0 -15
  215. package/es/library/behaviours/field-validation/applications/usecases/ValidateField.js +0 -29
  216. package/es/library/behaviours/field-validation/applications/usecases/ValidateFields.js +0 -28
  217. package/es/library/behaviours/field-validation/domain/FieldValidation.js +0 -94
  218. package/es/library/behaviours/field-validation/domain/field-vise-validations/BooleanValidation.js +0 -28
  219. package/es/library/behaviours/field-validation/domain/field-vise-validations/CurrencyValidation.js +0 -49
  220. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateTimeValidation.js +0 -24
  221. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateValidation.js +0 -24
  222. package/es/library/behaviours/field-validation/domain/field-vise-validations/DecimalValidation.js +0 -49
  223. package/es/library/behaviours/field-validation/domain/field-vise-validations/EmailValidation.js +0 -28
  224. package/es/library/behaviours/field-validation/domain/field-vise-validations/IntegerValidation.js +0 -39
  225. package/es/library/behaviours/field-validation/domain/field-vise-validations/LookUpValidation.js +0 -24
  226. package/es/library/behaviours/field-validation/domain/field-vise-validations/MultiSelectValidation.js +0 -26
  227. package/es/library/behaviours/field-validation/domain/field-vise-validations/PercentValidation.js +0 -28
  228. package/es/library/behaviours/field-validation/domain/field-vise-validations/PhoneValidation.js +0 -39
  229. package/es/library/behaviours/field-validation/domain/field-vise-validations/PicklistValidation.js +0 -24
  230. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextAreaValidation.js +0 -39
  231. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextBoxValidation.js +0 -39
  232. package/es/library/behaviours/field-validation/domain/field-vise-validations/URLValidation.js +0 -28
  233. package/es/library/behaviours/field-validation/domain/interfaces/FieldTypes.js +0 -20
  234. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsEnum.js +0 -22
  235. package/es/library/behaviours/field-validation/domain/interfaces/fields/IBooleanField.js +0 -0
  236. package/es/library/behaviours/field-validation/domain/interfaces/fields/ICurrencyField.js +0 -0
  237. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateField.js +0 -0
  238. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateTimeField.js +0 -0
  239. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDecimalField.js +0 -0
  240. package/es/library/behaviours/field-validation/domain/interfaces/fields/IEmailField.js +0 -0
  241. package/es/library/behaviours/field-validation/domain/interfaces/fields/IIntegerField.js +0 -0
  242. package/es/library/behaviours/field-validation/domain/interfaces/fields/ILookUpField.js +0 -0
  243. package/es/library/behaviours/field-validation/domain/interfaces/fields/IMultiSelectField.js +0 -0
  244. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPercentField.js +0 -0
  245. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPhoneField.js +0 -0
  246. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPicklistField.js +0 -0
  247. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextAreaField.js +0 -0
  248. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextBoxField.js +0 -0
  249. package/es/library/behaviours/field-validation/domain/interfaces/fields/IURLField.js +0 -0
  250. package/es/library/behaviours/field-validation/frameworks/ui/EventHandlerFactory.js +0 -23
  251. package/es/library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory.js +0 -27
  252. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/BooleanFieldValidation.test.js +0 -137
  253. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/CurrencyFieldValidation.test.js +0 -228
  254. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateFieldValidation.test.js +0 -108
  255. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateTimeFieldValidation.test.js +0 -108
  256. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DecimalFieldValidation.test.js +0 -257
  257. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/EmailFieldValidation.test.js +0 -139
  258. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/FieldValidationBehaviour.test.js +0 -171
  259. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/IntegerFieldValidation.test.js +0 -168
  260. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/LookUpFieldValidation.test.js +0 -108
  261. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/MultiSelectFieldValidation.test.js +0 -79
  262. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PercentFieldValidation.test.js +0 -108
  263. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PhoneFieldValidation.test.js +0 -168
  264. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PicklistFieldValidation.test.js +0 -79
  265. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextAreaFieldValidation.test.js +0 -170
  266. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextBoxFieldValidation.test.js +0 -170
  267. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/URLFieldValidation.test.js +0 -108
  268. package/es/library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor.js +0 -228
  269. package/es/library/behaviours/field-validation/frameworks/utils/__tests__/formValidate.test.js +0 -284
  270. package/es/library/behaviours/field-validation/frameworks/utils/formValidate.js +0 -334
  271. package/es/library/dot/components/form-fields/checkbox/adapters/presenter/TransformState.js +0 -22
  272. package/es/library/dot/components/form-fields/currency/adapters/presenter/TransformState.js +0 -81
  273. package/es/library/dot/components/form-fields/date/adapters/presenter/TransformState.js +0 -22
  274. package/es/library/dot/components/form-fields/datetime/adapters/presenter/TransformState.js +0 -22
  275. package/es/library/dot/components/form-fields/decimal/adapters/presenter/TransformState.js +0 -31
  276. package/es/library/dot/components/form-fields/email/adapters/presenter/TransformState.js +0 -23
  277. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITag.js +0 -10
  278. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITagView.js +0 -21
  279. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIcon.js +0 -10
  280. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIconView.js +0 -21
  281. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/css/InfoIcon.module.css +0 -3
  282. package/es/library/dot/components/form-fields/multi-select/adapters/presenter/TransformState.js +0 -31
  283. package/es/library/dot/components/form-fields/number/adapters/presenter/TransformState.js +0 -31
  284. package/es/library/dot/components/form-fields/percentage/adapters/presenter/TransformState.js +0 -31
  285. package/es/library/dot/components/form-fields/phone/adapters/presenter/TransformState.js +0 -31
  286. package/es/library/dot/components/form-fields/pick-list/adapters/presenter/TransformState.js +0 -23
  287. package/es/library/dot/components/form-fields/textarea/adapters/presenter/TransformState.js +0 -23
  288. package/es/library/dot/components/form-fields/textbox/adapters/presenter/TransformState.js +0 -32
  289. package/es/library/dot/components/form-fields/url/adapters/presenter/TransformState.js +0 -31
  290. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelAction.js +0 -9
  291. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelActionView.js +0 -38
  292. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/css/LabelAction.module.css +0 -4
  293. package/es/platform/zform/adapters/controllers/ValidateErrorMessageController.js +0 -22
  294. package/es/platform/zform/applications/usecases/ValidateErrorMessageUseCase.js +0 -33
  295. package/es/platform/zform/applications/usecases/ValidateFieldRequestUseCase.js +0 -56
  296. /package/es/{library/behaviours/field-validation/applications/interfaces/UseCaseDependencies.js → platform/client-actions/behaviour/zclient-actions/applications/interfaces/IClientActionResource.js} +0 -0
  297. /package/es/{library/behaviours/field-validation/applications/interfaces/gateways/IRepository.js → platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionLocationInputModel.js} +0 -0
  298. /package/es/{library/behaviours/field-validation/applications/interfaces/gateways/IService.js → platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionUIComponentPropertiesInputModel.js} +0 -0
  299. /package/es/{library/behaviours/field-validation/applications/interfaces/input/FieldValidationInputModel.js → platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionsInputModel.js} +0 -0
  300. /package/es/{library/behaviours/field-validation/applications/interfaces/input/ValidateFieldsInputModel.js → platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/UpdateClientActionUIComponentPropertiesInputModel.js} +0 -0
  301. /package/es/{library/behaviours/field-validation/domain/interfaces/IFieldValidation.js → platform/zform/applications/interfaces/input/FieldBlurUsecaseInputModel.js} +0 -0
  302. /package/es/{library/behaviours/field-validation/domain/interfaces/IFieldViseValidation.js → platform/zform/applications/interfaces/input/FocusFieldUseCaseInputModel.js} +0 -0
  303. /package/es/{library/behaviours/field-validation/domain/interfaces/ValidationResult.js → platform/zform/applications/interfaces/input/GetFieldErrorMessageInputModel.js} +0 -0
  304. /package/es/{library/behaviours/field-validation/domain/interfaces/ValidationsArray.js → platform/zform/applications/interfaces/input/InsertValidationRuleInputModel.js} +0 -0
  305. /package/es/{library/behaviours/field-validation/domain/interfaces/ValidationsMap.js → platform/zform/applications/interfaces/input/LookUpFieldSuccessUseCaseInputModel.js} +0 -0
  306. /package/es/{library/behaviours/field-validation/domain/interfaces/IField.js → platform/zform/applications/interfaces/input/SubmitValidationCompletedUsecaseInputModel.js} +0 -0
  307. /package/es/platform/zform/applications/interfaces/input/{ValidateErrorMessageInputModel.js → ValidateFieldUseCaseInputModel.js} +0 -0
@@ -1,34 +1,34 @@
1
- /* eslint-disable default-case */
2
-
3
- /* eslint-disable no-param-reassign */
1
+ import { getLocalizedFunction } from "./localization_utils";
2
+ import { getNoneText } from "./formUtils";
3
+ import { parse, evaluateExpression } from "./expressionEval";
4
4
  export function getMissedFields() {
5
5
  let rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6
6
  let fieldMapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7
- let missedFields = []; // let missedFieldsDetail = {};
7
+ const missedFields = []; // let missedFieldsDetail = {};
8
8
 
9
- let allFieldNames = Object.keys(fieldMapper);
9
+ const allFieldNames = Object.keys(fieldMapper);
10
10
 
11
11
  function pushMissedField(fieldDetails) {
12
- let {
12
+ const {
13
13
  displayLabel,
14
14
  fieldName
15
15
  } = fieldDetails;
16
16
 
17
- if (allFieldNames.indexOf(fieldName) === -1 && missedFields.indexOf(fieldName) === -1 && displayLabel) {
17
+ if (allFieldNames.indexOf(fieldName) === -1 && missedFields.indexOf(displayLabel) === -1 && displayLabel) {
18
18
  missedFields.push(displayLabel);
19
19
  }
20
20
  }
21
21
 
22
22
  rules.forEach(rule => {
23
- let {
23
+ const {
24
24
  fieldConditions = []
25
25
  } = rule;
26
26
  fieldConditions.forEach(fieldCondition => {
27
- let {
27
+ const {
28
28
  conditions = [],
29
29
  actions = {}
30
30
  } = fieldCondition;
31
- let {
31
+ const {
32
32
  setMandatoryFields = []
33
33
  } = actions;
34
34
  conditions.forEach(condition => {
@@ -41,27 +41,35 @@ export function getMissedFields() {
41
41
  });
42
42
  return missedFields;
43
43
  }
44
- export function getStatusMappingObj(statusMapping) {
45
- let mappingObj = {
44
+ export function getStatusMappingObj(statusMapping, moduleName) {
45
+ const mappingObj = {
46
46
  open: [],
47
47
  closed: [],
48
48
  onhold: [],
49
49
  completed: []
50
50
  };
51
+ const getTranslatedVal = getLocalizedFunction({
52
+ moduleName,
53
+ apiName: 'status',
54
+ type: 'picklist'
55
+ });
51
56
  statusMapping.forEach(status => {
52
- let {
57
+ const {
53
58
  statusType,
54
59
  name
55
60
  } = status;
61
+ const transVal = getTranslatedVal({
62
+ fieldValue: name
63
+ });
56
64
 
57
65
  if (statusType === 'Open') {
58
- mappingObj.open.push(name);
66
+ mappingObj.open.push(transVal);
59
67
  } else if (statusType === 'On Hold') {
60
- mappingObj.onhold.push(name);
68
+ mappingObj.onhold.push(transVal);
61
69
  } else if (statusType === 'Closed') {
62
- mappingObj.closed.push(name);
70
+ mappingObj.closed.push(transVal);
63
71
  } else if (statusType === 'Completed') {
64
- mappingObj.completed.push(name);
72
+ mappingObj.completed.push(transVal);
65
73
  }
66
74
  });
67
75
  return mappingObj;
@@ -71,8 +79,8 @@ function checkFieldsAvailableInForm() {
71
79
  let conditions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
72
80
  let fieldMapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
73
81
  return conditions.every(condition => {
74
- let allFieldNames = Object.keys(fieldMapper);
75
- let {
82
+ const allFieldNames = Object.keys(fieldMapper);
83
+ const {
76
84
  fieldName
77
85
  } = condition;
78
86
 
@@ -82,18 +90,11 @@ function checkFieldsAvailableInForm() {
82
90
 
83
91
  return false;
84
92
  });
85
- } //ignoreFields: assignee, multiselect, reminder, department, resolution
86
- // moduleEntityObj = {department: {}, contact:{}, account:{}, product:{}}
87
-
93
+ }
88
94
 
89
- function getFieldValue(fieldId, fieldUIStates, fieldDetails, moduleEntityObj) {
90
- let {
91
- type: fieldType,
92
- apiName: fieldName
93
- } = fieldDetails[fieldId];
94
- let {
95
- value,
96
- createNew
95
+ function getFieldValue(fieldId, fieldUIStates) {
96
+ const {
97
+ value
97
98
  } = fieldUIStates[fieldId];
98
99
  return value;
99
100
  }
@@ -104,322 +105,403 @@ function validateCondition() {
104
105
  let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
105
106
  let formValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
106
107
  let statusMapping = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
107
- {
108
- formValue = formValue === null ? '' : formValue;
109
- const Types = {
110
- TEXT: 'Text',
111
- EMAIL: 'Email',
112
- PHONE: 'Phone',
113
- URL: 'URL',
114
- TEXTAREA: 'Textarea',
115
- LOOKUP: 'LookUp',
116
- NUMBER: 'Number',
117
- PERCENT: 'Percent',
118
- CURRENCY: 'Currency',
119
- DECIMAL: 'Decimal',
120
- BOOLEAN: 'Boolean',
121
- DATETIME: 'DateTime',
122
- DATE: 'Date',
123
- PICKLIST: 'Picklist',
124
- RADIO: 'Radio',
125
- FAX: 'Fax'
126
- };
127
- const COMMON_COMPARATORS = {
128
- ISEMPTY: 'is empty',
129
- ISNOTEMPTY: 'is not empty'
130
- };
131
- const TEXT_COMPARATORS = {
132
- IS: 'is',
133
- ISNT: "isn't",
134
- STARTSWITH: 'starts with',
135
- ENDSWITH: 'ends with',
136
- CONTAINS: 'contains',
137
- DOESNTCONTAIN: "doesn't contain"
138
- };
139
- const NUMBER_COMPARATORS = {
140
- EQUAL: '=',
141
- NOTEQUAL: '<>',
142
- LESSTHAN: '<',
143
- LESSTHANEQUAL: '<=',
144
- GREATERTHAN: '>',
145
- GREATERTHANEQUAL: '>='
146
- };
147
- const DATE_COMPARATORS = {
148
- ISAFTER: 'is after',
149
- ISBEFORE: 'is before',
150
- BETWEEN: 'between',
151
- NOTBETWEEN: 'not between'
152
- };
153
- const STATUS_COMPARATORS = {
154
- ISOPEN: 'is OPEN',
155
- ISONHOLD: 'is ON HOLD',
156
- ISCLOSED: 'is CLOSED',
157
- ISCOMPLETED: 'is COMPLETED'
158
- };
159
-
160
- const validateText = function () {
161
- let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
162
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
163
- let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
164
- let matched = false;
108
+ formValue = formValue === null ? '' : formValue;
109
+ const Types = {
110
+ TEXT: 'Text',
111
+ EMAIL: 'Email',
112
+ PHONE: 'Phone',
113
+ URL: 'URL',
114
+ TEXTAREA: 'Textarea',
115
+ LOOKUP: 'LookUp',
116
+ NUMBER: 'Number',
117
+ PERCENT: 'Percent',
118
+ CURRENCY: 'Currency',
119
+ DECIMAL: 'Decimal',
120
+ BOOLEAN: 'Boolean',
121
+ DATETIME: 'DateTime',
122
+ DATE: 'Date',
123
+ PICKLIST: 'Picklist',
124
+ RADIO: 'Radio',
125
+ FAX: 'Fax',
126
+ MULTIPICKLIST: "Multiselect"
127
+ };
128
+ const COMMON_COMPARATORS = {
129
+ ISEMPTY: 'is empty',
130
+ ISNOTEMPTY: 'is not empty'
131
+ };
132
+ const TEXT_COMPARATORS = {
133
+ IS: 'is',
134
+ ISNT: "isn't",
135
+ STARTSWITH: 'starts with',
136
+ ENDSWITH: 'ends with',
137
+ CONTAINS: 'contains',
138
+ DOESNTCONTAIN: "doesn't contain"
139
+ };
140
+ const NUMBER_COMPARATORS = {
141
+ EQUAL: '=',
142
+ NOTEQUAL: '<>',
143
+ LESSTHAN: '<',
144
+ LESSTHANEQUAL: '<=',
145
+ GREATERTHAN: '>',
146
+ GREATERTHANEQUAL: '>='
147
+ };
148
+ const DATE_COMPARATORS = {
149
+ ISAFTER: 'is after',
150
+ ISBEFORE: 'is before',
151
+ BETWEEN: 'between',
152
+ NOTBETWEEN: 'not between'
153
+ };
154
+ const STATUS_COMPARATORS = {
155
+ ISOPEN: 'is OPEN',
156
+ ISONHOLD: 'is ON HOLD',
157
+ ISCLOSED: 'is CLOSED',
158
+ ISCOMPLETED: 'is COMPLETED'
159
+ };
160
+
161
+ function stringToRegex(str) {
162
+ const match = str.match(/^([\/~@;%#'])(.*?)\1([gimsuy]*)$/);
163
+ return match ? new RegExp(match[2], match[3].split('').filter((char, pos, flagArr) => flagArr.indexOf(char) === pos).join('')) : new RegExp(str);
164
+ }
165
+
166
+ const getValueFromRegex = value => {
167
+ try {
168
+ const regexpattern = /^(?<regexName>([a-zA-Z0-9\_\-\(\)\[\])\s\.\,]*)):(\/\()(?<regex>[a-zA-Z0-9\!\@\#\$\%\^\&\*\(\)\_\+\-\=\`\~\[\]\{\}\;\:\'\"\,\.\/\<\>\?\\\|]*)(\)\/)$/;
169
+ const match = value.match(regexpattern);
170
+ return match;
171
+ } catch (err) {
172
+ throw err;
173
+ }
174
+ };
165
175
 
166
- if (condition === COMMON_COMPARATORS.ISEMPTY) {
167
- matched = formValue === '';
168
- } else if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
169
- matched = formValue !== '';
176
+ const validateText = function () {
177
+ let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
178
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
179
+ let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
180
+ let matched = false;
181
+ let valueFromRegex = '';
182
+
183
+ if (condition === COMMON_COMPARATORS.ISEMPTY) {
184
+ matched = formValue === '';
185
+ } else if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
186
+ matched = formValue !== '';
187
+ } else {
188
+ valueFromRegex = getValueFromRegex(value);
189
+
190
+ if (valueFromRegex) {
191
+ value = value !== null ? value.trim() : '';
192
+ formValue = formValue !== null ? formValue.trim() : '';
170
193
  } else {
171
194
  value = value !== null ? value.toLowerCase().trim() : '';
172
195
  formValue = formValue !== null ? formValue.toLowerCase().trim() : '';
196
+ }
173
197
 
174
- switch (condition) {
175
- case TEXT_COMPARATORS.IS:
198
+ if (formValue === '') {
199
+ return false;
200
+ }
201
+
202
+ switch (condition) {
203
+ case TEXT_COMPARATORS.IS:
204
+ if (valueFromRegex && valueFromRegex.groups && valueFromRegex.groups.regexName && stringToRegex(`^${atob(valueFromRegex.groups.regex)}$`)) {
205
+ matched = new RegExp(stringToRegex(`^${atob(valueFromRegex.groups.regex)}$`), "u").test(formValue);
206
+ } else {
176
207
  matched = formValue === value;
177
- break;
208
+ }
178
209
 
179
- case TEXT_COMPARATORS.ISNT:
210
+ break;
211
+
212
+ case TEXT_COMPARATORS.ISNT:
213
+ if (valueFromRegex && valueFromRegex.groups && valueFromRegex.groups.regexName && stringToRegex(`^${atob(valueFromRegex.groups.regex)}$`)) {
214
+ matched = !new RegExp(stringToRegex(`^${atob(valueFromRegex.groups.regex)}$`), "u").test(formValue);
215
+ } else {
180
216
  matched = formValue !== value;
181
- break;
217
+ }
182
218
 
183
- case TEXT_COMPARATORS.STARTSWITH:
184
- matched = formValue.startsWith(value);
185
- break;
219
+ break;
186
220
 
187
- case TEXT_COMPARATORS.ENDSWITH:
188
- matched = formValue.endsWith(value);
189
- break;
221
+ case TEXT_COMPARATORS.STARTSWITH:
222
+ matched = formValue.startsWith(value);
223
+ break;
224
+
225
+ case TEXT_COMPARATORS.ENDSWITH:
226
+ matched = formValue.endsWith(value);
227
+ break;
190
228
 
191
- case TEXT_COMPARATORS.CONTAINS:
229
+ case TEXT_COMPARATORS.CONTAINS:
230
+ if (valueFromRegex && valueFromRegex.groups && valueFromRegex.groups.regexName && stringToRegex(`${atob(valueFromRegex.groups.regex)}`)) {
231
+ matched = new RegExp(stringToRegex(atob(valueFromRegex.groups.regex)), "u").test(formValue);
232
+ } else {
192
233
  matched = formValue.indexOf(value) !== -1;
193
- break;
234
+ }
194
235
 
195
- case TEXT_COMPARATORS.DOESNTCONTAIN:
196
- matched = formValue.indexOf(value) === -1;
197
- break;
198
- }
236
+ break;
237
+
238
+ case TEXT_COMPARATORS.DOESNTCONTAIN:
239
+ matched = formValue.indexOf(value) === -1;
240
+ break;
199
241
  }
242
+ }
200
243
 
201
- return matched;
202
- };
244
+ return matched;
245
+ };
203
246
 
204
- const validateNumber = function () {
205
- let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
206
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
207
- let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
208
- let matched = false;
247
+ const validateNumber = function () {
248
+ let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
249
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
250
+ let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
251
+ let matched = false;
209
252
 
210
- if (condition === COMMON_COMPARATORS.ISEMPTY) {
211
- matched = formValue === '';
212
- } else if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
213
- matched = formValue !== '';
214
- } else {
215
- if (formValue === '') {
216
- return false;
217
- }
253
+ if (condition === COMMON_COMPARATORS.ISEMPTY) {
254
+ matched = formValue === '';
255
+ } else if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
256
+ matched = formValue !== '';
257
+ } else {
258
+ if (formValue === '') {
259
+ return false;
260
+ }
261
+
262
+ value = parseFloat(value);
263
+ formValue = parseFloat(formValue);
264
+
265
+ switch (condition) {
266
+ case NUMBER_COMPARATORS.EQUAL:
267
+ matched = formValue === value;
268
+ break;
269
+
270
+ case NUMBER_COMPARATORS.NOTEQUAL:
271
+ matched = formValue !== value;
272
+ break;
273
+
274
+ case NUMBER_COMPARATORS.LESSTHAN:
275
+ matched = formValue < value;
276
+ break;
277
+
278
+ case NUMBER_COMPARATORS.LESSTHANEQUAL:
279
+ matched = formValue <= value;
280
+ break;
281
+
282
+ case NUMBER_COMPARATORS.GREATERTHAN:
283
+ matched = formValue > value;
284
+ break;
285
+
286
+ case NUMBER_COMPARATORS.GREATERTHANEQUAL:
287
+ matched = formValue >= value;
288
+ break;
289
+ }
290
+ }
291
+
292
+ return matched;
293
+ };
294
+
295
+ const validateBoolean = function () {
296
+ let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
297
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
298
+ let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
299
+ formValue = String(formValue) || 'false';
300
+ value = String(value) || 'false';
301
+ let matched = false;
218
302
 
219
- value = parseFloat(value);
220
- formValue = parseFloat(formValue);
303
+ switch (condition) {
304
+ case TEXT_COMPARATORS.IS:
305
+ matched = formValue === value;
306
+ break;
307
+ }
308
+
309
+ return matched;
310
+ };
311
+
312
+ const validateDate = function () {
313
+ let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
314
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
315
+ let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
316
+ let matched = false;
317
+
318
+ if (condition === COMMON_COMPARATORS.ISEMPTY) {
319
+ matched = formValue === '';
320
+ } else if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
321
+ matched = formValue !== '';
322
+ } else {
323
+ if (formValue === '') {
324
+ return false;
325
+ }
326
+
327
+ formValue = new Date(formValue);
328
+
329
+ if (condition === DATE_COMPARATORS.BETWEEN || condition === DATE_COMPARATORS.NOTBETWEEN) {
330
+ const beforeVal = new Date(value[0]);
331
+ const afterVal = new Date(value[1]);
221
332
 
222
333
  switch (condition) {
223
- case NUMBER_COMPARATORS.EQUAL:
224
- matched = formValue === value;
334
+ case DATE_COMPARATORS.BETWEEN:
335
+ matched = formValue.getTime() - beforeVal.getTime() >= 0 && formValue.getTime() - afterVal.getTime() <= 0;
225
336
  break;
226
337
 
227
- case NUMBER_COMPARATORS.NOTEQUAL:
228
- matched = formValue !== value;
338
+ case DATE_COMPARATORS.NOTBETWEEN:
339
+ matched = !(formValue.getTime() - beforeVal.getTime() >= 0 && formValue.getTime() - afterVal.getTime() <= 0);
229
340
  break;
341
+ }
342
+ } else {
343
+ value = new Date(value);
230
344
 
231
- case NUMBER_COMPARATORS.LESSTHAN:
232
- matched = formValue < value;
345
+ switch (condition) {
346
+ case TEXT_COMPARATORS.IS:
347
+ matched = formValue.getTime() - value.getTime() === 0;
233
348
  break;
234
349
 
235
- case NUMBER_COMPARATORS.LESSTHANEQUAL:
236
- matched = formValue <= value;
350
+ case TEXT_COMPARATORS.ISNT:
351
+ matched = formValue !== '' && formValue.getTime() - value.getTime() !== 0;
237
352
  break;
238
353
 
239
- case NUMBER_COMPARATORS.GREATERTHAN:
240
- matched = formValue > value;
354
+ case DATE_COMPARATORS.ISAFTER:
355
+ matched = formValue.getTime() - value.getTime() > 0;
241
356
  break;
242
357
 
243
- case NUMBER_COMPARATORS.GREATERTHANEQUAL:
244
- matched = formValue >= value;
358
+ case DATE_COMPARATORS.ISBEFORE:
359
+ matched = formValue.getTime() - value.getTime() < 0;
245
360
  break;
246
361
  }
247
362
  }
363
+ }
248
364
 
249
- return matched;
250
- };
251
-
252
- const validateBoolean = function () {
253
- let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
254
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
255
- let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
256
- formValue = String(formValue) || 'false';
257
- value = String(value) || 'false';
258
- let matched = false;
259
-
260
- switch (condition) {
261
- case TEXT_COMPARATORS.IS:
262
- matched = formValue === value;
263
- break;
264
- }
365
+ return matched;
366
+ };
265
367
 
266
- return matched;
267
- };
368
+ const validatePicklist = function () {
369
+ let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
370
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
371
+ let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
372
+ let statusMapping = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
268
373
 
269
- const validateDate = function () {
270
- let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
271
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
272
- let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
374
+ if ([STATUS_COMPARATORS.ISOPEN, STATUS_COMPARATORS.ISONHOLD, STATUS_COMPARATORS.ISCLOSED, STATUS_COMPARATORS.ISCOMPLETED].indexOf(condition) !== -1) {
273
375
  let matched = false;
274
376
 
275
- if (condition === COMMON_COMPARATORS.ISEMPTY) {
276
- matched = formValue === '';
277
- } else if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
278
- matched = formValue !== '';
279
- } else {
280
- if (formValue === '') {
281
- return false;
282
- }
377
+ switch (condition) {
378
+ case STATUS_COMPARATORS.ISOPEN:
379
+ matched = statusMapping.open.indexOf(formValue) !== -1;
380
+ break;
283
381
 
284
- formValue = new Date(formValue);
382
+ case STATUS_COMPARATORS.ISONHOLD:
383
+ matched = statusMapping.onhold.indexOf(formValue) !== -1;
384
+ break;
285
385
 
286
- if (condition === DATE_COMPARATORS.BETWEEN || condition === DATE_COMPARATORS.NOTBETWEEN) {
287
- const beforeVal = new Date(value[0]);
288
- const afterVal = new Date(value[1]);
386
+ case STATUS_COMPARATORS.ISCLOSED:
387
+ matched = statusMapping.closed.indexOf(formValue) !== -1;
388
+ break;
289
389
 
290
- switch (condition) {
291
- case DATE_COMPARATORS.BETWEEN:
292
- matched = formValue.getTime() - beforeVal.getTime() >= 0 && formValue.getTime() - afterVal.getTime() <= 0;
293
- break;
390
+ case STATUS_COMPARATORS.ISCOMPLETED:
391
+ matched = statusMapping.completed.indexOf(formValue) !== -1;
392
+ break;
393
+ }
294
394
 
295
- case DATE_COMPARATORS.NOTBETWEEN:
296
- matched = !(formValue.getTime() - beforeVal.getTime() >= 0 && formValue.getTime() - afterVal.getTime() <= 0);
297
- break;
298
- }
299
- } else {
300
- value = new Date(value);
395
+ return matched;
396
+ }
301
397
 
302
- switch (condition) {
303
- case TEXT_COMPARATORS.IS:
304
- matched = formValue.getTime() - value.getTime() === 0;
305
- break;
398
+ const {
399
+ valueNoneText: noneText
400
+ } = getNoneText();
401
+ formValue = formValue === noneText ? '' : formValue;
402
+ return validateText(condition, value, formValue);
403
+ };
306
404
 
307
- case TEXT_COMPARATORS.ISNT:
308
- matched = formValue !== '' && formValue.getTime() - value.getTime() !== 0;
309
- break;
405
+ const getRelatedDateISOString = (dateValue, isDateField) => {
406
+ if (dateValue === '${CURRENTTIME}') {
407
+ const currentDateObj = new Date();
408
+ dateValue = currentDateObj.toISOString();
409
+ }
310
410
 
311
- case DATE_COMPARATORS.ISAFTER:
312
- matched = formValue.getTime() - value.getTime() > 0;
313
- break;
411
+ if (isDateField) {
412
+ dateValue += 'T00:00:00.000Z';
413
+ } else {
414
+ const dateObj = new Date(dateValue);
415
+ dateObj.setSeconds(0);
416
+ dateObj.setMilliseconds(0);
417
+ dateValue = dateObj.toISOString();
418
+ }
314
419
 
315
- case DATE_COMPARATORS.ISBEFORE:
316
- matched = formValue.getTime() - value.getTime() < 0;
317
- break;
318
- }
319
- }
320
- }
420
+ return dateValue;
421
+ };
321
422
 
322
- return matched;
323
- };
423
+ const validateMultipicklist = function () {
424
+ let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
425
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
426
+ let formValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
427
+ const indexOfNone = (formValues || []).indexOf("-None-");
324
428
 
325
- const validatePicklist = function () {
326
- let condition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
327
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
328
- let formValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
329
- let statusMapping = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
429
+ if (indexOfNone > -1) {
430
+ formValues.splice(indexOfNone, 1);
431
+ }
330
432
 
331
- if ([STATUS_COMPARATORS.ISOPEN, STATUS_COMPARATORS.ISONHOLD, STATUS_COMPARATORS.ISCLOSED, STATUS_COMPARATORS.ISCOMPLETED].indexOf(condition) !== -1) {
332
- let matched = false;
433
+ let normalizedFormValue = formValues || [];
333
434
 
334
- switch (condition) {
335
- case STATUS_COMPARATORS.ISOPEN:
336
- matched = statusMapping.open.indexOf(formValue) !== -1;
337
- break;
435
+ if (condition === COMMON_COMPARATORS.ISEMPTY) {
436
+ return normalizedFormValue.length === 0;
437
+ }
338
438
 
339
- case STATUS_COMPARATORS.ISONHOLD:
340
- matched = statusMapping.onhold.indexOf(formValue) !== -1;
341
- break;
439
+ if (condition === COMMON_COMPARATORS.ISNOTEMPTY) {
440
+ return normalizedFormValue.length !== 0;
441
+ }
342
442
 
343
- case STATUS_COMPARATORS.ISCLOSED:
344
- matched = statusMapping.closed.indexOf(formValue) !== -1;
345
- break;
443
+ normalizedFormValue = Array.isArray(normalizedFormValue) ? normalizedFormValue : [normalizedFormValue];
444
+ return normalizedFormValue.some(formValue => validateText(condition, value, formValue) === true);
445
+ };
346
446
 
347
- case STATUS_COMPARATORS.ISCOMPLETED:
348
- matched = statusMapping.completed.indexOf(formValue) !== -1;
349
- break;
350
- }
447
+ switch (type) {
448
+ case Types.TEXT:
449
+ case Types.EMAIL:
450
+ case Types.PHONE:
451
+ case Types.URL:
452
+ case Types.TEXTAREA:
453
+ case Types.LOOKUP:
454
+ case Types.FAX:
455
+ return validateText(condition, value, formValue);
351
456
 
352
- return matched;
353
- }
457
+ case Types.MULTIPICKLIST:
458
+ return validateMultipicklist(condition, value, formValue);
354
459
 
355
- formValue = formValue === '-None-' ? null : formValue;
356
- return validateText(condition, value, formValue);
357
- };
460
+ case Types.NUMBER:
461
+ case Types.PERCENT:
462
+ case Types.CURRENCY:
463
+ case Types.DECIMAL:
464
+ return validateNumber(condition, value, formValue);
358
465
 
359
- const getRelatedDateISOString = (dateValue, isDateField) => {
360
- if (dateValue === '${CURRENTTIME}') {
361
- let currentDateObj = new Date();
362
- dateValue = currentDateObj.toISOString();
363
- }
466
+ case Types.BOOLEAN:
467
+ return validateBoolean(condition, value, formValue);
364
468
 
365
- if (isDateField) {
366
- dateValue += 'T00:00:00.000Z';
367
- } else {
368
- let dateObj = new Date(dateValue);
369
- dateObj.setSeconds(0);
370
- dateObj.setMilliseconds(0);
371
- dateValue = dateObj.toISOString();
372
- }
469
+ case Types.DATETIME:
470
+ case Types.DATE:
471
+ if (condition !== COMMON_COMPARATORS.ISNOTEMPTY && condition !== COMMON_COMPARATORS.ISEMPTY) {
472
+ const isDateField = type === Types.DATE;
373
473
 
374
- return dateValue;
375
- };
376
-
377
- switch (type) {
378
- case Types.TEXT:
379
- case Types.EMAIL:
380
- case Types.PHONE:
381
- case Types.URL:
382
- case Types.TEXTAREA:
383
- case Types.LOOKUP:
384
- case Types.FAX:
385
- return validateText(condition, value, formValue);
386
-
387
- case Types.NUMBER:
388
- case Types.PERCENT:
389
- case Types.CURRENCY:
390
- case Types.DECIMAL:
391
- return validateNumber(condition, value, formValue);
392
-
393
- case Types.BOOLEAN:
394
- return validateBoolean(condition, value, formValue);
395
-
396
- case Types.DATETIME:
397
- case Types.DATE:
398
- if (condition !== COMMON_COMPARATORS.ISNOTEMPTY && condition !== COMMON_COMPARATORS.ISEMPTY) {
399
- if (type === Types.DATE) {
400
- value = getRelatedDateISOString(value, true);
401
- } else {
402
- if (condition === DATE_COMPARATORS.BETWEEN || condition === DATE_COMPARATORS.NOTBETWEEN) {
403
- value[0] = getRelatedDateISOString(value[0], false);
404
- value[1] = getRelatedDateISOString(value[1], false);
405
- } else {
406
- value = getRelatedDateISOString(value, false);
407
- }
408
- }
474
+ if (condition === DATE_COMPARATORS.BETWEEN || condition === DATE_COMPARATORS.NOTBETWEEN) {
475
+ value[0] = getRelatedDateISOString(value[0], isDateField);
476
+ value[1] = getRelatedDateISOString(value[1], isDateField);
477
+ } else {
478
+ value = getRelatedDateISOString(value, isDateField);
409
479
  }
480
+ }
410
481
 
411
- return validateDate(condition, value, formValue);
482
+ return validateDate(condition, value, formValue);
412
483
 
413
- case Types.PICKLIST:
414
- case Types.RADIO:
415
- return validatePicklist(condition, value, formValue, statusMapping);
484
+ case Types.PICKLIST:
485
+ case Types.RADIO:
486
+ return validatePicklist(condition, value, formValue, statusMapping);
416
487
 
417
- default:
418
- return false;
419
- }
488
+ default:
489
+ return false;
420
490
  }
421
491
  }
422
492
 
493
+ function getConditionType(condition, fieldMapper, fieldDetails) {
494
+ const {
495
+ fieldName,
496
+ conditionType
497
+ } = condition;
498
+ const fieldId = fieldMapper[fieldName];
499
+ const {
500
+ type: fieldType
501
+ } = fieldDetails[fieldId];
502
+ return conditionType || fieldType;
503
+ }
504
+
423
505
  function getConditionsMatchedResult() {
424
506
  let conditions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
425
507
  let fieldUIStates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -427,27 +509,28 @@ function getConditionsMatchedResult() {
427
509
  let fieldDetails = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
428
510
  let statusMapping = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
429
511
  let moduleEntityObj = arguments.length > 5 ? arguments[5] : undefined;
430
- let result = {};
512
+ const result = {};
431
513
 
432
514
  if (!checkFieldsAvailableInForm(conditions, fieldMapper)) {
433
515
  return result;
434
516
  }
435
517
 
436
518
  conditions.forEach((condition, conditionIndex) => {
437
- let {
519
+ const {
438
520
  fieldName,
439
521
  condition: conditionName,
440
522
  value: values = []
441
523
  } = condition;
442
- let fieldId = fieldMapper[fieldName];
443
- let {
444
- type: fieldType
445
- } = fieldDetails[fieldId];
446
- let formValue = getFieldValue(fieldId, fieldUIStates, fieldDetails, moduleEntityObj);
524
+ const fieldId = fieldMapper[fieldName];
525
+ const fieldType = getConditionType(condition, fieldMapper, fieldDetails);
526
+ const formValue = getFieldValue(fieldId, fieldUIStates);
447
527
  let matched = false;
448
528
 
449
529
  if (conditionName === 'between' || conditionName === 'not between') {
450
- matched = validateCondition(fieldType, conditionName, values, formValue, statusMapping);
530
+ matched = validateCondition(fieldType, conditionName, [...values], formValue, statusMapping);
531
+ } else if (["isn't", "doesn't contain"].indexOf(conditionName) !== -1) {
532
+ const matchedList = values.filter(val => validateCondition(fieldType, conditionName, val, formValue, statusMapping));
533
+ matched = matchedList.length === values.length;
451
534
  } else {
452
535
  matched = values.some(value => {
453
536
  if (validateCondition(fieldType, conditionName, value, formValue, statusMapping)) {
@@ -463,30 +546,6 @@ function getConditionsMatchedResult() {
463
546
  return result;
464
547
  }
465
548
 
466
- function validatePattern() {
467
- let pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
468
- let matchedResult = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
469
-
470
- let evalExpression = pattern => Function(`return (${pattern})`);
471
-
472
- pattern = pattern.replace(/and/g, '&&').replace(/or/g, '||');
473
- let newPattern = '';
474
- let patternLen = pattern.length;
475
-
476
- for (let i = 0; i < patternLen; i++) {
477
- let char = pattern[i];
478
-
479
- if (char !== '(' && char !== ')' && char !== '&' && char !== '|') {
480
- char = parseInt(char);
481
- char = matchedResult[char] || false;
482
- }
483
-
484
- newPattern += char;
485
- }
486
-
487
- return evalExpression(newPattern)();
488
- }
489
-
490
549
  export function getPassedFormRules() {
491
550
  let rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
492
551
  let fieldUIStates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -494,55 +553,47 @@ export function getPassedFormRules() {
494
553
  let fieldDetails = arguments.length > 3 ? arguments[3] : undefined;
495
554
  let statusMapping = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
496
555
  let moduleEntityObj = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
497
- let customValidators = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
498
- let passedRules = [];
556
+ let customValidationRunner = arguments.length > 6 ? arguments[6] : undefined;
557
+ const passedRules = [];
499
558
  statusMapping = getStatusMappingObj(statusMapping);
500
559
  rules.forEach(rule => {
501
- let allFieldNames = Object.keys(fieldMapper);
502
- let {
560
+ const allFieldNames = Object.keys(fieldMapper);
561
+ const {
503
562
  fieldName,
504
563
  fieldConditions
505
564
  } = rule;
506
565
 
507
566
  if (allFieldNames.indexOf(fieldName) !== -1) {
508
567
  fieldConditions.forEach(fieldCondition => {
568
+ if (fieldCondition.validator) {
569
+ const promisedResult = customValidationRunner({
570
+ fieldCondition,
571
+ fieldName
572
+ });
573
+ passedRules.push(promisedResult);
574
+ return;
575
+ }
576
+
509
577
  let {
510
- conditions,
511
- pattern,
578
+ pattern
579
+ } = fieldCondition;
580
+ const {
512
581
  actions,
513
- validator
582
+ conditions
514
583
  } = fieldCondition;
515
-
516
- if (validator) {
517
- let {
518
- scriptId
519
- } = validator;
520
-
521
- if (customValidators[scriptId]) {
522
- let value = getFieldValue(fieldMapper[fieldName], fieldUIStates, fieldDetails, moduleEntityObj);
523
- let isValid = customValidators[scriptId](value);
524
-
525
- if (!isValid) {
526
- let obj = {
527
- fieldName,
528
- actions
529
- };
530
- passedRules.push(obj);
531
- }
532
- }
533
- } else {
534
- let matchedResult = getConditionsMatchedResult(conditions, fieldUIStates, fieldMapper, fieldDetails, statusMapping, moduleEntityObj);
535
-
536
- if (Object.keys(matchedResult).length > 0) {
537
- let isValid = validatePattern(pattern, matchedResult);
538
-
539
- if (isValid) {
540
- let obj = {
541
- fieldName,
542
- actions
543
- };
544
- passedRules.push(obj);
545
- }
584
+ const matchedResult = getConditionsMatchedResult(conditions, fieldUIStates, fieldMapper, fieldDetails, statusMapping, moduleEntityObj);
585
+
586
+ if (Object.keys(matchedResult).length > 0) {
587
+ pattern = pattern.replace(/and/g, '&&').replace(/or/g, '||');
588
+ const ast = parse(pattern);
589
+ const isValid = evaluateExpression(ast, matchedResult);
590
+
591
+ if (isValid) {
592
+ const obj = {
593
+ fieldName,
594
+ actions
595
+ };
596
+ passedRules.push(obj);
546
597
  }
547
598
  }
548
599
  });