@zohodesk/library-platform 1.1.9-exp.1 → 1.1.10

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 (145) hide show
  1. package/es/bc/field-validation/Constants.js +4 -0
  2. package/es/bc/field-validation/EventHandlers.js +1 -0
  3. package/es/bc/field-validation/Events.js +106 -0
  4. package/es/bc/field-validation/FieldTypes.js +20 -0
  5. package/es/bc/field-validation/Properties.js +11 -0
  6. package/es/bc/field-validation/index.js +5 -0
  7. package/es/cc/ephi-tag/Properties.js +1 -0
  8. package/es/cc/ephi-tag/index.js +1 -0
  9. package/es/cc/info-icon/Properties.js +10 -0
  10. package/es/cc/info-icon/index.js +1 -0
  11. package/es/{platform/app-context-behaviour → library/behaviours/field-validation}/adapters/controllers/AbstractController.js +4 -2
  12. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldController.js +32 -0
  13. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldsController.js +31 -0
  14. package/es/library/behaviours/field-validation/adapters/gateway/Repository.js +23 -0
  15. package/es/library/behaviours/field-validation/adapters/gateway/Service.js +18 -0
  16. package/es/library/behaviours/field-validation/applications/interfaces/input/FieldData.js +17 -0
  17. package/es/library/behaviours/field-validation/applications/usecases/AbstractUseCase.js +15 -0
  18. package/es/library/behaviours/field-validation/applications/usecases/ValidateField.js +29 -0
  19. package/es/library/behaviours/field-validation/applications/usecases/ValidateFields.js +28 -0
  20. package/es/library/behaviours/field-validation/domain/FieldValidation.js +94 -0
  21. package/es/library/behaviours/field-validation/domain/field-vise-validations/BooleanValidation.js +28 -0
  22. package/es/library/behaviours/field-validation/domain/field-vise-validations/CurrencyValidation.js +49 -0
  23. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateTimeValidation.js +24 -0
  24. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateValidation.js +24 -0
  25. package/es/library/behaviours/field-validation/domain/field-vise-validations/DecimalValidation.js +49 -0
  26. package/es/library/behaviours/field-validation/domain/field-vise-validations/EmailValidation.js +28 -0
  27. package/es/library/behaviours/field-validation/domain/field-vise-validations/IntegerValidation.js +39 -0
  28. package/es/library/behaviours/field-validation/domain/field-vise-validations/LookUpValidation.js +24 -0
  29. package/es/library/behaviours/field-validation/domain/field-vise-validations/MultiSelectValidation.js +26 -0
  30. package/es/library/behaviours/field-validation/domain/field-vise-validations/PercentValidation.js +28 -0
  31. package/es/library/behaviours/field-validation/domain/field-vise-validations/PhoneValidation.js +39 -0
  32. package/es/library/behaviours/field-validation/domain/field-vise-validations/PicklistValidation.js +24 -0
  33. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextAreaValidation.js +39 -0
  34. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextBoxValidation.js +39 -0
  35. package/es/library/behaviours/field-validation/domain/field-vise-validations/URLValidation.js +28 -0
  36. package/es/library/behaviours/field-validation/domain/interfaces/FieldTypes.js +20 -0
  37. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsEnum.js +22 -0
  38. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsMap.js +1 -0
  39. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateField.js +0 -0
  40. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateTimeField.js +0 -0
  41. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDecimalField.js +0 -0
  42. package/es/library/behaviours/field-validation/domain/interfaces/fields/IEmailField.js +0 -0
  43. package/es/library/behaviours/field-validation/domain/interfaces/fields/IIntegerField.js +0 -0
  44. package/es/library/behaviours/field-validation/domain/interfaces/fields/ILookUpField.js +0 -0
  45. package/es/library/behaviours/field-validation/domain/interfaces/fields/IMultiSelectField.js +0 -0
  46. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPercentField.js +0 -0
  47. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPhoneField.js +0 -0
  48. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPicklistField.js +0 -0
  49. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextAreaField.js +0 -0
  50. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextBoxField.js +0 -0
  51. package/es/library/behaviours/field-validation/domain/interfaces/fields/IURLField.js +0 -0
  52. package/es/library/behaviours/field-validation/frameworks/ui/EventHandlerFactory.js +23 -0
  53. package/es/library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory.js +27 -0
  54. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/BooleanFieldValidation.test.js +137 -0
  55. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/CurrencyFieldValidation.test.js +228 -0
  56. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateFieldValidation.test.js +108 -0
  57. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateTimeFieldValidation.test.js +108 -0
  58. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DecimalFieldValidation.test.js +257 -0
  59. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/EmailFieldValidation.test.js +139 -0
  60. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/FieldValidationBehaviour.test.js +171 -0
  61. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/IntegerFieldValidation.test.js +168 -0
  62. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/LookUpFieldValidation.test.js +108 -0
  63. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/MultiSelectFieldValidation.test.js +79 -0
  64. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PercentFieldValidation.test.js +108 -0
  65. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PhoneFieldValidation.test.js +168 -0
  66. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PicklistFieldValidation.test.js +79 -0
  67. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextAreaFieldValidation.test.js +170 -0
  68. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextBoxFieldValidation.test.js +170 -0
  69. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/URLFieldValidation.test.js +108 -0
  70. package/es/library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor.js +228 -0
  71. package/es/library/behaviours/field-validation/frameworks/utils/__tests__/formValidate.test.js +284 -0
  72. package/es/library/behaviours/field-validation/frameworks/utils/formValidate.js +334 -0
  73. package/es/library/dot/components/form-fields/checkbox/adapters/presenter/TransformState.js +22 -0
  74. package/es/library/dot/components/form-fields/currency/adapters/presenter/TransformState.js +81 -0
  75. package/es/library/dot/components/form-fields/date/adapters/presenter/TransformState.js +22 -0
  76. package/es/library/dot/components/form-fields/datetime/adapters/presenter/TransformState.js +22 -0
  77. package/es/library/dot/components/form-fields/decimal/adapters/presenter/TransformState.js +31 -0
  78. package/es/library/dot/components/form-fields/email/adapters/presenter/TransformState.js +23 -0
  79. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITag.js +10 -0
  80. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITagView.js +21 -0
  81. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/css/EPHITag.module.css +3 -0
  82. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIcon.js +10 -0
  83. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIconView.js +21 -0
  84. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/css/InfoIcon.module.css +3 -0
  85. package/es/library/dot/components/form-fields/multi-select/adapters/presenter/TransformState.js +31 -0
  86. package/es/library/dot/components/form-fields/number/adapters/presenter/TransformState.js +31 -0
  87. package/es/library/dot/components/form-fields/percentage/adapters/presenter/TransformState.js +31 -0
  88. package/es/library/dot/components/form-fields/phone/adapters/presenter/TransformState.js +31 -0
  89. package/es/library/dot/components/form-fields/pick-list/adapters/presenter/TransformState.js +23 -0
  90. package/es/library/dot/components/form-fields/textarea/adapters/presenter/TransformState.js +23 -0
  91. package/es/library/dot/components/form-fields/textbox/adapters/presenter/TransformState.js +32 -0
  92. package/es/library/dot/components/form-fields/url/adapters/presenter/TransformState.js +31 -0
  93. package/es/library/dot/components/section/adapters/presenter/TransFormState.js +26 -0
  94. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelAction.js +9 -0
  95. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelActionView.js +38 -0
  96. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/css/LabelAction.module.css +4 -0
  97. package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +18 -0
  98. package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +4 -2
  99. package/es/platform/zdata-source/domain/entities/APITemplate.js +2 -1
  100. package/es/platform/zform/adapters/controllers/ValidateErrorMessageController.js +22 -0
  101. package/es/platform/zform/applications/interfaces/input/GetIsFieldValueChangedUseCaseInput.js +1 -0
  102. package/es/platform/zform/applications/interfaces/input/ValidateErrorMessageInputModel.js +1 -0
  103. package/es/platform/zform/applications/usecases/GetIsFieldValueChanged.js +35 -0
  104. package/es/platform/zform/applications/usecases/ValidateErrorMessageUseCase.js +33 -0
  105. package/es/platform/zform/applications/usecases/ValidateFieldRequestUseCase.js +56 -0
  106. package/es/platform/zform/domain/ZField.js +4 -0
  107. package/package.json +1 -1
  108. package/es/bc/app-context/Event.js +0 -1
  109. package/es/bc/app-context/Properties.js +0 -58
  110. package/es/cc/component/ErrorStructure.js +0 -9
  111. package/es/cc/error-state/ErrorTypes.js +0 -11
  112. package/es/cc/error-state/Properties.js +0 -31
  113. package/es/cc/error-state/index.js +0 -2
  114. package/es/library/custom-component/domain/entities/ComponentProperties.js +0 -121
  115. package/es/library/custom-component/domain/entities/Logger.js +0 -63
  116. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState.js +0 -10
  117. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorStateView.js +0 -68
  118. package/es/platform/app-context-behaviour/adapters/controllers/InitializeController.js +0 -19
  119. package/es/platform/app-context-behaviour/adapters/gateways/Service.js +0 -7
  120. package/es/platform/app-context-behaviour/adapters/presenters/Presenter.js +0 -18
  121. package/es/platform/app-context-behaviour/adapters/resources/AppResource.js +0 -25
  122. package/es/platform/app-context-behaviour/applications/AbstractUseCase.js +0 -6
  123. package/es/platform/app-context-behaviour/applications/usecases/InitializeUseCase.js +0 -15
  124. package/es/platform/app-context-behaviour/frameworks/AppContextBehaviourFactory.js +0 -31
  125. package/es/platform/app-context-behaviour/frameworks/EventHandlerFactory.js +0 -25
  126. package/es/platform/components/form-connected/frameworks/FallbackView.js +0 -23
  127. package/es/platform/data-source/http-template/getDependencyMappings.js +0 -18
  128. package/es/platform/data-source/http-template/getLayoutRules.js +0 -29
  129. package/es/platform/data-source/http-template/getMyForm.js +0 -19
  130. package/es/platform/data-source/http-template/getMyLayout.js +0 -43
  131. package/es/platform/data-source/http-template/getValidationRules.js +0 -30
  132. package/es/platform/zform/adapters/controllers/ApiFailureController.js +0 -31
  133. package/es/platform/zform/applications/usecases/ApiFailureUseCase.js +0 -30
  134. /package/es/{platform/app-context-behaviour/applications/interfaces/UsecaseDependencies.js → library/behaviours/field-validation/applications/interfaces/UseCaseDependencies.js} +0 -0
  135. /package/es/{platform/app-context-behaviour/applications/interfaces/gateways/IService.js → library/behaviours/field-validation/applications/interfaces/gateways/IRepository.js} +0 -0
  136. /package/es/{platform/app-context-behaviour/applications/interfaces/input/InitializeUseCaseInputModel.js → library/behaviours/field-validation/applications/interfaces/gateways/IService.js} +0 -0
  137. /package/es/{platform/app-context-behaviour/applications/interfaces/output/BehaviourState.js → library/behaviours/field-validation/applications/interfaces/input/FieldValidationInputModel.js} +0 -0
  138. /package/es/{platform/app-context-behaviour/applications/interfaces/output/IPresenter.js → library/behaviours/field-validation/applications/interfaces/input/ValidateFieldsInputModel.js} +0 -0
  139. /package/es/{bc/app-context/Constants.js → library/behaviours/field-validation/domain/interfaces/IField.js} +0 -0
  140. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ApiHeaderContract.js → library/behaviours/field-validation/domain/interfaces/IFieldValidation.js} +0 -0
  141. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ContextContract.js → library/behaviours/field-validation/domain/interfaces/IFieldViseValidation.js} +0 -0
  142. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/IAppResource.js → library/behaviours/field-validation/domain/interfaces/ValidationResult.js} +0 -0
  143. /package/es/{platform/zform/applications/interfaces/input/ApiFailureInputModel.js → library/behaviours/field-validation/domain/interfaces/ValidationsArray.js} +0 -0
  144. /package/es/{bc/app-context/EventHandlers.js → library/behaviours/field-validation/domain/interfaces/fields/IBooleanField.js} +0 -0
  145. /package/es/library/{custom-component/domain/entities/interfaces/IComponentProperties.js → behaviours/field-validation/domain/interfaces/fields/ICurrencyField.js} +0 -0
