@formio/js 5.0.0-dev.5913.cf6760f → 5.0.0-dev.5914.479573c
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 +3 -0
- package/dist/formio.form.js +570 -580
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -3
- package/dist/formio.full.js +572 -582
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -3
- package/dist/formio.js +3006 -287
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +12 -0
- package/dist/formio.utils.js +40 -50
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -3
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +27 -28
- package/lib/cjs/WebformBuilder.js +9 -29
- package/lib/cjs/Wizard.d.ts +2 -1
- package/lib/cjs/Wizard.js +30 -29
- package/lib/cjs/components/Components.d.ts +0 -7
- package/lib/cjs/components/Components.js +1 -33
- package/lib/cjs/components/_classes/component/Component.d.ts +24 -7
- package/lib/cjs/components/_classes/component/Component.js +47 -13
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
- package/lib/cjs/components/_classes/nested/NestedComponent.js +39 -54
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +9 -46
- package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
- package/lib/cjs/components/datagrid/DataGrid.js +1 -45
- package/lib/cjs/components/datamap/DataMap.js +1 -2
- package/lib/cjs/components/editgrid/EditGrid.js +6 -6
- package/lib/cjs/components/form/Form.d.ts +1 -3
- package/lib/cjs/components/form/Form.js +15 -24
- package/lib/cjs/components/hidden/Hidden.d.ts +0 -1
- package/lib/cjs/components/hidden/Hidden.js +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
- package/lib/cjs/utils/formUtils.d.ts +25 -14
- package/lib/cjs/utils/formUtils.js +11 -16
- package/lib/cjs/utils/utils.d.ts +1 -2
- package/lib/cjs/utils/utils.js +15 -31
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +24 -27
- package/lib/mjs/WebformBuilder.js +9 -29
- package/lib/mjs/Wizard.d.ts +2 -1
- package/lib/mjs/Wizard.js +27 -25
- package/lib/mjs/components/Components.d.ts +0 -7
- package/lib/mjs/components/Components.js +1 -32
- package/lib/mjs/components/_classes/component/Component.d.ts +24 -7
- package/lib/mjs/components/_classes/component/Component.js +49 -14
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
- package/lib/mjs/components/_classes/nested/NestedComponent.js +40 -55
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
- package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
- package/lib/mjs/components/datagrid/DataGrid.js +1 -45
- package/lib/mjs/components/datamap/DataMap.js +1 -2
- package/lib/mjs/components/editgrid/EditGrid.js +9 -6
- package/lib/mjs/components/form/Form.d.ts +1 -3
- package/lib/mjs/components/form/Form.js +16 -24
- package/lib/mjs/components/hidden/Hidden.d.ts +0 -1
- package/lib/mjs/components/hidden/Hidden.js +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
- package/lib/mjs/utils/formUtils.d.ts +25 -14
- package/lib/mjs/utils/formUtils.js +2 -12
- package/lib/mjs/utils/utils.d.ts +1 -2
- package/lib/mjs/utils/utils.js +14 -29
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import {
|
|
3
|
+
import { Utils } from '@formio/core/utils';
|
|
4
|
+
const { getComponentPaths } = Utils;
|
|
5
|
+
import { componentValueTypes, isLayoutComponent } from '../../../utils/utils';
|
|
4
6
|
import Component from '../component/Component';
|
|
5
7
|
import NestedDataComponent from '../nesteddata/NestedDataComponent';
|
|
6
8
|
export default class NestedArrayComponent extends NestedDataComponent {
|
|
@@ -19,9 +21,13 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
19
21
|
throw new Error('Getter #iteratableRows() is not implemented');
|
|
20
22
|
}
|
|
21
23
|
get rowIndex() {
|
|
22
|
-
return
|
|
24
|
+
return this._rowIndex;
|
|
23
25
|
}
|
|
24
26
|
set rowIndex(value) {
|
|
27
|
+
this.paths = getComponentPaths(this.component, this.parent?.component, {
|
|
28
|
+
...(this.parent?.paths || {}),
|
|
29
|
+
...{ dataIndex: value }
|
|
30
|
+
});
|
|
25
31
|
this._rowIndex = value;
|
|
26
32
|
}
|
|
27
33
|
init() {
|
|
@@ -84,47 +90,6 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
84
90
|
value: this.dataValue,
|
|
85
91
|
}, 'show'));
|
|
86
92
|
}
|
|
87
|
-
getComponent(path, fn, originalPath) {
|
|
88
|
-
originalPath = originalPath || getStringFromComponentPath(path);
|
|
89
|
-
if (this.componentsMap.hasOwnProperty(originalPath)) {
|
|
90
|
-
if (fn) {
|
|
91
|
-
return fn(this.componentsMap[originalPath]);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
return this.componentsMap[originalPath];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
path = Array.isArray(path) ? path : [path];
|
|
98
|
-
let key = path.shift();
|
|
99
|
-
const remainingPath = path;
|
|
100
|
-
let result = [];
|
|
101
|
-
let possibleComp = null;
|
|
102
|
-
let comp = null;
|
|
103
|
-
let rowIndex = null;
|
|
104
|
-
if (_.isNumber(key)) {
|
|
105
|
-
rowIndex = key;
|
|
106
|
-
key = remainingPath.shift();
|
|
107
|
-
}
|
|
108
|
-
if (!_.isString(key)) {
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
this.everyComponent((component, components) => {
|
|
112
|
-
if (component.component.key === key) {
|
|
113
|
-
possibleComp = component;
|
|
114
|
-
if (remainingPath.length > 0 && 'getComponent' in component) {
|
|
115
|
-
comp = component.getComponent(remainingPath, fn, originalPath);
|
|
116
|
-
}
|
|
117
|
-
else if (fn) {
|
|
118
|
-
fn(component, components);
|
|
119
|
-
}
|
|
120
|
-
result = rowIndex !== null ? comp : result.concat(comp || possibleComp);
|
|
121
|
-
}
|
|
122
|
-
}, rowIndex);
|
|
123
|
-
if ((!result || result.length === 0) && possibleComp) {
|
|
124
|
-
result = rowIndex !== null ? possibleComp : [possibleComp];
|
|
125
|
-
}
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
93
|
everyComponent(fn, rowIndex, options = {}) {
|
|
129
94
|
if (_.isObject(rowIndex)) {
|
|
130
95
|
options = rowIndex;
|
|
@@ -87,7 +87,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
87
87
|
show: boolean;
|
|
88
88
|
};
|
|
89
89
|
checkComponentConditions(data: any, flags: any, row: any): boolean;
|
|
90
|
-
getComponent(path: any, fn: any): any;
|
|
91
90
|
toggleGroup(element: any, index: any): void;
|
|
92
91
|
}
|
|
93
92
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
|
3
3
|
import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
|
|
4
|
-
import Components from '../Components';
|
|
5
4
|
export default class DataGridComponent extends NestedArrayComponent {
|
|
6
5
|
static schema(...extend) {
|
|
7
6
|
return NestedArrayComponent.schema({
|
|
@@ -422,7 +421,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
422
421
|
}
|
|
423
422
|
component.rowIndex = rowIndex;
|
|
424
423
|
component.row = `${rowIndex}-${colIndex}`;
|
|
425
|
-
component.path = Components.getComponentPath(component);
|
|
426
424
|
});
|
|
427
425
|
}
|
|
428
426
|
updateRowsComponents(rowIndex) {
|
|
@@ -488,6 +486,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
488
486
|
const options = _.clone(this.options);
|
|
489
487
|
options.name += `[${rowIndex}]`;
|
|
490
488
|
options.row = `${rowIndex}-${colIndex}`;
|
|
489
|
+
options.rowIndex = rowIndex;
|
|
491
490
|
let columnComponent;
|
|
492
491
|
if (this.builderMode) {
|
|
493
492
|
col.id = col.id + rowIndex;
|
|
@@ -610,49 +609,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
610
609
|
restoreComponentsContext() {
|
|
611
610
|
this.rows.forEach((row, index) => _.forIn(row, (component) => component.data = this.dataValue[index]));
|
|
612
611
|
}
|
|
613
|
-
getComponent(path, fn) {
|
|
614
|
-
path = Array.isArray(path) ? path : [path];
|
|
615
|
-
const [key, ...remainingPath] = path;
|
|
616
|
-
let result = [];
|
|
617
|
-
if (_.isNumber(key) && remainingPath.length) {
|
|
618
|
-
const compKey = remainingPath.pop();
|
|
619
|
-
result = this.rows[key][compKey];
|
|
620
|
-
// If the component is inside a Layout Component, try to find it among all the row's components
|
|
621
|
-
if (!result) {
|
|
622
|
-
Object.entries(this.rows[key]).forEach(([, comp]) => {
|
|
623
|
-
if ('getComponent' in comp) {
|
|
624
|
-
const possibleResult = comp.getComponent([compKey], fn);
|
|
625
|
-
if (possibleResult) {
|
|
626
|
-
result = possibleResult;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
if (result && _.isFunction(fn)) {
|
|
632
|
-
fn(result, this.getComponents());
|
|
633
|
-
}
|
|
634
|
-
if (remainingPath.length && 'getComponent' in result) {
|
|
635
|
-
return result.getComponent(remainingPath, fn);
|
|
636
|
-
}
|
|
637
|
-
return result;
|
|
638
|
-
}
|
|
639
|
-
if (!_.isString(key)) {
|
|
640
|
-
return result;
|
|
641
|
-
}
|
|
642
|
-
this.everyComponent((component, components) => {
|
|
643
|
-
if (component.component.key === key) {
|
|
644
|
-
let comp = component;
|
|
645
|
-
if (remainingPath.length > 0 && 'getComponent' in component) {
|
|
646
|
-
comp = component.getComponent(remainingPath, fn);
|
|
647
|
-
}
|
|
648
|
-
else if (fn) {
|
|
649
|
-
fn(component, components);
|
|
650
|
-
}
|
|
651
|
-
result = result.concat(comp);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
return result.length > 0 ? result : null;
|
|
655
|
-
}
|
|
656
612
|
toggleGroup(element, index) {
|
|
657
613
|
element.classList.toggle('collapsed');
|
|
658
614
|
_.each(this.refs.chunks[index], row => {
|
|
@@ -3,7 +3,6 @@ import DataGridComponent from '../datagrid/DataGrid';
|
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
5
|
import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
|
|
6
|
-
import Components from '../Components';
|
|
7
6
|
export default class DataMapComponent extends DataGridComponent {
|
|
8
7
|
static schema(...extend) {
|
|
9
8
|
return Component.schema({
|
|
@@ -227,6 +226,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
227
226
|
options.events = new EventEmitter();
|
|
228
227
|
options.name += `[${rowIndex}]`;
|
|
229
228
|
options.row = `${rowIndex}`;
|
|
229
|
+
options.rowIndex = rowIndex;
|
|
230
230
|
const components = {};
|
|
231
231
|
components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
|
|
232
232
|
components['__key'].on('componentChange', (event) => {
|
|
@@ -236,7 +236,6 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
236
236
|
delete dataValue[key];
|
|
237
237
|
const comp = components[this.valueKey];
|
|
238
238
|
comp.component.key = newKey;
|
|
239
|
-
comp.path = Components.getComponentPath(comp);
|
|
240
239
|
key = newKey;
|
|
241
240
|
});
|
|
242
241
|
const valueComponent = _.clone(this.component.valueComponent);
|
|
@@ -923,6 +923,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
923
923
|
const options = _.clone(this.options);
|
|
924
924
|
options.name += `[${rowIndex}]`;
|
|
925
925
|
options.row = `${rowIndex}-${colIndex}`;
|
|
926
|
+
options.rowIndex = rowIndex;
|
|
926
927
|
options.onChange = (flags = {}, changed, modified) => {
|
|
927
928
|
if (changed.instance.root?.id && (this.root?.id !== changed.instance.root.id)) {
|
|
928
929
|
changed.instance.root.triggerChange(flags, changed, modified);
|
|
@@ -939,7 +940,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
939
940
|
...flags,
|
|
940
941
|
changed,
|
|
941
942
|
}, editRow.data, editRow.components);
|
|
942
|
-
this.validateRow(editRow, false);
|
|
943
|
+
this.validateRow(editRow, false, false);
|
|
943
944
|
}
|
|
944
945
|
if (this.variableTypeComponentsIndexes.length) {
|
|
945
946
|
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
|
@@ -979,22 +980,24 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
979
980
|
validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
|
|
980
981
|
editRow.errors = [];
|
|
981
982
|
if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
|
|
982
|
-
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
|
983
|
+
const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
|
|
983
984
|
const rootValue = fastCloneDeep(this.rootValue);
|
|
984
985
|
const editGridValue = _.get(rootValue, this.path, []);
|
|
985
986
|
editGridValue[editRow.rowIndex] = editRow.data;
|
|
986
987
|
_.set(rootValue, this.path, editGridValue);
|
|
987
988
|
const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
|
|
988
989
|
const errors = processSync({
|
|
989
|
-
components:
|
|
990
|
-
component.parentPath = `${this.path}[${editRow.rowIndex}]`;
|
|
991
|
-
return component;
|
|
992
|
-
}),
|
|
990
|
+
components: this.component.components,
|
|
993
991
|
data: rootValue,
|
|
994
992
|
row: editRow.data,
|
|
995
993
|
process: 'validateRow',
|
|
996
994
|
instances: this.componentsMap,
|
|
997
995
|
scope: { errors: [] },
|
|
996
|
+
parent: this.component,
|
|
997
|
+
parentPaths: {
|
|
998
|
+
...this.paths,
|
|
999
|
+
dataIndex: editRow.rowIndex
|
|
1000
|
+
},
|
|
998
1001
|
processors: [
|
|
999
1002
|
{
|
|
1000
1003
|
process: validationProcessorProcess,
|
|
@@ -21,7 +21,7 @@ export default class FormComponent extends Component {
|
|
|
21
21
|
get useOriginalRevision(): any;
|
|
22
22
|
setFormRevision(rev: any): void;
|
|
23
23
|
subFormRevision: any;
|
|
24
|
-
getComponent(path: any
|
|
24
|
+
getComponent(path: any): any;
|
|
25
25
|
getSubOptions(options?: {}): {};
|
|
26
26
|
render(): string;
|
|
27
27
|
asString(value: any): any;
|
|
@@ -55,8 +55,6 @@ export default class FormComponent extends Component {
|
|
|
55
55
|
*/
|
|
56
56
|
loadSubForm(fromAttach: boolean): Promise<any>;
|
|
57
57
|
subFormLoading: boolean | undefined;
|
|
58
|
-
get subFormData(): any;
|
|
59
|
-
checkComponentValidity(data: any, dirty: any, row: any, options: any, errors?: any[]): any;
|
|
60
58
|
checkComponentConditions(data: any, flags: any, row: any): any;
|
|
61
59
|
calculateValue(data: any, flags: any, row: any): any;
|
|
62
60
|
setPristine(pristine: any): void;
|
|
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
|
|
3
3
|
import Component from '../_classes/component/Component';
|
|
4
4
|
import ComponentModal from '../_classes/componentModal/ComponentModal';
|
|
5
5
|
import EventEmitter from 'eventemitter3';
|
|
6
|
-
import { isMongoId, eachComponent,
|
|
6
|
+
import { isMongoId, eachComponent, componentValueTypes } from '../../utils/utils';
|
|
7
7
|
import { Formio } from '../../Formio';
|
|
8
8
|
import Form from '../../Form';
|
|
9
9
|
export default class FormComponent extends Component {
|
|
@@ -127,15 +127,11 @@ export default class FormComponent extends Component {
|
|
|
127
127
|
this.subFormRevision = undefined;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
getComponent(path
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
path.shift();
|
|
134
|
-
}
|
|
135
|
-
const originalPathStr = `${this.path}.data.${getStringFromComponentPath(path)}`;
|
|
136
|
-
if (this.subForm) {
|
|
137
|
-
return this.subForm.getComponent(path, fn, originalPathStr);
|
|
130
|
+
getComponent(path) {
|
|
131
|
+
if (!this.subForm) {
|
|
132
|
+
return null;
|
|
138
133
|
}
|
|
134
|
+
return this.subForm.getComponent(path);
|
|
139
135
|
}
|
|
140
136
|
/* eslint-disable max-statements */
|
|
141
137
|
getSubOptions(options = {}) {
|
|
@@ -203,6 +199,7 @@ export default class FormComponent extends Component {
|
|
|
203
199
|
if (this.options.skipDraftRestore) {
|
|
204
200
|
options.skipDraftRestore = this.options.skipDraftRestore;
|
|
205
201
|
}
|
|
202
|
+
options.parent = this;
|
|
206
203
|
return options;
|
|
207
204
|
}
|
|
208
205
|
/* eslint-enable max-statements */
|
|
@@ -294,6 +291,7 @@ export default class FormComponent extends Component {
|
|
|
294
291
|
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
|
295
292
|
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
|
296
293
|
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
|
294
|
+
this.subForm.element = this.componentModal.refs.modalContents;
|
|
297
295
|
this.setOpenModalElement();
|
|
298
296
|
}
|
|
299
297
|
this.calculateValue();
|
|
@@ -391,6 +389,9 @@ export default class FormComponent extends Component {
|
|
|
391
389
|
return (new Form(form, this.getSubOptions())).ready.then((instance) => {
|
|
392
390
|
this.subForm = instance;
|
|
393
391
|
this.subForm.currentForm = this;
|
|
392
|
+
const componentsMap = this.componentsMap;
|
|
393
|
+
const formComponentsMap = this.subForm.componentsMap;
|
|
394
|
+
_.assign(componentsMap, formComponentsMap);
|
|
394
395
|
this.subForm.parent = this;
|
|
395
396
|
this.subForm.parentVisible = this.visible;
|
|
396
397
|
this.subForm.on('change', () => {
|
|
@@ -409,6 +410,8 @@ export default class FormComponent extends Component {
|
|
|
409
410
|
this.valueChanged = this.hasSetValue;
|
|
410
411
|
this.onChange();
|
|
411
412
|
return this.subForm;
|
|
413
|
+
}).catch((err) => {
|
|
414
|
+
console.log(err);
|
|
412
415
|
});
|
|
413
416
|
}).then((subForm) => {
|
|
414
417
|
this.updateSubWizards(subForm);
|
|
@@ -464,17 +467,6 @@ export default class FormComponent extends Component {
|
|
|
464
467
|
}
|
|
465
468
|
return Promise.resolve();
|
|
466
469
|
}
|
|
467
|
-
get subFormData() {
|
|
468
|
-
return this.dataValue?.data || {};
|
|
469
|
-
}
|
|
470
|
-
checkComponentValidity(data, dirty, row, options, errors = []) {
|
|
471
|
-
options = options || {};
|
|
472
|
-
const silentCheck = options.silentCheck || false;
|
|
473
|
-
if (this.subForm && !this.isNestedWizard) {
|
|
474
|
-
return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
|
|
475
|
-
}
|
|
476
|
-
return super.checkComponentValidity(data, dirty, row, options, errors);
|
|
477
|
-
}
|
|
478
470
|
checkComponentConditions(data, flags, row) {
|
|
479
471
|
const visible = super.checkComponentConditions(data, flags, row);
|
|
480
472
|
// Return if already hidden
|
|
@@ -482,14 +474,14 @@ export default class FormComponent extends Component {
|
|
|
482
474
|
return visible;
|
|
483
475
|
}
|
|
484
476
|
if (this.subForm) {
|
|
485
|
-
return this.subForm.checkConditions(
|
|
477
|
+
return this.subForm.checkConditions(data, flags, row);
|
|
486
478
|
}
|
|
487
479
|
// There are few cases when subForm is not loaded when a change is triggered,
|
|
488
480
|
// so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
|
|
489
481
|
else if (this.subFormReady) {
|
|
490
482
|
this.subFormReady.then(() => {
|
|
491
483
|
if (this.subForm) {
|
|
492
|
-
return this.subForm.checkConditions(
|
|
484
|
+
return this.subForm.checkConditions(data, flags, row);
|
|
493
485
|
}
|
|
494
486
|
});
|
|
495
487
|
}
|
|
@@ -497,7 +489,7 @@ export default class FormComponent extends Component {
|
|
|
497
489
|
}
|
|
498
490
|
calculateValue(data, flags, row) {
|
|
499
491
|
if (this.subForm) {
|
|
500
|
-
return this.subForm.calculateValue(
|
|
492
|
+
return this.subForm.calculateValue(data, flags, row);
|
|
501
493
|
}
|
|
502
494
|
return super.calculateValue(data, flags, row);
|
|
503
495
|
}
|
|
@@ -539,7 +531,7 @@ export default class FormComponent extends Component {
|
|
|
539
531
|
}
|
|
540
532
|
this.subForm.nosubmit = false;
|
|
541
533
|
this.subForm.submitted = true;
|
|
542
|
-
return this.subForm.submitForm().then(result => {
|
|
534
|
+
return this.subForm.submitForm({}, true).then(result => {
|
|
543
535
|
this.subForm.loading = false;
|
|
544
536
|
this.subForm.showAllErrors = false;
|
|
545
537
|
this.dataValue = result.submission;
|
|
@@ -1099,6 +1099,7 @@ declare const _default: ({
|
|
|
1099
1099
|
alwaysEnabled?: undefined;
|
|
1100
1100
|
} | {
|
|
1101
1101
|
key: string;
|
|
1102
|
+
type: string;
|
|
1102
1103
|
conditional: {
|
|
1103
1104
|
json: {
|
|
1104
1105
|
and: ({
|
|
@@ -1149,7 +1150,6 @@ declare const _default: ({
|
|
|
1149
1150
|
};
|
|
1150
1151
|
};
|
|
1151
1152
|
data?: undefined;
|
|
1152
|
-
type?: undefined;
|
|
1153
1153
|
weight?: undefined;
|
|
1154
1154
|
input?: undefined;
|
|
1155
1155
|
label?: undefined;
|
|
@@ -14,13 +14,13 @@ export default class DateGeaterThan extends ConditionOperator {
|
|
|
14
14
|
return { date, comparedDate };
|
|
15
15
|
}
|
|
16
16
|
execute(options, functionName = 'isAfter') {
|
|
17
|
-
const { value, instance,
|
|
17
|
+
const { value, instance, path } = options;
|
|
18
18
|
if (!value) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
let conditionTriggerComponent = null;
|
|
22
22
|
if (instance?.root?.getComponent) {
|
|
23
|
-
conditionTriggerComponent = instance.root.getComponent(
|
|
23
|
+
conditionTriggerComponent = instance.root.getComponent(path);
|
|
24
24
|
}
|
|
25
25
|
if (conditionTriggerComponent && conditionTriggerComponent.isPartialDay && conditionTriggerComponent.isPartialDay(value)) {
|
|
26
26
|
return false;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default class IsEmptyValue extends ConditionOperator {
|
|
2
|
-
execute({ value, instance,
|
|
2
|
+
execute({ value, instance, path }: {
|
|
3
3
|
value: any;
|
|
4
4
|
instance: any;
|
|
5
|
-
|
|
5
|
+
path: any;
|
|
6
6
|
}): any;
|
|
7
7
|
getResult(options: any): any;
|
|
8
8
|
}
|
|
@@ -10,10 +10,10 @@ export default class IsEmptyValue extends ConditionOperator {
|
|
|
10
10
|
static get requireValue() {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
|
-
execute({ value, instance,
|
|
13
|
+
execute({ value, instance, path }) {
|
|
14
14
|
const isEmptyValue = _.isEmpty(_.isNumber(value) ? String(value) : value);
|
|
15
15
|
if (instance?.root?.getComponent) {
|
|
16
|
-
const conditionTriggerComponent = instance.root.getComponent(
|
|
16
|
+
const conditionTriggerComponent = instance.root.getComponent(path);
|
|
17
17
|
return conditionTriggerComponent?.isEmpty ? conditionTriggerComponent.isEmpty() : isEmptyValue;
|
|
18
18
|
}
|
|
19
19
|
return isEmptyValue;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default class IsEqualTo extends ConditionOperator {
|
|
2
|
-
execute({ value, comparedValue, instance,
|
|
2
|
+
execute({ value, comparedValue, instance, path }: {
|
|
3
3
|
value: any;
|
|
4
4
|
comparedValue: any;
|
|
5
5
|
instance: any;
|
|
6
|
-
|
|
6
|
+
path: any;
|
|
7
7
|
}): any;
|
|
8
8
|
}
|
|
9
9
|
import ConditionOperator from './ConditionOperator';
|
|
@@ -8,7 +8,7 @@ export default class IsEqualTo extends ConditionOperator {
|
|
|
8
8
|
static get displayedName() {
|
|
9
9
|
return 'Is Equal To';
|
|
10
10
|
}
|
|
11
|
-
execute({ value, comparedValue, instance,
|
|
11
|
+
execute({ value, comparedValue, instance, path }) {
|
|
12
12
|
if ((value || value === false) && comparedValue && typeof value !== typeof comparedValue && _.isString(comparedValue)) {
|
|
13
13
|
try {
|
|
14
14
|
comparedValue = JSON.parse(comparedValue);
|
|
@@ -17,7 +17,7 @@ export default class IsEqualTo extends ConditionOperator {
|
|
|
17
17
|
catch (e) { }
|
|
18
18
|
}
|
|
19
19
|
if (instance?.root?.getComponent) {
|
|
20
|
-
const conditionTriggerComponent = instance.root.getComponent(
|
|
20
|
+
const conditionTriggerComponent = instance.root.getComponent(path);
|
|
21
21
|
if (conditionTriggerComponent
|
|
22
22
|
&& isSelectResourceWithObjectValue(conditionTriggerComponent.component)
|
|
23
23
|
&& conditionTriggerComponent.component?.template) {
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deprecated version of findComponents. Renamed to searchComponents.
|
|
3
|
-
* @param {import('@formio/core').Component[]} components - The components to find components within.
|
|
4
|
-
* @param {object} query - The query to use when searching for the components.
|
|
5
|
-
* @returns {import('@formio/core').Component[]} - The result of the component that is found.
|
|
6
|
-
*/
|
|
7
|
-
export function findComponents(components: import('@formio/core').Component[], query: object): import('@formio/core').Component[];
|
|
8
1
|
export const flattenComponents: typeof Utils.flattenComponents;
|
|
9
2
|
export const guid: typeof Utils.guid;
|
|
10
3
|
export const uniqueName: typeof Utils.uniqueName;
|
|
11
|
-
export const
|
|
4
|
+
export const MODEL_TYPES_OF_KNOWN_COMPONENTS: {
|
|
5
|
+
nestedArray: string[];
|
|
6
|
+
nestedDataArray: string[];
|
|
7
|
+
dataObject: string[];
|
|
8
|
+
object: string[];
|
|
9
|
+
map: string[];
|
|
10
|
+
content: string[];
|
|
11
|
+
string: string[];
|
|
12
|
+
number: string[];
|
|
13
|
+
boolean: string[];
|
|
14
|
+
none: string[];
|
|
15
|
+
any: string[];
|
|
16
|
+
};
|
|
12
17
|
export const getModelType: typeof Utils.getModelType;
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
18
|
+
export const getComponentPath: any;
|
|
19
|
+
export const setComponentScope: typeof Utils.setComponentScope;
|
|
20
|
+
export const resetComponentScope: typeof Utils.resetComponentScope;
|
|
15
21
|
export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
|
|
16
22
|
export const componentPath: typeof Utils.componentPath;
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
23
|
+
export const getComponentPaths: typeof Utils.getComponentPaths;
|
|
24
|
+
export const componentMatches: typeof Utils.componentMatches;
|
|
25
|
+
export const getBestMatch: typeof Utils.getBestMatch;
|
|
26
|
+
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
|
27
|
+
export const getComponentValue: typeof Utils.getComponentValue;
|
|
28
|
+
export const findComponents: typeof Utils.findComponents;
|
|
29
|
+
export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => Promise<void>;
|
|
30
|
+
export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => void;
|
|
20
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
|
21
32
|
export const getContextualRowPath: typeof Utils.getContextualRowPath;
|
|
22
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
|
@@ -24,7 +35,7 @@ export const componentInfo: typeof Utils.componentInfo;
|
|
|
24
35
|
export const eachComponent: typeof Utils.eachComponent;
|
|
25
36
|
export const eachComponentAsync: typeof Utils.eachComponentAsync;
|
|
26
37
|
export const getComponentData: typeof Utils.getComponentData;
|
|
27
|
-
export const getComponentActualValue:
|
|
38
|
+
export const getComponentActualValue: any;
|
|
28
39
|
export const isLayoutComponent: typeof Utils.isLayoutComponent;
|
|
29
40
|
export const matchComponent: typeof Utils.matchComponent;
|
|
30
41
|
export const getComponent: typeof Utils.getComponent;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import { Utils } from '@formio/core';
|
|
2
|
-
const { flattenComponents, guid, uniqueName,
|
|
3
|
-
|
|
4
|
-
* Deprecated version of findComponents. Renamed to searchComponents.
|
|
5
|
-
* @param {import('@formio/core').Component[]} components - The components to find components within.
|
|
6
|
-
* @param {object} query - The query to use when searching for the components.
|
|
7
|
-
* @returns {import('@formio/core').Component[]} - The result of the component that is found.
|
|
8
|
-
*/
|
|
9
|
-
export function findComponents(components, query) {
|
|
10
|
-
console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');
|
|
11
|
-
return searchComponents(components, query);
|
|
12
|
-
}
|
|
13
|
-
export { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys };
|
|
2
|
+
const { flattenComponents, guid, uniqueName, MODEL_TYPES_OF_KNOWN_COMPONENTS, getModelType, getComponentPath, setComponentScope, resetComponentScope, isComponentNestedDataType, componentPath, getComponentPaths, componentMatches, getBestMatch, getComponentFromPath, getComponentValue, findComponents, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys } = Utils;
|
|
3
|
+
export { flattenComponents, guid, uniqueName, MODEL_TYPES_OF_KNOWN_COMPONENTS, getModelType, getComponentPath, setComponentScope, resetComponentScope, isComponentNestedDataType, componentPath, getComponentPaths, componentMatches, getBestMatch, getComponentFromPath, getComponentValue, findComponents, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys };
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -462,10 +462,9 @@ export function getComponentPathWithoutIndicies(path?: string): string;
|
|
|
462
462
|
/**
|
|
463
463
|
* Returns a path to the component which based on its schema
|
|
464
464
|
* @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
|
|
465
|
-
* @param {string} path - Path to the component
|
|
466
465
|
* @returns {string} - Path to the component
|
|
467
466
|
*/
|
|
468
|
-
export function getComponentPath(component: import('@formio/core').Component
|
|
467
|
+
export function getComponentPath(component: import('@formio/core').Component): string;
|
|
469
468
|
/**
|
|
470
469
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
471
470
|
* @param {Component} componentInstance - The component to check for the parent.
|