@zohodesk/library-platform 1.1.9-alpha.1 → 1.1.9-exp.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 (79) hide show
  1. package/es/bc/app-context/Constants.js +0 -0
  2. package/es/bc/app-context/Event.js +1 -0
  3. package/es/bc/app-context/EventHandlers.js +0 -0
  4. package/es/bc/app-context/Properties.js +58 -0
  5. package/es/bc/zform/Properties.js +6 -0
  6. package/es/bc/zlist/Properties.js +6 -0
  7. package/es/cc/component/ErrorStructure.js +9 -0
  8. package/es/cc/error-state/ErrorTypes.js +11 -0
  9. package/es/cc/error-state/Properties.js +31 -0
  10. package/es/cc/error-state/index.js +2 -0
  11. package/es/cc/fields/currency/Model.js +2 -0
  12. package/es/cc/fields/text/Properties.js +1 -1
  13. package/es/cc/form-connected/ExternalConstants.js +11 -0
  14. package/es/cc/form-connected/index.js +1 -1
  15. package/es/cc/switch/Properties.js +2 -2
  16. package/es/cc/table-connected/Events.js +1 -1
  17. package/es/cc/table-connected/Properties.js +6 -0
  18. package/es/cc/table-connected/constants/Events.js +1 -8
  19. package/es/cc/table-connected/constants/ExternalConstants.js +9 -0
  20. package/es/cc/table-connected/constants/index.js +2 -1
  21. package/es/index.js +12 -2
  22. package/es/library/custom-component/domain/entities/ComponentProperties.js +121 -0
  23. package/es/library/custom-component/domain/entities/Logger.js +63 -0
  24. package/es/library/custom-component/domain/entities/interfaces/IComponentProperties.js +0 -0
  25. package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +71 -10
  26. package/es/library/dot/components/form/frameworks/ui/FormView.js +3 -1
  27. package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +15 -3
  28. package/es/library/dot/components/form-fields/currency/frameworks/ui/EventHandlerFactory.js +8 -0
  29. package/es/library/dot/components/section/frameworks/ui/SectionView.js +1 -0
  30. package/es/library/dot/components/table-list/adapters/controllers/KeyboardRowClickController.js +1 -1
  31. package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +1 -0
  32. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState.js +10 -0
  33. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorStateView.js +68 -0
  34. package/es/library/dot/legacy-to-new-arch/switch/frameworks/ui/SwitchView.js +5 -5
  35. package/es/library/dot/legacy-to-new-arch/table-field-components/currency-field/frameworks/ui/CurrencyFieldView.js +10 -2
  36. package/es/library/dot/legacy-to-new-arch/table-field-components/switch-field/frameworks/ui/SwitchFieldView.js +0 -1
  37. package/es/library/translator-common/adapters/presenter/formatCurrency.js +42 -0
  38. package/es/library/translator-common/index.js +2 -1
  39. package/es/platform/app-context-behaviour/adapters/controllers/AbstractController.js +7 -0
  40. package/es/platform/app-context-behaviour/adapters/controllers/InitializeController.js +19 -0
  41. package/es/platform/app-context-behaviour/adapters/gateways/Service.js +7 -0
  42. package/es/platform/app-context-behaviour/adapters/presenters/Presenter.js +18 -0
  43. package/es/platform/app-context-behaviour/adapters/resources/AppResource.js +25 -0
  44. package/es/platform/app-context-behaviour/applications/AbstractUseCase.js +6 -0
  45. package/es/platform/app-context-behaviour/applications/interfaces/UsecaseDependencies.js +1 -0
  46. package/es/platform/app-context-behaviour/applications/interfaces/gateways/IService.js +1 -0
  47. package/es/platform/app-context-behaviour/applications/interfaces/input/InitializeUseCaseInputModel.js +1 -0
  48. package/es/platform/app-context-behaviour/applications/interfaces/output/BehaviourState.js +1 -0
  49. package/es/platform/app-context-behaviour/applications/interfaces/output/IPresenter.js +1 -0
  50. package/es/platform/app-context-behaviour/applications/interfaces/resources/ApiHeaderContract.js +1 -0
  51. package/es/platform/app-context-behaviour/applications/interfaces/resources/ContextContract.js +1 -0
  52. package/es/platform/app-context-behaviour/applications/interfaces/resources/IAppResource.js +1 -0
  53. package/es/platform/app-context-behaviour/applications/usecases/InitializeUseCase.js +15 -0
  54. package/es/platform/app-context-behaviour/frameworks/AppContextBehaviourFactory.js +31 -0
  55. package/es/platform/app-context-behaviour/frameworks/EventHandlerFactory.js +25 -0
  56. package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +1 -1
  57. package/es/platform/components/form-connected/frameworks/FallbackView.js +23 -0
  58. package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +4 -4
  59. package/es/platform/data-source/http-template/getDependencyMappings.js +18 -0
  60. package/es/platform/data-source/http-template/getLayoutRules.js +29 -0
  61. package/es/platform/data-source/http-template/getMyForm.js +19 -0
  62. package/es/platform/data-source/http-template/getMyLayout.js +43 -0
  63. package/es/platform/data-source/http-template/getValidationRules.js +30 -0
  64. package/es/platform/zform/adapters/controllers/ApiFailureController.js +31 -0
  65. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +7 -2
  66. package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +9 -1
  67. package/es/platform/zform/adapters/presenter/utils/sanitizeHtmlString.js +11 -0
  68. package/es/platform/zform/applications/interfaces/input/ApiFailureInputModel.js +1 -0
  69. package/es/platform/zform/applications/usecases/ApiFailureUseCase.js +30 -0
  70. package/es/platform/zform/domain/ZForm.js +1 -0
  71. package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +1 -1
  72. package/es/platform/zlist/adapters/presenters/TableTranslator.js +1 -1
  73. package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +3 -3
  74. package/es/platform/zlist/adapters/presenters/translators/Row.js +3 -2
  75. package/es/platform/zlist/adapters/presenters/translators/RowsTranslator.js +4 -2
  76. package/es/platform/zlist/adapters/presenters/translators/fields/CurrencyFieldTranslator.js +7 -2
  77. package/es/platform/zlist/adapters/presenters/translators/fields/FormulaFieldTranslator.js +7 -2
  78. package/es/platform/zlist/domain/entities/List.js +2 -2
  79. package/package.json +19 -15
