@formio/js 5.0.0-rc.69 → 5.0.0-rc.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +28 -17
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +29 -18
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +3 -3
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +21 -10
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Webform.js +1 -1
  17. package/lib/cjs/WebformBuilder.js +11 -2
  18. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  19. package/lib/cjs/components/_classes/nested/NestedComponent.js +4 -1
  20. package/lib/cjs/components/currency/Currency.d.ts +1 -0
  21. package/lib/cjs/components/number/Number.d.ts +7 -1
  22. package/lib/cjs/components/number/Number.js +11 -0
  23. package/lib/cjs/components/number/fixtures/comp10.d.ts +18 -0
  24. package/lib/cjs/components/number/fixtures/comp10.js +21 -0
  25. package/lib/cjs/components/number/fixtures/index.d.ts +2 -1
  26. package/lib/cjs/components/number/fixtures/index.js +3 -1
  27. package/lib/cjs/components/panel/Panel.d.ts +1 -0
  28. package/lib/cjs/components/panel/Panel.js +1 -0
  29. package/lib/cjs/components/time/Time.d.ts +2 -2
  30. package/lib/cjs/components/time/Time.js +3 -2
  31. package/lib/cjs/components/time/fixtures/comp4.d.ts +166 -0
  32. package/lib/cjs/components/time/fixtures/comp4.js +171 -0
  33. package/lib/cjs/components/time/fixtures/index.d.ts +2 -1
  34. package/lib/cjs/components/time/fixtures/index.js +3 -1
  35. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +4 -3
  36. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  37. package/lib/cjs/utils/utils.d.ts +1 -10
  38. package/lib/cjs/utils/utils.js +59 -7
  39. package/lib/mjs/Webform.js +1 -1
  40. package/lib/mjs/WebformBuilder.js +10 -2
  41. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  42. package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -1
  43. package/lib/mjs/components/currency/Currency.d.ts +1 -0
  44. package/lib/mjs/components/number/Number.d.ts +7 -1
  45. package/lib/mjs/components/number/Number.js +11 -0
  46. package/lib/mjs/components/number/fixtures/comp10.d.ts +18 -0
  47. package/lib/mjs/components/number/fixtures/comp10.js +19 -0
  48. package/lib/mjs/components/number/fixtures/index.d.ts +2 -1
  49. package/lib/mjs/components/number/fixtures/index.js +2 -1
  50. package/lib/mjs/components/panel/Panel.d.ts +1 -0
  51. package/lib/mjs/components/panel/Panel.js +1 -0
  52. package/lib/mjs/components/time/Time.d.ts +2 -2
  53. package/lib/mjs/components/time/Time.js +3 -2
  54. package/lib/mjs/components/time/fixtures/comp4.d.ts +166 -0
  55. package/lib/mjs/components/time/fixtures/comp4.js +169 -0
  56. package/lib/mjs/components/time/fixtures/index.d.ts +2 -1
  57. package/lib/mjs/components/time/fixtures/index.js +2 -1
  58. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +3 -3
  59. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  60. package/lib/mjs/utils/utils.d.ts +1 -10
  61. package/lib/mjs/utils/utils.js +58 -7
  62. package/package.json +2 -2