@@ -0,0 +1,334 @@
1
+ /** Libraries * */
2
+ // import { i18NProviderUtils } from '@zohodesk/i18n';
3
+ const i18NProviderUtils = {
4
+ getI18NValue(key, values) {
5
+ return key;
6
+ }
7
+
8
+ };
9
+ /** Methods * */
10
+
11
+ const formatWebsiteUrl = url => {
12
+ const whitelistedDomains = ['htt' + 'p://', 'htt' + 'ps://', 'ftp://', 'simplehelp://', 'dynamicsnav://'];
13
+ const site = url.toLowerCase();
14
+ const isValidWebsite = whitelistedDomains.some(domain => site.startsWith(domain));
15
+
16
+ if (!isValidWebsite) {
17
+ return `htt${''}p://${url}`;
18
+ }
19
+
20
+ return url;
21
+ };
22
+
23
+ function getNoneText() {
24
+ const valueNoneText = '-None-';
25
+ return {
26
+ valueNoneText
27
+ };
28
+ } // let ticketFieldTypes = [
29
+ // 'LookUp String',
30
+ // 'Picklist String',
31
+ // 'Multiselect Array',
32
+ // 'Email String',
33
+ // 'Text String',
34
+ // 'Textarea String',
35
+ // 'Date String',
36
+ // 'DateTime String',
37
+ // 'Boolean boolean',
38
+ // 'URL String',
39
+ // 'Phone phone',
40
+ // 'Number Number',
41
+ // 'Percent String',
42
+ // 'Decimal String',
43
+ // 'Currency String'
44
+ // ];
45
+
46
+
47
+ export const validator = {
48
+ isEmpty(value) {
49
+ const valueType = typeof value;
50
+
51
+ if (valueType === 'string') {
52
+ return this.isEmptyString(value);
53
+ }
54
+
55
+ if (Array.isArray(value)) {
56
+ return this.isEmptyArr(value);
57
+ }
58
+
59
+ if (valueType === 'object') {
60
+ return this.isEmptyObj(value);
61
+ }
62
+
63
+ if (valueType === 'boolean' || value) {
64
+ return false;
65
+ }
66
+
67
+ return true;
68
+ },
69
+
70
+ isEmptyString(value) {
71
+ if (value && typeof value === 'string' && value.trim()) {
72
+ return false;
73
+ }
74
+
75
+ return true;
76
+ },
77
+
78
+ isEmptyArr(value) {
79
+ if (Array.isArray(value) && value.length > 0) {
80
+ return false;
81
+ }
82
+
83
+ return true;
84
+ },
85
+
86
+ isEmptyMultiSelect(value) {
87
+ if (!this.isEmpty(value) && !(value.length <= 2 && value.every(val => this.isNoneValue(val)))) {
88
+ return false;
89
+ }
90
+
91
+ return true;
92
+ },
93
+
94
+ isEmptyPicklist(value) {
95
+ if (!this.isEmpty(value) && !this.isNoneValue(value)) {
96
+ return false;
97
+ }
98
+
99
+ return true;
100
+ },
101
+
102
+ isEmptyObj(value) {
103
+ for (const key in value) {
104
+ if (value.hasOwnProperty(key)) {
105
+ return false;
106
+ }
107
+ }
108
+
109
+ return true;
110
+ },
111
+
112
+ isValidLength(value, length) {
113
+ let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'max';
114
+ const valueType = typeof value;
115
+ const inpVal = valueType === 'number' ? value.toString() : value;
116
+ const valueLength = (inpVal || '').length;
117
+
118
+ if (valueType === 'string' || valueType === 'number' || Array.isArray(value)) {
119
+ if (type === 'max' && valueLength > length) {
120
+ return true;
121
+ }
122
+
123
+ if (type === 'min' && valueLength < length) {
124
+ return true;
125
+ }
126
+
127
+ return false;
128
+ }
129
+
130
+ return false;
131
+ },
132
+
133
+ isMaxLength(value, argum) {
134
+ return this.isValidLength(value, argum, 'max');
135
+ },
136
+
137
+ isMinLength(value, argum) {
138
+ return this.isValidLength(value, argum, 'min');
139
+ },
140
+
141
+ isValidInteger(value) {
142
+ const valueType = typeof value;
143
+ const inpVal = valueType === 'number' ? value.toString() : value;
144
+
145
+ if (inpVal) {
146
+ const re = /(^-?\d\d*$)/;
147
+
148
+ if (isNaN(inpVal) || inpVal.indexOf('.') !== -1 || !re.test(inpVal)) {
149
+ return false;
150
+ }
151
+
152
+ return true;
153
+ }
154
+
155
+ return false;
156
+ },
157
+
158
+ isValidDecimal(value) {
159
+ const valueType = typeof value;
160
+ const inpVal = valueType === 'number' ? value.toString() : value;
161
+ const restr = '^-?[0-9]\\d*(|\\.\\d[0-9]*)$';
162
+ const re = new RegExp(restr);
163
+
164
+ if (re.test(inpVal)) {
165
+ return true;
166
+ }
167
+
168
+ return false;
169
+ },
170
+
171
+ isValidDecimalPlaces(value, decimalPlaces) {
172
+ const valueType = typeof value;
173
+ const inpVal = valueType === 'number' ? value.toString() : value;
174
+ const restr = `^-?\\d*(|\\.\\d[0-9]{0,${decimalPlaces - 1}})$`;
175
+ const re = new RegExp(restr);
176
+
177
+ if (re.test(inpVal)) {
178
+ return true;
179
+ }
180
+
181
+ return false;
182
+ },
183
+
184
+ isValidPhone(value) {
185
+ // old validation
186
+ const phoneRegEx = /^[0-9a-zA-Z_()\+\-\.\$@\?\,\:\'\/\!\s]+/;
187
+ const match = value.match(phoneRegEx);
188
+
189
+ if (!match || value !== match[0]) {
190
+ return false;
191
+ }
192
+
193
+ return true; // let valueType = typeof value;
194
+ // let inpVal = valueType === 'number' ? value.toString() : value;
195
+ // let re = new RegExp(/^\+?\d+(-\d+)*$/);
196
+ // if (re.test(inpVal)) {
197
+ // return true;
198
+ // }
199
+ // return false;
200
+ },
201
+
202
+ isValidEmail(value, isReplyValidation) {
203
+ const re = isReplyValidation ? /^[\wÀ-ž\+\#]([\wÀ-ž\-\.\+\'\&\/\#\~]*)@([\wÀ-ž\-\.]*)(\.[a-zA-ZÀ-ž]{2,22}(\.[a-zA-ZÀ-ž]{2}){0,2})$/ : /^[\wÀ-ž]([\wÀ-ž\-\.\+\'\&\/]*)@([\wÀ-ž\-\.]*)(\.[a-zA-ZÀ-ž]{2,22}(\.[a-zA-ZÀ-ž]{2}){0,2})$/; // swedish character support
204
+ // let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
205
+
206
+ if (re.test(value)) {
207
+ return true;
208
+ }
209
+
210
+ return false;
211
+ },
212
+
213
+ isValidWebsite(value) {
214
+ const newValue = formatWebsiteUrl(value);
215
+ const re = /^(ht|f)tp(s?):\/\/[-.\w]*(\/?)([a-zA-Z0-9\-\.\?,:'\/\\\+=&amp;%\$#_@]*)?$/;
216
+
217
+ if (re.test(newValue)) {
218
+ return true;
219
+ }
220
+
221
+ return false;
222
+ },
223
+
224
+ isValidDate(dateObj) {
225
+ if (dateObj || dateObj instanceof Date && dateObj.getFullYear() > 1000) {
226
+ return true;
227
+ }
228
+
229
+ return false;
230
+ },
231
+
232
+ isReminder(value) {
233
+ const alerTypes = value.alertTypes || [];
234
+ return !!alerTypes.length;
235
+ },
236
+
237
+ isNoneValue() {
238
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
239
+ const inpVal = value.trim && value.trim();
240
+ const {
241
+ valueNoneText: noneText
242
+ } = getNoneText();
243
+ const i18nNoneValue = i18NProviderUtils.getI18NValue('-None-');
244
+
245
+ if (typeof inpVal === 'string' && (inpVal === noneText || inpVal === i18nNoneValue)) {
246
+ return true;
247
+ }
248
+
249
+ return false;
250
+ },
251
+
252
+ isValidDuration() {
253
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
254
+ const {
255
+ hoursSpent,
256
+ minutesSpent
257
+ } = value;
258
+
259
+ if (hoursSpent < 24 && minutesSpent < 60) {
260
+ return true;
261
+ }
262
+
263
+ return false;
264
+ }
265
+
266
+ };
267
+ export function fieldValidate(value, fieldDetails) {
268
+ const patternMapping = {
269
+ LookUp: '',
270
+ Email: 'isValidEmail',
271
+ Number: 'isValidInteger',
272
+ Text: '',
273
+ // No Check
274
+ Picklist: '',
275
+ // No Check
276
+ Textarea: '',
277
+ // No Check
278
+ DateTime: 'isValidDate',
279
+ // valid date check or valid dateTime check
280
+ Currency: 'isValidDecimal',
281
+ // check only decimal & decimal places, server side convert rouding option
282
+ Decimal: 'isValidDecimal',
283
+ Percent: 'isValidDecimal',
284
+ Boolean: '',
285
+ // No Check
286
+ Phone: 'isValidPhone',
287
+ // URL: 'isValidWebsite',// remove for validation
288
+ Date: 'isValidDate',
289
+ Radio: '',
290
+ // No Check
291
+ Duration: '',
292
+ // No Check
293
+ Multiselect: '' // No Check
294
+
295
+ };
296
+ const emptyValidateMapping = {
297
+ Multiselect: 'isEmptyMultiSelect',
298
+ Picklist: 'isEmptyPicklist'
299
+ };
300
+ const {
301
+ isMandatory,
302
+ i18NLabel,
303
+ type: fieldType,
304
+ maxLength,
305
+ decimalPlaces,
306
+ apiName: fieldName,
307
+ localizedValue = ''
308
+ } = fieldDetails;
309
+ const fieldLabel = localizedValue || i18NLabel;
310
+ const validationMethod = patternMapping[fieldType];
311
+ let isError = false;
312
+ let message = '';
313
+ const emptyValidationMethod = emptyValidateMapping[fieldType];
314
+ const isEmptyValue = emptyValidationMethod ? validator[emptyValidationMethod](value) : validator.isEmpty(value);
315
+
316
+ if (isMandatory && isEmptyValue || isMandatory && fieldType === 'Boolean' && (value === false || value === 'false')) {
317
+ isError = true;
318
+ message = i18NProviderUtils.getI18NValue('crm.field.empty.check', fieldLabel);
319
+ } else if (maxLength && fieldType !== 'Boolean' && fieldType !== 'DateTime' && fieldType !== 'Date' && validator.isMaxLength(value, maxLength)) {
320
+ isError = true;
321
+ message = i18NProviderUtils.getI18NValue('support.form.more.than.max.length', [fieldLabel, maxLength]);
322
+ } else if (!isEmptyValue && validationMethod && !validator[validationMethod](value)) {
323
+ isError = true;
324
+ message = i18NProviderUtils.getI18NValue('crm.field.valid.check', fieldLabel);
325
+ } else if (!isEmptyValue && (fieldType === 'Currency' || fieldType === 'Decimal') && !validator.isValidDecimalPlaces(value, decimalPlaces)) {
326
+ isError = true;
327
+ message = i18NProviderUtils.getI18NValue('support.form.decimal.places.length.error.message', decimalPlaces);
328
+ }
329
+
330
+ return {
331
+ isError,
332
+ message
333
+ };
334
+ }
@@ -0,0 +1,22 @@
1
+ export function TransformState(state) {
2
+ const {
3
+ tooltip
4
+ } = state.properties;
5
+ let actions = [];
6
+
7
+ if (tooltip) {
8
+ actions.push({
9
+ type: 'InfoIcon',
10
+ eventMappings: [],
11
+ properties: {
12
+ tooltip
13
+ }
14
+ });
15
+ }
16
+
17
+ return { ...state,
18
+ viewModel: { ...state.properties,
19
+ actions
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,81 @@
1
+ // import TransFormState from '../../adapters/presenter/TransFormState';
2
+ function isValidInteger() {
3
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
4
+ const rejexPattern = new RegExp('^(\\d+\\.?\\d*|\\.\\d+)$');
5
+ const isValidInt = rejexPattern.test(value);
6
+ return isValidInt;
7
+ }
8
+
9
+ function formatCurrency(amount) {
10
+ let symbol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
11
+ let currencyLocale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'US';
12
+ const isFormatNeeded = typeof amount === 'string' && amount.match(/(e|E)/) != null;
13
+ let number = isFormatNeeded ? Number(amount) : amount;
14
+ const isValidInt = isValidInteger(number);
15
+
16
+ if (isValidInt && symbol) {
17
+ number = number.toString();
18
+ const currencyArr = new Intl.NumberFormat(`en-${currencyLocale}`).formatToParts(number);
19
+ let currencyVal = '';
20
+ currencyArr.map(val => {
21
+ if (val.type == 'group') {
22
+ currencyVal += ',';
23
+ } else if (val.type == 'integer') {
24
+ currencyVal += val.value;
25
+ }
26
+ });
27
+
28
+ if (number.indexOf('.') != -1) {
29
+ const fractionVal = number.split(".")[1];
30
+
31
+ for (let i = fractionVal.length - 1; i >= 0; i--) {
32
+ if (fractionVal[i] != 0) {
33
+ currencyVal += `.${fractionVal.slice(0, i + 1)}`;
34
+ break;
35
+ }
36
+ }
37
+ }
38
+
39
+ return `${symbol}${currencyVal}`;
40
+ }
41
+
42
+ return number || amount;
43
+ }
44
+
45
+ export function TransformState(state) {
46
+ const {
47
+ ePHI,
48
+ tooltip,
49
+ value,
50
+ currencySymbol,
51
+ currencyLocale
52
+ } = state.properties;
53
+ let actions = [];
54
+
55
+ if (tooltip) {
56
+ actions.push({
57
+ type: 'InfoIcon',
58
+ eventMappings: [],
59
+ properties: {
60
+ tooltip
61
+ }
62
+ });
63
+ }
64
+
65
+ if (ePHI) {
66
+ actions.push({
67
+ type: 'EPHITag',
68
+ properties: {},
69
+ eventMappings: []
70
+ });
71
+ }
72
+
73
+ const formattedValue = formatCurrency(value, currencySymbol, currencyLocale);
74
+ return { ...state,
75
+ formattedValue,
76
+ properties: { ...state.properties,
77
+ actions,
78
+ value
79
+ }
80
+ };
81
+ }
@@ -0,0 +1,22 @@
1
+ export function TransformState(state) {
2
+ const {
3
+ tooltip
4
+ } = state.properties;
5
+ let actions = [];
6
+
7
+ if (tooltip) {
8
+ actions.push({
9
+ type: 'InfoIcon',
10
+ eventMappings: [],
11
+ properties: {
12
+ tooltip
13
+ }
14
+ });
15
+ }
16
+
17
+ return { ...state,
18
+ viewModel: { ...state.properties,
19
+ actions
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,22 @@
1
+ export function TransformState(state) {
2
+ const {
3
+ tooltip
4
+ } = state.properties;
5
+ let actions = [];
6
+
7
+ if (tooltip) {
8
+ actions.push({
9
+ type: 'InfoIcon',
10
+ eventMappings: [],
11
+ properties: {
12
+ tooltip
13
+ }
14
+ });
15
+ }
16
+
17
+ return { ...state,
18
+ viewModel: { ...state.properties,
19
+ actions
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,31 @@
1
+ export function TransformState(state) {
2
+ const {
3
+ ePHI,
4
+ tooltip
5
+ } = state.properties;
6
+ let actions = [];
7
+
8
+ if (tooltip) {
9
+ actions.push({
10
+ type: 'InfoIcon',
11
+ eventMappings: [],
12
+ properties: {
13
+ tooltip
14
+ }
15
+ });
16
+ }
17
+
18
+ if (ePHI) {
19
+ actions.push({
20
+ type: 'EPHITag',
21
+ properties: {},
22
+ eventMappings: []
23
+ });
24
+ }
25
+
26
+ return { ...state,
27
+ viewModel: { ...state.properties,
28
+ actions
29
+ }
30
+ };
31
+ }
@@ -0,0 +1,23 @@
1
+ // import TransFormState from '../../adapters/presenter/TransFormState';
2
+ export function TransformState(state) {
3
+ const {
4
+ tooltip
5
+ } = state.properties;
6
+ let actions = [];
7
+
8
+ if (tooltip) {
9
+ actions.push({
10
+ type: 'InfoIcon',
11
+ eventMappings: [],
12
+ properties: {
13
+ tooltip
14
+ }
15
+ });
16
+ }
17
+
18
+ return { ...state,
19
+ properties: { ...state.properties,
20
+ actions
21
+ }
22
+ };
23
+ }
@@ -0,0 +1,10 @@
1
+ import { createCustomComponent } from "../../../../../../custom-component";
2
+ import EPHITagView from "./EPHITagView";
3
+ const EPHITag = createCustomComponent({
4
+ name: 'EPHITag',
5
+ View: EPHITagView,
6
+ properties: {},
7
+ eventHandlers: {},
8
+ behaviours: []
9
+ });
10
+ export default EPHITag;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import Tag from '@zohodesk-private/desk-components/es/table/StatusBox/StatusBox'; // @ts-ignore
3
+
4
+ import style from "./css/EPHITag.module.css";
5
+
6
+ function EPHITagView(_, ref) {
7
+ const ephiTooltip = 'ePHI is individually identifiable protected health information sent or stored electronically.';
8
+ return /*#__PURE__*/React.createElement(Tag, {
9
+ $customProps_container: {
10
+ ref
11
+ },
12
+ customStyle: {
13
+ container: style.tag
14
+ },
15
+ $ui_color: "green",
16
+ $i18n_text: 'ePHI',
17
+ $i18n_tooltip: ephiTooltip
18
+ });
19
+ }
20
+
21
+ export default EPHITagView;
@@ -0,0 +1,10 @@
1
+ import { createCustomComponent } from "../../../../../../custom-component";
2
+ import InfoIconProperties from "../../../../../../../cc/info-icon/Properties";
3
+ import InfoIconView from "./InfoIconView";
4
+ const InfoIcon = createCustomComponent({
5
+ name: 'InfoIcon',
6
+ View: InfoIconView,
7
+ properties: InfoIconProperties,
8
+ eventHandlers: {}
9
+ });
10
+ export default InfoIcon;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import ActionIcon from '@zohodesk-private/desk-components/es/ActionIcon/ActionIcon'; // @ts-ignore
3
+
4
+ import style from "./css/InfoIcon.module.css";
5
+ export default function InfoIconView(_ref, ref) {
6
+ let {
7
+ state
8
+ } = _ref;
9
+ const {
10
+ tooltip
11
+ } = state.properties;
12
+ return /*#__PURE__*/React.createElement(ActionIcon, {
13
+ ref: ref,
14
+ $ui_iconName: "ZD-GN-info",
15
+ $ui_hoverVariant: "default",
16
+ $i18n_tooltip: tooltip,
17
+ customStyle: {
18
+ icon: style.icon
19
+ }
20
+ });
21
+ }
@@ -0,0 +1,31 @@
1
+ export function TransformState(state) {
2
+ const {
3
+ tooltip,
4
+ ePHI
5
+ } = state.properties;
6
+ let actions = [];
7
+
8
+ if (tooltip) {
9
+ actions.push({
10
+ type: 'InfoIcon',
11
+ eventMappings: [],
12
+ properties: {
13
+ tooltip
14
+ }
15
+ });
16
+ }
17
+
18
+ if (ePHI) {
19
+ actions.push({
20
+ type: 'EPHITag',
21
+ properties: {},
22
+ eventMappings: []
23
+ });
24
+ }
25
+
26
+ return { ...state,
27
+ properties: { ...state.properties,
28
+ actions
29
+ }
30
+ };
31
+ }
@@ -0,0 +1,31 @@
1
+ export function TransformState(state) {
2
+ const {
3
+ ePHI,
4
+ tooltip
5
+ } = state.properties;
6
+ let actions = [];
7
+
8
+ if (tooltip) {
9
+ actions.push({
10
+ type: 'InfoIcon',
11
+ eventMappings: [],
12
+ properties: {
13
+ tooltip
14
+ }
15
+ });
16
+ }
17
+
18
+ if (ePHI) {
19
+ actions.push({
20
+ type: 'EPHITag',
21
+ properties: {},
22
+ eventMappings: []
23
+ });
24
+ }
25
+
26
+ return { ...state,
27
+ viewModel: { ...state.properties,
28
+ actions
29
+ }
30
+ };
31
+ }