File without changes
@@ -0,0 +1 @@
1
+ export default [];
File without changes
@@ -0,0 +1,58 @@
1
+ export default {
2
+ context: {
3
+ required: false,
4
+ typeMetadata: {
5
+ schema: {
6
+ type: 'object',
7
+ properties: {
8
+ orgId: {
9
+ type: 'string'
10
+ },
11
+ // zlist
12
+ orgName: {
13
+ type: 'string'
14
+ },
15
+ // zlist, zform
16
+ servicePrefix: {
17
+ type: 'string'
18
+ },
19
+ // zlist, zform
20
+ modules: {
21
+ // zlist
22
+ type: 'array',
23
+ items: {
24
+ type: 'object',
25
+ properties: {
26
+ apiKey: {
27
+ type: 'string'
28
+ },
29
+ hasRecycleBin: {
30
+ type: 'boolean'
31
+ },
32
+ nameField: {
33
+ type: 'string'
34
+ }
35
+ } // required: ['apiKey', 'nameField']
36
+ // NOTE: making required should handled inside AppContextBehaviourFactory in future if needed
37
+
38
+ }
39
+ },
40
+ departmentName: {
41
+ type: 'string'
42
+ },
43
+ // zlist
44
+ routing: {
45
+ type: 'object'
46
+ },
47
+ // zlist
48
+ additionalData: {
49
+ type: 'object'
50
+ } // zform
51
+
52
+ },
53
+ // required: ['orgName'],
54
+ additionalProperties: false
55
+ }
56
+ }
57
+ }
58
+ };
@@ -61,6 +61,12 @@ export default {
61
61
  servicePrefix: {
62
62
  type: 'string'
63
63
  },
64
+ currencyLocale: {
65
+ type: 'string'
66
+ },
67
+ currencySymbol: {
68
+ type: 'string'
69
+ },
64
70
  additionalData: {
65
71
  type: 'object'
66
72
  }
@@ -44,6 +44,12 @@ export default {
44
44
  orgName: {
45
45
  type: 'string'
46
46
  },
47
+ currencyLocale: {
48
+ type: 'string'
49
+ },
50
+ currencySymbol: {
51
+ type: 'string'
52
+ },
47
53
  modules: {
48
54
  type: 'array',
49
55
  items: {
@@ -0,0 +1,9 @@
1
+ export let ErrorCodes = /*#__PURE__*/function (ErrorCodes) {
2
+ ErrorCodes["PROPERTY_VALIDATION_FAILED"] = "PROPERTY_VALIDATION_FAILED";
3
+ ErrorCodes["API_FAILED"] = "API_FAILED";
4
+ ErrorCodes["EVENT_HANDLER_FAILED"] = "EVENT_HANDLER_FAILED";
5
+ ErrorCodes["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
6
+ return ErrorCodes;
7
+ }({});
8
+ export const ACA_ERROR_OCCURRED = 'ACA#ERROR_OCCURRED';
9
+ export const ERROR_OCCURRED_SUFFIX = '#ERROR_OCCURRED';
@@ -0,0 +1,11 @@
1
+ var ErrorTypes = /*#__PURE__*/function (ErrorTypes) {
2
+ ErrorTypes["Inconvenience"] = "Inconvenience";
3
+ ErrorTypes["OopsSomethingMiss"] = "OopsSomethingMiss";
4
+ ErrorTypes["UnableToProcess"] = "UnableToProcess";
5
+ ErrorTypes["PermissionDenied"] = "PermissionDenied";
6
+ ErrorTypes["UrlNotFound"] = "UrlNotFound";
7
+ ErrorTypes["WillBeRightBack"] = "WillBeRightBack";
8
+ return ErrorTypes;
9
+ }(ErrorTypes || {});
10
+
11
+ export default ErrorTypes;
@@ -0,0 +1,31 @@
1
+ import ErrorTypes from "./ErrorTypes";
2
+ export default {
3
+ type: {
4
+ defaultValue: ErrorTypes.OopsSomethingMiss,
5
+ required: false,
6
+ typeMetadata: {
7
+ schema: {
8
+ type: 'string',
9
+ enum: Object.values(ErrorTypes)
10
+ }
11
+ }
12
+ },
13
+ title: {
14
+ defaultValue: '',
15
+ required: false,
16
+ typeMetadata: {
17
+ schema: {
18
+ type: 'string'
19
+ }
20
+ }
21
+ },
22
+ description: {
23
+ defaultValue: '',
24
+ required: false,
25
+ typeMetadata: {
26
+ schema: {
27
+ type: 'string'
28
+ }
29
+ }
30
+ }
31
+ };
@@ -0,0 +1,2 @@
1
+ export { default as ErrorStateProperties } from "./Properties";
2
+ export { default as ErrorStateTypes } from "./ErrorTypes";
@@ -2,6 +2,7 @@ export default function CurrencyFieldModel(_ref) {
2
2
  let {
3
3
  name,
4
4
  currencyLocale,
5
+ currencySymbol,
5
6
  value,
6
7
  uiType,
7
8
  appendToActionPayload
@@ -9,6 +10,7 @@ export default function CurrencyFieldModel(_ref) {
9
10
  return {
10
11
  name,
11
12
  currencyLocale,
13
+ currencySymbol,
12
14
  appendToActionPayload,
13
15
  type: uiType,
14
16
  value
@@ -29,7 +29,7 @@ export default { ...FieldProperties,
29
29
  },
30
30
  lookup: {
31
31
  required: false,
32
- defaultValue: '',
32
+ defaultValue: {},
33
33
  typeMetadata: {
34
34
  schema: {
35
35
  type: 'object'
@@ -0,0 +1,11 @@
1
+ class SmartFormConstants {
2
+ static SMART_FORM_FIELD_FOCUSED = 'SMART_FORM#FIELD_FOCUSED';
3
+ static SMART_FORM_FIELD_BLURRED = 'SMART_FORM#FIELD_BLURRED';
4
+ static SMART_FORM_FIELD_VALUE_CHANGED = 'SMART_FORM#FIELD_VALUE_CHANGED';
5
+ static SMART_FORM_SUBMIT_CLICKED = 'SMART_FORM#SUBMIT_CLICKED';
6
+ static SMART_FORM_CANCEL_CLICKED = 'SMART_FORM#CANCEL_CLICKED';
7
+ static SMART_FORM_SUBMIT_SUCCESS = 'SMART_FORM#SUBMIT_SUCCESS';
8
+ static SMART_FORM_SUBMIT_FAILURE = 'SMART_FORM#SUBMIT_FAILED';
9
+ }
10
+
11
+ export default SmartFormConstants;
@@ -1,2 +1,2 @@
1
1
  // export { ErrorCode as SmartFormErrorCode } from './ErrorEventType';
2
- export { default as SmartFormConstants } from "./Constants"; // export { default as SmartFormEventsContracts } from './Events';
2
+ export { default as SmartFormConstants } from "./ExternalConstants"; // export { default as SmartFormEventsContracts } from './Events';
@@ -19,11 +19,11 @@ export default {
19
19
  },
20
20
  size: {
21
21
  required: true,
22
- defaultValue: "small",
22
+ defaultValue: "medium",
23
23
  typeMetadata: {
24
24
  schema: {
25
25
  type: "string",
26
- enum: ["small", "medium"]
26
+ enum: ["small", "medium", "large", "xlarge"]
27
27
  }
28
28
  }
29
29
  },
@@ -1,5 +1,5 @@
1
1
  import { ZListEvents } from "../../bc/zlist";
2
- import SmartTableEventConstants from "./constants/Events";
2
+ import SmartTableEventConstants from "./constants/ExternalConstants";
3
3
  const {
4
4
  DELETE_RECORDS_SUCCESS,
5
5
  UPDATE_RECORDS_SUCCESS,
@@ -25,6 +25,12 @@ export default {
25
25
  properties: {
26
26
  initialWidth: {
27
27
  type: 'number'
28
+ },
29
+ currencyLocale: {
30
+ type: 'string'
31
+ },
32
+ currencySymbol: {
33
+ type: 'string'
28
34
  }
29
35
  }
30
36
  }
@@ -1,15 +1,8 @@
1
1
  export const ERROR_OCCURRED = 'SMART_TABLE#ERROR_OCCURRED';
2
2
  export default {
3
- REORDER_SUCCESS: 'SMART_TABLE#REORDER_SUCCEED',
4
- DELETE_RECORDS_SUCCESS: 'SMART_TABLE#RECORD_DELETED',
5
- UPDATE_RECORDS_SUCCESS: 'SMART_TABLE#RECORD_UPDATED',
6
3
  SORT: 'SMART_TABLE#SORT',
7
4
  SORTED: 'SMART_TABLE#SORTED',
8
- RECORDS_SELECTED: 'SMART_TABLE#RECORDS_SELECTED',
9
- RECORDS_DESELECTED: 'SMART_TABLE#RECORDS_DESELECTED',
10
- SMART_TABLE_ROW_ACTION_TRIGGERED: 'SMART_TABLE#ROW_ACTION_TRIGGERED',
11
- ERROR_OCCURRED,
12
- SELECTION_LIMIT_EXCEEDED: 'SMART_TABLE#SELECTION_LIMIT_EXCEEDED'
5
+ ERROR_OCCURRED
13
6
  };
14
7
  export const SMART_TABLE_SELECTION_TOGGLED = 'SMART_TABLE#SELECTION_TOGGLED';
15
8
  export const SMART_TABLE_ACTION_TRIGGERED = 'SMART_TABLE#ACTION_TRIGGERED';
@@ -0,0 +1,9 @@
1
+ export default {
2
+ REORDER_SUCCESS: 'SMART_TABLE#REORDER_SUCCEED',
3
+ DELETE_RECORDS_SUCCESS: 'SMART_TABLE#RECORD_DELETED',
4
+ UPDATE_RECORDS_SUCCESS: 'SMART_TABLE#RECORD_UPDATED',
5
+ RECORDS_SELECTED: 'SMART_TABLE#RECORDS_SELECTED',
6
+ RECORDS_DESELECTED: 'SMART_TABLE#RECORDS_DESELECTED',
7
+ SMART_TABLE_ROW_ACTION_TRIGGERED: 'SMART_TABLE#ROW_ACTION_TRIGGERED',
8
+ SELECTION_LIMIT_EXCEEDED: 'SMART_TABLE#SELECTION_LIMIT_EXCEEDED'
9
+ };
@@ -1 +1,2 @@
1
- export { default as Events } from "./Events";
1
+ export { default as Events } from "./Events";
2
+ export { default as ExternalConstants } from "./ExternalConstants";
package/es/index.js CHANGED
@@ -1,5 +1,15 @@
1
- import * as _CC from "./cc";
2
- export { _CC as CC };
1
+ // export * as CC from './cc';
2
+ import * as CCNamespace from "./cc"; // Import only the ExternalConstants
3
+
4
+ import ExternalConstants from "./cc/table-connected/constants/ExternalConstants"; // Rebuild SmartTableConstants without Events
5
+
6
+ const SmartTableConstants = {
7
+ ExternalConstants
8
+ }; // Re-export CC, overriding SmartTableConstants
9
+
10
+ export const CC = { ...CCNamespace,
11
+ SmartTableConstants
12
+ };
3
13
  import * as _BC from "./bc";
4
14
  export { _BC as BC };
5
15
  export { TableConnectedFactory, FormConnectedFactory } from "./platform/components";
@@ -0,0 +1,121 @@
1
+ /* eslint-disable complexity */
2
+ import { ErrorCodes } from "../../../../cc/component/ErrorStructure";
3
+ import Logger from "./Logger";
4
+ export default class ComponentProperties {
5
+ constructor(componentName, properties, behaviours) {
6
+ this.componentName = componentName;
7
+ this.properties = properties;
8
+ this.behaviours = behaviours;
9
+ this.logger = new Logger(componentName);
10
+ this.behavioursProperties = {};
11
+ /* store behaviour properties */
12
+
13
+ this.behaviours.forEach(behaviour => {
14
+ behaviour.getProperties().data && behaviour.getProperties().data.forEach(obj => {
15
+ this.behavioursProperties[obj.getName()] = obj.clone();
16
+ });
17
+ });
18
+ }
19
+
20
+ getAllBehavioursPropertiesWithValue() {
21
+ const output = {};
22
+ Object.keys(this.behavioursProperties).forEach(propertyName => {
23
+ output[propertyName] = this.behavioursProperties[propertyName].getValue();
24
+ });
25
+ return output;
26
+ }
27
+
28
+ getAllPropertiesValue() {
29
+ return { ...this.properties.getAllPropertiesValue(),
30
+ ...this.getAllBehavioursPropertiesWithValue()
31
+ };
32
+ }
33
+
34
+ getAllPropertiesKeys() {
35
+ const propKeys = this.properties.getAllPropertiesKeys();
36
+ const bhvrKeys = Object.keys(this.behavioursProperties);
37
+ return [...propKeys, ...bhvrKeys];
38
+ }
39
+
40
+ validateAndUpdateProperties(jsonValidator, newProps) {
41
+ const {
42
+ isValid,
43
+ validationResults
44
+ } = this.validateProperties(jsonValidator, newProps);
45
+
46
+ if (!isValid) {
47
+ this.logger.logPropertiesValidation(validationResults); // console.log({ isValid, componentName: this.componentName, validationResults });
48
+
49
+ throw {
50
+ code: ErrorCodes.PROPERTY_VALIDATION_FAILED,
51
+ message: `Properties validation failed for component ${this.componentName}`,
52
+ errorDetails: {
53
+ isBreaking: true,
54
+ validationResults: validationResults.filter(result => !result.isValid)
55
+ }
56
+ };
57
+ }
58
+
59
+ return this.updateProperties(newProps);
60
+ }
61
+
62
+ updateProperties(newProps) {
63
+ const allProperties = this.getAllPropertiesKeys();
64
+ let isChanged = false;
65
+ allProperties.forEach(key => {
66
+ const property = this.findProperty(key);
67
+
68
+ if (property) {
69
+ isChanged = property.updateValue(newProps[key]) || isChanged;
70
+ }
71
+ });
72
+ return isChanged;
73
+ }
74
+
75
+ getExtraPropertiesError(propertyName) {
76
+ return {
77
+ key: propertyName,
78
+ isValid: false,
79
+ warnings: [{
80
+ keyword: 'extra',
81
+ message: 'Property is not allowed',
82
+ params: {}
83
+ }],
84
+ errors: [],
85
+ schema: {}
86
+ };
87
+ }
88
+
89
+ validateProperties(validator, newProps) {
90
+ const allProperties = this.getAllPropertiesKeys();
91
+ const validationResults = [];
92
+ allProperties.forEach(propertyName => {
93
+ const property = this.findProperty(propertyName);
94
+
95
+ if (property) {
96
+ const result = property.validateProperty(validator, newProps[propertyName]);
97
+ validationResults.push(result);
98
+ } else {
99
+ validationResults.push(this.getExtraPropertiesError(propertyName));
100
+ }
101
+ });
102
+ const isValid = validationResults.every(result => result.isValid);
103
+ return {
104
+ isValid,
105
+ validationResults
106
+ };
107
+ }
108
+
109
+ findProperty(propertyName) {
110
+ if (this.behavioursProperties[propertyName]) {
111
+ return this.behavioursProperties[propertyName];
112
+ }
113
+
114
+ return this.properties.findProperty(propertyName);
115
+ }
116
+
117
+ getAppendToActionPayloadProperty() {
118
+ return this.properties.getAppendToActionPayloadProperty();
119
+ }
120
+
121
+ }
@@ -0,0 +1,63 @@
1
+ // Define types
2
+ // const ERROR_TITLE: string = 'color: red; font-weight: bold;';
3
+ const ERROR_PRIMARY = 'color: #FF6F61;font-weight: bold';
4
+ const ERROR_SECONDARY = 'color: #FFA500;font-weight: initial'; // const LOG_TITLE: string = 'color: gray; font-weight: bold;';
5
+
6
+ const LOG_PRIMARY = 'color: #55c355;font-weight: bold';
7
+ const LOG_SECONDARY = 'color: #5a9de9;font-weight: bold';
8
+ export default class Logger {
9
+ constructor(componentName) {
10
+ this.componentName = componentName;
11
+ } // eslint-disable-next-line max-lines-per-function
12
+
13
+
14
+ logPropertiesValidation(validationResults) {
15
+ console.group(`%cProperties Validation: %c${this.componentName}`, ERROR_PRIMARY, ERROR_SECONDARY, validationResults.filter(result => result.errors?.length > 0 || result.warnings?.length > 0));
16
+ validationResults.filter(result => result.errors?.length > 0 || result.warnings?.length > 0).forEach(result => {
17
+ result.errors?.forEach(error => {
18
+ this.printResult(result.key, error);
19
+ });
20
+ result.warnings?.forEach(warning => {
21
+ this.printResult(result.key, warning);
22
+ });
23
+ });
24
+ console.groupEnd();
25
+ }
26
+
27
+ printResult(key, errorOrWarning) {
28
+ if (errorOrWarning.dataPath) {
29
+ console.error(`Invalid Property %c${key}%c${errorOrWarning.dataPath} %c${errorOrWarning.message}`, ERROR_PRIMARY, ERROR_SECONDARY, 'color: white;');
30
+ return;
31
+ }
32
+
33
+ console.error(`Invalid Property %c${key} : %c${errorOrWarning.message}`, ERROR_PRIMARY, 'color: white;');
34
+ }
35
+
36
+ eventNameConsoleStyle(type) {
37
+ const index = type.indexOf('#');
38
+ return {
39
+ msg: '%c' + type.slice(0, index) + '%c' + type.slice(index),
40
+ styles: [LOG_PRIMARY, LOG_SECONDARY]
41
+ };
42
+ }
43
+
44
+ isLoggingEnabled() {
45
+ // @ts-ignore
46
+ return __DEVELOPMENT__ && globalThis.enableEventLogging;
47
+ }
48
+
49
+ isLoggingEnabledAndTypePresent(type) {
50
+ return this.isLoggingEnabled() && type;
51
+ }
52
+
53
+ logEvent(type, data) {
54
+ if (this.isLoggingEnabledAndTypePresent(type)) {
55
+ const {
56
+ msg,
57
+ styles: nameStyles
58
+ } = this.eventNameConsoleStyle(type);
59
+ console.log(`%cEvent ${msg}`, 'font-weight: bold', ...nameStyles, data);
60
+ }
61
+ }
62
+
63
+ }
@@ -6,28 +6,89 @@ let jsonValidator = new Ajv({
6
6
  class Validator {
7
7
  static validate(schema, value) {
8
8
  let errors = [];
9
+ Validator.checkFunctionsRecursively(schema, value, '', '#', errors); // Use AJV for the rest of the validation, ignoring functions
9
10
 
10
- if (schema.type === 'function' && typeof value === 'function') {
11
- return {
12
- isValid: true,
13
- errors
14
- };
15
- } // validate is a type guard for MyData - type is inferred from schema type
11
+ const ajvSchema = JSON.parse(JSON.stringify(schema, (key, val) => val === 'function' ? undefined : val)); // validate is a type guard for MyData - type is inferred from schema type
12
+ // const validate = jsonValidator.compile(schema);
16
13
 
17
-
18
- const validate = jsonValidator.compile(schema);
14
+ const validate = jsonValidator.compile(ajvSchema);
19
15
  const isValid = validate(value);
20
16
 
21
17
  if (!isValid) {
22
- errors = validate.errors;
18
+ // errors = validate.errors;
19
+ errors.push(...(validate.errors || []));
23
20
  }
24
21
 
25
22
  return {
26
- isValid,
23
+ isValid: isValid && errors.length === 0,
27
24
  errors
28
25
  };
29
26
  }
30
27
 
28
+ static checkFunctionsRecursively(schema, value) {
29
+ let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
30
+ let schemaPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#';
31
+ let errors = arguments.length > 4 ? arguments[4] : undefined;
32
+
33
+ if (schema.type === 'function') {
34
+ if (typeof value !== 'function') {
35
+ errors.push({
36
+ keyword: "type",
37
+ dataPath: path ? `.${path}` : "",
38
+ schemaPath: `${schemaPath}/type`,
39
+ params: {
40
+ type: "function"
41
+ },
42
+ message: "should be function"
43
+ });
44
+ }
45
+
46
+ return;
47
+ }
48
+
49
+ if (schema.type === 'object' && schema.properties && typeof value === 'object' && value !== null) {
50
+ for (const key in schema.properties) {
51
+ Validator.checkFunctionsRecursively(schema.properties[key], value[key], path ? `${path}.${key}` : key, `${schemaPath}/properties/${key}`, errors);
52
+ }
53
+ }
54
+
55
+ if (schema.type === 'array' && Array.isArray(value) && schema.items) {
56
+ value.forEach((item, index) => {
57
+ Validator.checkFunctionsRecursively(schema.items, item, `${path}[${index}]`, `${schemaPath}/items`, errors);
58
+ });
59
+ } // if (schema.anyOf && Array.isArray(schema.anyOf)) {
60
+ // const subErrors = [];
61
+ // const valid = schema.anyOf.some((subSchema, idx) => {
62
+ // const tmpErrors = [];
63
+ // Validator.checkFunctionsRecursively(subSchema, value, path, `${schemaPath}/anyOf/${idx}`, tmpErrors);
64
+ // return tmpErrors.length === 0;
65
+ // });
66
+ // if (!valid) {
67
+ // errors.push({ keyword: "anyOf", dataPath: path ? `.${path}` : "", schemaPath: `${schemaPath}/anyOf`, params: {}, message: "should match some schema in anyOf" });
68
+ // }
69
+ // return;
70
+ // }
71
+ // if (schema.allOf && Array.isArray(schema.allOf)) {
72
+ // schema.allOf.forEach((subSchema, idx) => {
73
+ // Validator.checkFunctionsRecursively(subSchema, value, path, `${schemaPath}/allOf/${idx}`, errors);
74
+ // });
75
+ // return;
76
+ // }
77
+ // if (schema.oneOf && Array.isArray(schema.oneOf)) {
78
+ // let matchCount = 0;
79
+ // schema.oneOf.forEach((subSchema, idx) => {
80
+ // const tmpErrors = [];
81
+ // Validator.checkFunctionsRecursively(subSchema, value, path, `${schemaPath}/oneOf/${idx}`, tmpErrors);
82
+ // if (tmpErrors.length === 0) matchCount++;
83
+ // });
84
+ // if (matchCount !== 1) {
85
+ // errors.push({ keyword: "oneOf", dataPath: path ? `.${path}` : "", schemaPath: `${schemaPath}/oneOf`, params: {}, message: "should match exactly one schema in oneOf" });
86
+ // }
87
+ // return;
88
+ // }
89
+
90
+ }
91
+
31
92
  static validatePropsAgainstSchema(schemaProps, props) {
32
93
  const warnings = [];
33
94
  const errors = [];
@@ -20,10 +20,12 @@ function FormView(_ref, ref) {
20
20
  isFooterEnabled
21
21
  } = state.viewModel;
22
22
  return /*#__PURE__*/React.createElement(Flex, {
23
- $ui_tagName: "form",
24
23
  $ui_displayMode: "flex",
25
24
  $ui_direction: "column",
26
25
  $flag_fullsize: true,
26
+ $a11y_attributes: {
27
+ role: 'form'
28
+ },
27
29
  ref: ref
28
30
  }, /*#__PURE__*/React.createElement(Header, {
29
31
  hasHeader: isHeaderEnabled,
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import TextBox from "../../../../../legacy-to-new-arch/textbox/frameworks/ui/TextBox";
3
- import FieldItem from "../../../field/FieldItem"; // @ts-ignore
3
+ import FieldItem from "../../../field/FieldItem";
4
+ import { formatCurrency } from "../../../../../../translator-common"; // @ts-ignore
4
5
 
5
6
  import style from "../../../../form/frameworks/ui/css/Form.module.css";
6
7
 
@@ -8,6 +9,10 @@ function CurrencyView(_ref, ref) {
8
9
  let {
9
10
  state
10
11
  } = _ref;
12
+ const {
13
+ isFocused,
14
+ properties
15
+ } = state;
11
16
  const {
12
17
  id,
13
18
  label,
@@ -17,14 +22,21 @@ function CurrencyView(_ref, ref) {
17
22
  disabled,
18
23
  readonly,
19
24
  required,
25
+ currencyLocale,
26
+ currencySymbol,
20
27
  labelActions,
21
28
  actions,
22
29
  uiConfig
23
- } = state.properties;
30
+ } = properties;
24
31
  const {
25
32
  size,
26
33
  breakRow
27
34
  } = uiConfig;
35
+ const formattedValue = isFocused ? value : formatCurrency({
36
+ value,
37
+ symbol: currencySymbol,
38
+ locale: currencyLocale
39
+ });
28
40
  return /*#__PURE__*/React.createElement(FieldItem, {
29
41
  ref: ref,
30
42
  id: id,
@@ -39,7 +51,7 @@ function CurrencyView(_ref, ref) {
39
51
  className: style.field
40
52
  }, /*#__PURE__*/React.createElement(TextBox, {
41
53
  id: id,
42
- value: value,
54
+ value: formattedValue,
43
55
  placeholder: placeholder,
44
56
  disabled: disabled,
45
57
  readonly: readonly,
@@ -13,8 +13,12 @@ class EventHandlersFactory {
13
13
  static handleTextBoxFocused(_ref) {
14
14
  let {
15
15
  state,
16
+ updateState,
16
17
  dispatch
17
18
  } = _ref;
19
+ updateState({ ...state,
20
+ isFocused: true
21
+ });
18
22
  const {
19
23
  name
20
24
  } = state.properties;
@@ -30,8 +34,12 @@ class EventHandlersFactory {
30
34
  static handleTextBoxBlurred(_ref2) {
31
35
  let {
32
36
  state,
37
+ updateState,
33
38
  dispatch
34
39
  } = _ref2;
40
+ updateState({ ...state,
41
+ isFocused: false
42
+ });
35
43
  const {
36
44
  name
37
45
  } = state.properties;