@@ -0,0 +1,169 @@
1
+ export default {
2
+ "type": "form",
3
+ "display": "wizard",
4
+ "components": [
5
+ {
6
+ "title": "Page 1",
7
+ "breadcrumbClickable": true,
8
+ "buttonSettings": {
9
+ "previous": true,
10
+ "cancel": true,
11
+ "next": true
12
+ },
13
+ "navigateOnEnter": false,
14
+ "saveOnEnter": false,
15
+ "scrollToTop": false,
16
+ "collapsible": false,
17
+ "key": "page1",
18
+ "type": "panel",
19
+ "label": "Page 1",
20
+ "components": [
21
+ {
22
+ "label": "Time",
23
+ "disabled": true,
24
+ "alwaysEnabled": false,
25
+ "tableView": true,
26
+ "defaultValue": "03:03 PM",
27
+ "key": "time1",
28
+ "type": "time",
29
+ "input": true,
30
+ "inputMask": "99:99",
31
+ "hideOnChildrenHidden": false,
32
+ "id": "efw9yyq",
33
+ "placeholder": "",
34
+ "prefix": "",
35
+ "customClass": "",
36
+ "suffix": "",
37
+ "multiple": false,
38
+ "protected": false,
39
+ "unique": false,
40
+ "persistent": true,
41
+ "hidden": false,
42
+ "clearOnHide": true,
43
+ "refreshOn": "",
44
+ "redrawOn": "",
45
+ "modalEdit": false,
46
+ "dataGridLabel": false,
47
+ "labelPosition": "top",
48
+ "description": "",
49
+ "errorLabel": "",
50
+ "tooltip": "",
51
+ "hideLabel": false,
52
+ "tabindex": "",
53
+ "autofocus": false,
54
+ "dbIndex": false,
55
+ "customDefaultValue": "",
56
+ "calculateValue": "",
57
+ "calculateServer": false,
58
+ "widget": {
59
+ "type": "input"
60
+ },
61
+ "attributes": {},
62
+ "validateOn": "change",
63
+ "validate": {
64
+ "required": false,
65
+ "custom": "",
66
+ "customPrivate": false,
67
+ "strictDateValidation": false,
68
+ "multiple": false,
69
+ "unique": false,
70
+ "minLength": "",
71
+ "maxLength": "",
72
+ "pattern": ""
73
+ },
74
+ "conditional": {
75
+ "show": null,
76
+ "when": null,
77
+ "eq": ""
78
+ },
79
+ "overlay": {
80
+ "style": "",
81
+ "left": "",
82
+ "top": "",
83
+ "width": "",
84
+ "height": ""
85
+ },
86
+ "allowCalculateOverride": false,
87
+ "encrypted": false,
88
+ "showCharCount": false,
89
+ "showWordCount": false,
90
+ "properties": {},
91
+ "allowMultipleMasks": false,
92
+ "addons": [],
93
+ "mask": false,
94
+ "inputType": "time",
95
+ "inputFormat": "plain",
96
+ "displayMask": "",
97
+ "spellcheck": true,
98
+ "truncateMultipleSpaces": false,
99
+ "format": "HH:mm",
100
+ "dataFormat": "HH:mm:ss"
101
+ }
102
+ ],
103
+ "input": false,
104
+ "tableView": false,
105
+ "id": "e7vej1d",
106
+ "placeholder": "",
107
+ "prefix": "",
108
+ "customClass": "",
109
+ "suffix": "",
110
+ "multiple": false,
111
+ "defaultValue": null,
112
+ "protected": false,
113
+ "unique": false,
114
+ "persistent": false,
115
+ "hidden": false,
116
+ "clearOnHide": false,
117
+ "refreshOn": "",
118
+ "redrawOn": "",
119
+ "modalEdit": false,
120
+ "dataGridLabel": false,
121
+ "labelPosition": "top",
122
+ "description": "",
123
+ "errorLabel": "",
124
+ "tooltip": "",
125
+ "hideLabel": false,
126
+ "tabindex": "",
127
+ "disabled": false,
128
+ "autofocus": false,
129
+ "dbIndex": false,
130
+ "customDefaultValue": "",
131
+ "calculateValue": "",
132
+ "calculateServer": false,
133
+ "widget": null,
134
+ "attributes": {},
135
+ "validateOn": "change",
136
+ "validate": {
137
+ "required": false,
138
+ "custom": "",
139
+ "customPrivate": false,
140
+ "strictDateValidation": false,
141
+ "multiple": false,
142
+ "unique": false
143
+ },
144
+ "conditional": {
145
+ "show": null,
146
+ "when": null,
147
+ "eq": ""
148
+ },
149
+ "overlay": {
150
+ "style": "",
151
+ "left": "",
152
+ "top": "",
153
+ "width": "",
154
+ "height": ""
155
+ },
156
+ "allowCalculateOverride": false,
157
+ "encrypted": false,
158
+ "showCharCount": false,
159
+ "showWordCount": false,
160
+ "properties": {},
161
+ "allowMultipleMasks": false,
162
+ "addons": [],
163
+ "tree": false,
164
+ "lazyLoad": false,
165
+ "theme": "default",
166
+ "breadcrumb": "default"
167
+ }
168
+ ],
169
+ };
@@ -1,6 +1,7 @@
1
1
  import comp1 from './comp1';
