@formio/js 5.0.0-dev.5643.9c5173a → 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 +7 -0
- package/dist/formio.form.js +25 -26
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +26 -27
- 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/WebformBuilder.js +8 -2
- package/lib/cjs/components/_classes/component/Component.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/form/Form.js +4 -4
- package/lib/cjs/components/radio/Radio.js +1 -2
- 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/WebformBuilder.js +8 -2
- package/lib/mjs/components/_classes/component/Component.js +1 -1
- 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/form/Form.js +2 -2
- package/lib/mjs/components/radio/Radio.js +1 -1
- 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
|
@@ -6,6 +6,7 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
+
import comp9 from './comp9';
|
|
9
10
|
import withDefValue from './comp-with-def-value';
|
|
10
11
|
import withRowGroupsAndDefValue from './comp-row-groups-with-def-value';
|
|
11
12
|
import modalWithRequiredFields from './comp-modal-with-required-fields';
|
|
@@ -14,5 +15,4 @@ import withLogic from './comp-with-logic';
|
|
|
14
15
|
import withCollapsibleRowGroups from './comp-with-collapsible-groups';
|
|
15
16
|
import withAllowCalculateOverride from './comp-with-allow-calculate-override';
|
|
16
17
|
import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
|
|
17
|
-
|
|
18
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
18
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride };
|
|
@@ -649,8 +649,7 @@ export default class FileComponent extends Field {
|
|
|
649
649
|
// Check if file with the same name is being uploaded
|
|
650
650
|
const fileWithSameNameUploading = this.filesToSync.filesToUpload
|
|
651
651
|
.some(fileToSync => fileToSync.file?.name === file.name);
|
|
652
|
-
const fileWithSameNameUploaded = this.dataValue
|
|
653
|
-
.some(fileStatus => fileStatus.originalName === file.name);
|
|
652
|
+
const fileWithSameNameUploaded = _.some(this.dataValue, fileStatus => fileStatus.originalName === file.name);
|
|
654
653
|
return fileWithSameNameUploaded || fileWithSameNameUploading
|
|
655
654
|
? {
|
|
656
655
|
status: 'error',
|
|
@@ -440,7 +440,7 @@ export default class FormComponent extends Component {
|
|
|
440
440
|
}
|
|
441
441
|
else if (this.formSrc) {
|
|
442
442
|
this.subFormLoading = true;
|
|
443
|
-
const options = this.root
|
|
443
|
+
const options = this.root?.formio?.base && this.root?.formio?.projectUrl
|
|
444
444
|
? {
|
|
445
445
|
base: this.root.formio.base,
|
|
446
446
|
project: this.root.formio.projectUrl,
|
|
@@ -624,7 +624,7 @@ export default class FormComponent extends Component {
|
|
|
624
624
|
if (shouldLoadSubmissionById || shouldLoadDraftById) {
|
|
625
625
|
const formId = submission.form || this.formObj.form || this.component.form;
|
|
626
626
|
const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
|
|
627
|
-
const options = this.root
|
|
627
|
+
const options = this.root?.formio?.base && this.root?.formio?.projectUrl
|
|
628
628
|
? {
|
|
629
629
|
base: this.root.formio.base,
|
|
630
630
|
project: this.root.formio.projectUrl,
|
|
@@ -322,7 +322,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
322
322
|
const value = this.dataValue;
|
|
323
323
|
this.refs.wrapper.forEach((wrapper, index) => {
|
|
324
324
|
const input = this.refs.input[index];
|
|
325
|
-
const checked = (input.type === 'checkbox') ? value[input.value]
|
|
325
|
+
const checked = (input.type === 'checkbox') ? value[input.value] : (input.value.toString() === value.toString());
|
|
326
326
|
if (checked) {
|
|
327
327
|
//add class to container when selected
|
|
328
328
|
this.addClass(wrapper, this.optionSelectedClass);
|
|
@@ -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) {
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -60,16 +60,6 @@ export function isMongoId(text: any): any[] | {
|
|
|
60
60
|
* The full submission data.
|
|
61
61
|
*/
|
|
62
62
|
export function checkCalculated(component: Object, submission: Object, rowData: any): void;
|
|
63
|
-
/**
|
|
64
|
-
* Check if a simple conditional evaluates to true.
|
|
65
|
-
*
|
|
66
|
-
* @param condition
|
|
67
|
-
* @param condition
|
|
68
|
-
* @param row
|
|
69
|
-
* @param data
|
|
70
|
-
* @param instance
|
|
71
|
-
* @returns {boolean}
|
|
72
|
-
*/
|
|
73
63
|
export function checkSimpleConditional(component: any, condition: any, row: any, data: any, instance: any): boolean;
|
|
74
64
|
export function getComponentActualValue(compPath: any, data: any, row: any): any;
|
|
75
65
|
/**
|
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
|
-
};
|