@formio/js 5.0.0-dev.5643.17b8168 → 5.0.0-dev.5646.8734cf4
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.
- package/Changelog.md +1 -0
- package/dist/formio.form.js +23 -24
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +23 -24
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +3 -3
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/components/datagrid/fixtures/comp9.d.ts +81 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.js +87 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -2
- package/lib/cjs/components/datagrid/fixtures/index.js +3 -3
- package/lib/cjs/components/file/File.js +1 -2
- package/lib/cjs/components/radio/Radio.js +2 -3
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +4 -3
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/utils.d.ts +0 -10
- package/lib/cjs/utils/utils.js +59 -7
- package/lib/mjs/components/datagrid/fixtures/comp9.d.ts +81 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.js +85 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -2
- package/lib/mjs/components/datagrid/fixtures/index.js +2 -2
- package/lib/mjs/components/file/File.js +1 -2
- package/lib/mjs/components/radio/Radio.js +2 -3
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +3 -3
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/utils.d.ts +0 -10
- package/lib/mjs/utils/utils.js +58 -7
- package/package.json +2 -2
- package/lib/cjs/components/datagrid/fixtures/comp-with-checkboxes.d.ts +0 -29
- package/lib/cjs/components/datagrid/fixtures/comp-with-checkboxes.js +0 -36
- package/lib/mjs/components/datagrid/fixtures/comp-with-checkboxes.d.ts +0 -29
- package/lib/mjs/components/datagrid/fixtures/comp-with-checkboxes.js +0 -34
package/lib/mjs/utils/utils.js
CHANGED
|
@@ -201,6 +201,44 @@ export function checkCalculated(component, submission, rowData) {
|
|
|
201
201
|
* @param instance
|
|
202
202
|
* @returns {boolean}
|
|
203
203
|
*/
|
|
204
|
+
function getConditionalPathsRecursive(conditionPaths, data) {
|
|
205
|
+
let currentGlobalIndex = 0;
|
|
206
|
+
const conditionalPathsArray = [];
|
|
207
|
+
const getConditionalPaths = (data, currentPath = '', localIndex = 0) => {
|
|
208
|
+
currentPath = currentPath.replace(/^\.+|\.+$/g, '');
|
|
209
|
+
const currentLocalIndex = localIndex;
|
|
210
|
+
const currentData = _.get(data, currentPath);
|
|
211
|
+
if (Array.isArray(currentData) && currentData.filter(Boolean).length > 0) {
|
|
212
|
+
if (currentData.some(element => typeof element !== 'object')) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const hasInnerDataArray = currentData.find(x => Array.isArray(x[conditionPaths[currentLocalIndex]]));
|
|
216
|
+
if (hasInnerDataArray) {
|
|
217
|
+
currentData.forEach((_, indexOutside) => {
|
|
218
|
+
const innerCompDataPath = `${currentPath}[${indexOutside}].${conditionPaths[currentLocalIndex]}`;
|
|
219
|
+
getConditionalPaths(data, innerCompDataPath, currentLocalIndex + 1);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
currentData.forEach((x, index) => {
|
|
224
|
+
if (!_.isNil(x[conditionPaths[currentLocalIndex]])) {
|
|
225
|
+
const compDataPath = `${currentPath}[${index}].${conditionPaths[currentLocalIndex]}`;
|
|
226
|
+
conditionalPathsArray.push(compDataPath);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
if (!conditionPaths[currentGlobalIndex]) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
currentGlobalIndex = currentGlobalIndex + 1;
|
|
236
|
+
getConditionalPaths(data, `${currentPath}.${conditionPaths[currentGlobalIndex - 1]}`, currentGlobalIndex);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
getConditionalPaths(data);
|
|
240
|
+
return conditionalPathsArray;
|
|
241
|
+
}
|
|
204
242
|
export function checkSimpleConditional(component, condition, row, data, instance) {
|
|
205
243
|
if (condition.when) {
|
|
206
244
|
const value = getComponentActualValue(condition.when, data, row);
|
|
@@ -226,19 +264,32 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
|
226
264
|
if (!conditionComponentPath) {
|
|
227
265
|
return true;
|
|
228
266
|
}
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
267
|
+
const splittedConditionPath = conditionComponentPath.split('.');
|
|
268
|
+
const conditionalPaths = instance?.parent?.type === 'datagrid' || instance?.parent?.type === 'editgrid' ? [] : getConditionalPathsRecursive(splittedConditionPath, data);
|
|
269
|
+
if (conditionalPaths.length > 0) {
|
|
270
|
+
return conditionalPaths.map((path) => {
|
|
271
|
+
const value = getComponentActualValue(path, data, row);
|
|
272
|
+
const ConditionOperator = ConditionOperators[operator];
|
|
273
|
+
return ConditionOperator
|
|
274
|
+
? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
|
275
|
+
: true;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
const value = getComponentActualValue(conditionComponentPath, data, row);
|
|
280
|
+
const СonditionOperator = ConditionOperators[operator];
|
|
281
|
+
return СonditionOperator
|
|
282
|
+
? new СonditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
|
283
|
+
: true;
|
|
284
|
+
}
|
|
234
285
|
});
|
|
235
286
|
let result = false;
|
|
236
287
|
switch (conjunction) {
|
|
237
288
|
case 'any':
|
|
238
|
-
result = _.some(conditionsResult, res => !!res);
|
|
289
|
+
result = _.some(conditionsResult.flat(), res => !!res);
|
|
239
290
|
break;
|
|
240
291
|
default:
|
|
241
|
-
result = _.every(conditionsResult, res => !!res);
|
|
292
|
+
result = _.every(conditionsResult.flat(), res => !!res);
|
|
242
293
|
}
|
|
243
294
|
return show ? result : !result;
|
|
244
295
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.5646.8734cf4",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@formio/bootstrap": "^3.0.0-rc.22",
|
|
79
79
|
"@formio/choices.js": "^10.2.1",
|
|
80
|
-
"@formio/core": "2.0.0-dev.
|
|
80
|
+
"@formio/core": "2.0.0-dev.105.e92d9a1",
|
|
81
81
|
"@formio/text-mask-addons": "^3.8.0-formio.2",
|
|
82
82
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
|
83
83
|
"abortcontroller-polyfill": "^1.7.5",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
let label: string;
|
|
3
|
-
let reorder: boolean;
|
|
4
|
-
let addAnotherPosition: string;
|
|
5
|
-
let layoutFixed: boolean;
|
|
6
|
-
let enableRowGroups: boolean;
|
|
7
|
-
let initEmpty: boolean;
|
|
8
|
-
let tableView: boolean;
|
|
9
|
-
let defaultValue: {}[];
|
|
10
|
-
let key: string;
|
|
11
|
-
let type: string;
|
|
12
|
-
let input: boolean;
|
|
13
|
-
let components: {
|
|
14
|
-
label: string;
|
|
15
|
-
optionsLabelPosition: string;
|
|
16
|
-
inline: boolean;
|
|
17
|
-
tableView: boolean;
|
|
18
|
-
values: {
|
|
19
|
-
label: string;
|
|
20
|
-
value: string;
|
|
21
|
-
shortcut: string;
|
|
22
|
-
}[];
|
|
23
|
-
key: string;
|
|
24
|
-
type: string;
|
|
25
|
-
input: boolean;
|
|
26
|
-
inputType: string;
|
|
27
|
-
}[];
|
|
28
|
-
}
|
|
29
|
-
export default _default;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = {
|
|
4
|
-
'label': 'Data Grid',
|
|
5
|
-
'reorder': false,
|
|
6
|
-
'addAnotherPosition': 'bottom',
|
|
7
|
-
'layoutFixed': false,
|
|
8
|
-
'enableRowGroups': false,
|
|
9
|
-
'initEmpty': false,
|
|
10
|
-
'tableView': false,
|
|
11
|
-
'defaultValue': [
|
|
12
|
-
{}
|
|
13
|
-
],
|
|
14
|
-
'key': 'dataGrid',
|
|
15
|
-
'type': 'datagrid',
|
|
16
|
-
'input': true,
|
|
17
|
-
'components': [
|
|
18
|
-
{
|
|
19
|
-
'label': 'Radio',
|
|
20
|
-
'optionsLabelPosition': 'right',
|
|
21
|
-
'inline': false,
|
|
22
|
-
'tableView': false,
|
|
23
|
-
'values': [
|
|
24
|
-
{
|
|
25
|
-
'label': 'yes',
|
|
26
|
-
'value': 'yes',
|
|
27
|
-
'shortcut': ''
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
'key': 'radio',
|
|
31
|
-
'type': 'radio',
|
|
32
|
-
'input': true,
|
|
33
|
-
'inputType': 'checkbox'
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
let label: string;
|
|
3
|
-
let reorder: boolean;
|
|
4
|
-
let addAnotherPosition: string;
|
|
5
|
-
let layoutFixed: boolean;
|
|
6
|
-
let enableRowGroups: boolean;
|
|
7
|
-
let initEmpty: boolean;
|
|
8
|
-
let tableView: boolean;
|
|
9
|
-
let defaultValue: {}[];
|
|
10
|
-
let key: string;
|
|
11
|
-
let type: string;
|
|
12
|
-
let input: boolean;
|
|
13
|
-
let components: {
|
|
14
|
-
label: string;
|
|
15
|
-
optionsLabelPosition: string;
|
|
16
|
-
inline: boolean;
|
|
17
|
-
tableView: boolean;
|
|
18
|
-
values: {
|
|
19
|
-
label: string;
|
|
20
|
-
value: string;
|
|
21
|
-
shortcut: string;
|
|
22
|
-
}[];
|
|
23
|
-
key: string;
|
|
24
|
-
type: string;
|
|
25
|
-
input: boolean;
|
|
26
|
-
inputType: string;
|
|
27
|
-
}[];
|
|
28
|
-
}
|
|
29
|
-
export default _default;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
'label': 'Data Grid',
|
|
3
|
-
'reorder': false,
|
|
4
|
-
'addAnotherPosition': 'bottom',
|
|
5
|
-
'layoutFixed': false,
|
|
6
|
-
'enableRowGroups': false,
|
|
7
|
-
'initEmpty': false,
|
|
8
|
-
'tableView': false,
|
|
9
|
-
'defaultValue': [
|
|
10
|
-
{}
|
|
11
|
-
],
|
|
12
|
-
'key': 'dataGrid',
|
|
13
|
-
'type': 'datagrid',
|
|
14
|
-
'input': true,
|
|
15
|
-
'components': [
|
|
16
|
-
{
|
|
17
|
-
'label': 'Radio',
|
|
18
|
-
'optionsLabelPosition': 'right',
|
|
19
|
-
'inline': false,
|
|
20
|
-
'tableView': false,
|
|
21
|
-
'values': [
|
|
22
|
-
{
|
|
23
|
-
'label': 'yes',
|
|
24
|
-
'value': 'yes',
|
|
25
|
-
'shortcut': ''
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
'key': 'radio',
|
|
29
|
-
'type': 'radio',
|
|
30
|
-
'input': true,
|
|
31
|
-
'inputType': 'checkbox'
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
};
|