2
2
  import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
+ import comp4 from './comp4';
4
5
  import timeForm from './timeForm';
5
6
  import timeForm2 from './timeForm2';
6
- export { comp1, comp2, comp3, timeForm, timeForm2 };
7
+ export { comp1, comp2, comp3, comp4, timeForm, timeForm2 };
@@ -1,6 +1,7 @@
1
1
  import comp1 from './comp1';
2
2
  import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
+ import comp4 from './comp4';
4
5
  import timeForm from './timeForm';
5
6
  import timeForm2 from './timeForm2';
6
- export { comp1, comp2, comp3, timeForm, timeForm2 };
7
+ export { comp1, comp2, comp3, comp4, timeForm, timeForm2 };
@@ -11,10 +11,10 @@ export default class IsEmptyValue extends ConditionOperator {
11
11
  return false;
12
12
  }
13
13
  execute({ value, instance, conditionComponentPath }) {
14
- const isEmptyValue = _.isEmpty(value);
14
+ const isEmptyValue = _.isEmpty(_.isNumber(value) ? String(value) : value);
15
15
  if (instance && instance.root) {
16
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
17
- return conditionTriggerComponent ? conditionTriggerComponent.isEmpty() : isEmptyValue;
16
+ const conditionTriggerComponent = instance.root?.getComponent && instance.root.getComponent(conditionComponentPath);
17
+ return conditionTriggerComponent?.isEmpty ? conditionTriggerComponent.isEmpty() : isEmptyValue;
18
18
  }
19
19
  return isEmptyValue;
20
20
  }
@@ -17,7 +17,7 @@ export default class IsEqualTo extends ConditionOperator {
17
17
  catch (e) { }
18
18
  }
19
19
  if (instance && instance.root) {
20
- const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
20
+ const conditionTriggerComponent = instance.root?.getComponent && instance.root.getComponent(conditionComponentPath);
21
21
  if (conditionTriggerComponent
22
22
  && isSelectResourceWithObjectValue(conditionTriggerComponent.component)
23
23
  && conditionTriggerComponent.component?.template) {
@@ -56,16 +56,7 @@ export function isMongoId(text: string): boolean;
56
56
  * @param {*} rowData - The contextual row data for the component.
57
57
  */
58
58
  export function checkCalculated(component: import('@formio/core').Component, submission: import('@formio/core').Submission, rowData: any): void;
59
- /**
60
- * Check if a simple conditional evaluates to true.
61
- * @param {import('@formio/core').Component} component - The component to check for the conditional.
62
- * @param {import('@formio/core').SimpleConditional} condition - The condition to check.
63
- * @param {*} row - The row data for the component.
64
- * @param {*} data - The full submission data.
65
- * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
66
- * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
67
- */
68
- export function checkSimpleConditional(component: import('@formio/core').Component, condition: import('@formio/core').SimpleConditional, row: any, data: any, instance: any): boolean;
59
+ export function checkSimpleConditional(component: any, condition: any, row: any, data: any, instance: any): boolean;
69
60
  /**
70
61
  * Returns a components normalized value.
71
62
  * @param {string} compPath - The full path to the component.
@@ -145,6 +145,44 @@ export function checkCalculated(component, submission, rowData) {
145
145
  * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
146
146
  * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
147
147
  */
148
+ function getConditionalPathsRecursive(conditionPaths, data) {
149
+ let currentGlobalIndex = 0;
150
+ const conditionalPathsArray = [];
151
+ const getConditionalPaths = (data, currentPath = '', localIndex = 0) => {
152
+ currentPath = currentPath.replace(/^\.+|\.+$/g, '');
153
+ const currentLocalIndex = localIndex;
154
+ const currentData = _.get(data, currentPath);
155
+ if (Array.isArray(currentData) && currentData.filter(Boolean).length > 0) {
156
+ if (currentData.some(element => typeof element !== 'object')) {
157
+ return;
158
+ }
159
+ const hasInnerDataArray = currentData.find(x => Array.isArray(x[conditionPaths[currentLocalIndex]]));
160
+ if (hasInnerDataArray) {
161
+ currentData.forEach((_, indexOutside) => {
162
+ const innerCompDataPath = `${currentPath}[${indexOutside}].${conditionPaths[currentLocalIndex]}`;
163
+ getConditionalPaths(data, innerCompDataPath, currentLocalIndex + 1);
164
+ });
165
+ }
166
+ else {
167
+ currentData.forEach((x, index) => {
168
+ if (!_.isNil(x[conditionPaths[currentLocalIndex]])) {
169
+ const compDataPath = `${currentPath}[${index}].${conditionPaths[currentLocalIndex]}`;
170
+ conditionalPathsArray.push(compDataPath);
171
+ }
172
+ });
173
+ }
174
+ }
175
+ else {
176
+ if (!conditionPaths[currentGlobalIndex]) {
177
+ return;
178
+ }
179
+ currentGlobalIndex = currentGlobalIndex + 1;
180
+ getConditionalPaths(data, `${currentPath}.${conditionPaths[currentGlobalIndex - 1]}`, currentGlobalIndex);
181
+ }
182
+ };
183
+ getConditionalPaths(data);
184
+ return conditionalPathsArray;
185
+ }
148
186
  export function checkSimpleConditional(component, condition, row, data, instance) {
149
187
  if (condition.when) {
150
188
  const value = getComponentActualValue(condition.when, data, row);
@@ -170,19 +208,32 @@ export function checkSimpleConditional(component, condition, row, data, instance
170
208
  if (!conditionComponentPath) {
171
209
  return true;
172
210
  }
173
- const value = getComponentActualValue(conditionComponentPath, data, row);
174
- const ConditionOperator = ConditionOperators[operator];
175
- return ConditionOperator
176
- ? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
177
- : true;
211
+ const splittedConditionPath = conditionComponentPath.split('.');
212
+ const conditionalPaths = instance?.parent?.type === 'datagrid' || instance?.parent?.type === 'editgrid' ? [] : getConditionalPathsRecursive(splittedConditionPath, data);
213
+ if (conditionalPaths.length > 0) {
214
+ return conditionalPaths.map((path) => {
215
+ const value = getComponentActualValue(path, data, row);
216
+ const ConditionOperator = ConditionOperators[operator];
217
+ return ConditionOperator
218
+ ? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
219
+ : true;
220
+ });
221
+ }
222
+ else {
223
+ const value = getComponentActualValue(conditionComponentPath, data, row);
224
+ const СonditionOperator = ConditionOperators[operator];
225
+ return СonditionOperator
226
+ ? new СonditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
227
+ : true;
228
+ }
178
229
  });
179
230
  let result = false;
180
231
  switch (conjunction) {
181
232
  case 'any':
182
- result = _.some(conditionsResult, res => !!res);
233
+ result = _.some(conditionsResult.flat(), res => !!res);
183
234
  break;
184
235
  default:
185
- result = _.every(conditionsResult, res => !!res);
236
+ result = _.every(conditionsResult.flat(), res => !!res);
186
237
  }
187
238
  return show ? result : !result;
188
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.69",
3
+ "version": "5.0.0-rc.70",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -81,7 +81,7 @@
81
81
  "dependencies": {
82
82
  "@formio/bootstrap": "3.0.0-rc.36",
83
83
  "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.2.0-rc.7",
84
+ "@formio/core": "2.2.0-rc.9",
85
85
  "@formio/text-mask-addons": "^3.8.0-formio.2",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",