@formio/js 5.0.0-dev.5913.d415fcc → 5.0.0-dev.5914.e8a58b3
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/dist/formio.form.js +579 -589
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -3
- package/dist/formio.full.js +580 -590
- 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 +41 -51
- 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 +14 -18
- package/lib/cjs/Wizard.d.ts +2 -2
- package/lib/cjs/Wizard.js +34 -42
- 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/componentModal/ComponentModal.d.ts +1 -0
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
- 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 +16 -24
- 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 +14 -18
- package/lib/mjs/Wizard.d.ts +2 -2
- package/lib/mjs/Wizard.js +30 -37
- 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/componentModal/ComponentModal.d.ts +1 -0
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
- 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 +17 -24
- 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 +4 -4
|
@@ -243,6 +243,7 @@ class Component extends Element_1.default {
|
|
|
243
243
|
*/
|
|
244
244
|
/* eslint-disable max-statements */
|
|
245
245
|
constructor(component, options, data) {
|
|
246
|
+
var _a, _b, _c, _d;
|
|
246
247
|
super(Object.assign({
|
|
247
248
|
renderMode: 'form',
|
|
248
249
|
attachMode: 'full',
|
|
@@ -258,6 +259,10 @@ class Component extends Element_1.default {
|
|
|
258
259
|
* @private
|
|
259
260
|
*/
|
|
260
261
|
this._hasCondition = null;
|
|
262
|
+
/**
|
|
263
|
+
* The row index for this component.
|
|
264
|
+
*/
|
|
265
|
+
this._rowIndex = undefined;
|
|
261
266
|
/**
|
|
262
267
|
* References to dom elements
|
|
263
268
|
*/
|
|
@@ -268,11 +273,6 @@ class Component extends Element_1.default {
|
|
|
268
273
|
this.options.components[component.type]) {
|
|
269
274
|
lodash_1.default.merge(component, this.options.components[component.type]);
|
|
270
275
|
}
|
|
271
|
-
/**
|
|
272
|
-
* The data path to this specific component instance.
|
|
273
|
-
* @type {string}
|
|
274
|
-
*/
|
|
275
|
-
this.path = (component === null || component === void 0 ? void 0 : component.key) || '';
|
|
276
276
|
/**
|
|
277
277
|
* An array of all the children components errors.
|
|
278
278
|
*/
|
|
@@ -341,6 +341,11 @@ class Component extends Element_1.default {
|
|
|
341
341
|
* @type {Component}
|
|
342
342
|
*/
|
|
343
343
|
this.parent = this.options.parent;
|
|
344
|
+
/**
|
|
345
|
+
* The component paths for this component.
|
|
346
|
+
* @type {import('@formio/core').ComponentPaths} - The component paths.
|
|
347
|
+
*/
|
|
348
|
+
this.paths = FormioUtils.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths), { dataIndex: this.options.rowIndex === undefined ? (_d = (_c = this.parent) === null || _c === void 0 ? void 0 : _c.paths) === null || _d === void 0 ? void 0 : _d.dataIndex : this.options.rowIndex }));
|
|
344
349
|
this.options.name = this.options.name || 'data';
|
|
345
350
|
this._path = '';
|
|
346
351
|
// Needs for Nextgen Rules Engine
|
|
@@ -447,12 +452,7 @@ class Component extends Element_1.default {
|
|
|
447
452
|
/* eslint-enable max-statements */
|
|
448
453
|
get componentsMap() {
|
|
449
454
|
var _a;
|
|
450
|
-
|
|
451
|
-
return this.localRoot.childComponentsMap;
|
|
452
|
-
}
|
|
453
|
-
const localMap = {};
|
|
454
|
-
localMap[this.path] = this;
|
|
455
|
-
return localMap;
|
|
455
|
+
return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
|
|
456
456
|
}
|
|
457
457
|
get data() {
|
|
458
458
|
return this._data;
|
|
@@ -499,6 +499,23 @@ class Component extends Element_1.default {
|
|
|
499
499
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Get Row Index.
|
|
504
|
+
* @returns {number} - The row index.
|
|
505
|
+
*/
|
|
506
|
+
get rowIndex() {
|
|
507
|
+
return this._rowIndex;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Set Row Index to row and update each component.
|
|
511
|
+
* @param {number} value - The row index.
|
|
512
|
+
* @returns {void}
|
|
513
|
+
*/
|
|
514
|
+
set rowIndex(value) {
|
|
515
|
+
var _a, _b;
|
|
516
|
+
this.paths = FormioUtils.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
|
|
517
|
+
this._rowIndex = value;
|
|
518
|
+
}
|
|
502
519
|
afterComponentAssign() {
|
|
503
520
|
//implement in extended classes
|
|
504
521
|
}
|
|
@@ -568,6 +585,12 @@ class Component extends Element_1.default {
|
|
|
568
585
|
get key() {
|
|
569
586
|
return lodash_1.default.get(this.component, 'key', '');
|
|
570
587
|
}
|
|
588
|
+
get path() {
|
|
589
|
+
return this.paths.dataPath;
|
|
590
|
+
}
|
|
591
|
+
set path(path) {
|
|
592
|
+
throw new Error('Should not be setting the path of a component.');
|
|
593
|
+
}
|
|
571
594
|
set parentVisible(value) {
|
|
572
595
|
this._parentVisible = value;
|
|
573
596
|
}
|
|
@@ -1274,6 +1297,7 @@ class Component extends Element_1.default {
|
|
|
1274
1297
|
* @returns {void}
|
|
1275
1298
|
*/
|
|
1276
1299
|
checkRefresh(refreshData, changed, flags) {
|
|
1300
|
+
var _a, _b;
|
|
1277
1301
|
const changePath = lodash_1.default.get(changed, 'instance.path', false);
|
|
1278
1302
|
// Don't let components change themselves.
|
|
1279
1303
|
if (changePath && this.path === changePath) {
|
|
@@ -1282,7 +1306,7 @@ class Component extends Element_1.default {
|
|
|
1282
1306
|
if (refreshData === 'data') {
|
|
1283
1307
|
this.refresh(this.data, changed, flags);
|
|
1284
1308
|
}
|
|
1285
|
-
else if ((changePath && (
|
|
1309
|
+
else if ((changePath && (((_b = (_a = changed.instance) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.localPath) === refreshData)) && changed && changed.instance &&
|
|
1286
1310
|
// Make sure the changed component is not in a different "context". Solves issues where refreshOn being set
|
|
1287
1311
|
// in fields inside EditGrids could alter their state from other rows (which is bad).
|
|
1288
1312
|
this.inContext(changed.instance)) {
|
|
@@ -2892,6 +2916,10 @@ class Component extends Element_1.default {
|
|
|
2892
2916
|
* @returns {string} - The message to show when the component is invalid.
|
|
2893
2917
|
*/
|
|
2894
2918
|
invalidMessage(data, dirty, ignoreCondition, row) {
|
|
2919
|
+
var _a;
|
|
2920
|
+
if (!row) {
|
|
2921
|
+
row = (0, utils_1.getContextualRowData)(this.component, data, this.paths);
|
|
2922
|
+
}
|
|
2895
2923
|
if (!ignoreCondition && !this.checkCondition(row, data)) {
|
|
2896
2924
|
return '';
|
|
2897
2925
|
}
|
|
@@ -2909,6 +2937,8 @@ class Component extends Element_1.default {
|
|
|
2909
2937
|
data,
|
|
2910
2938
|
row,
|
|
2911
2939
|
path: this.path || this.component.key,
|
|
2940
|
+
parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
|
|
2941
|
+
paths: this.paths,
|
|
2912
2942
|
scope: validationScope,
|
|
2913
2943
|
instance: this,
|
|
2914
2944
|
processors: [
|
|
@@ -2962,7 +2992,7 @@ class Component extends Element_1.default {
|
|
|
2962
2992
|
if (flags.silentCheck) {
|
|
2963
2993
|
return [];
|
|
2964
2994
|
}
|
|
2965
|
-
let isDirty = this.dirty || flags.dirty;
|
|
2995
|
+
let isDirty = (flags.dirty === false) ? false : (this.dirty || flags.dirty);
|
|
2966
2996
|
if (this.options.alwaysDirty) {
|
|
2967
2997
|
isDirty = true;
|
|
2968
2998
|
}
|
|
@@ -2977,6 +3007,7 @@ class Component extends Element_1.default {
|
|
|
2977
3007
|
* @returns {Array<any>} - An array of errors if the component is invalid.
|
|
2978
3008
|
*/
|
|
2979
3009
|
validateComponent(data = null, row = null, flags = {}) {
|
|
3010
|
+
var _a;
|
|
2980
3011
|
data = data || this.rootValue;
|
|
2981
3012
|
row = row || this.data;
|
|
2982
3013
|
const { async = false } = flags;
|
|
@@ -2987,7 +3018,10 @@ class Component extends Element_1.default {
|
|
|
2987
3018
|
component: this.component,
|
|
2988
3019
|
data,
|
|
2989
3020
|
row,
|
|
3021
|
+
local: !!flags.local,
|
|
2990
3022
|
value: this.validationValue,
|
|
3023
|
+
parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
|
|
3024
|
+
paths: this.paths,
|
|
2991
3025
|
path: this.path || this.component.key,
|
|
2992
3026
|
instance: this,
|
|
2993
3027
|
form: this.root ? this.root._form : {},
|
|
@@ -56,18 +56,6 @@ export default class NestedComponent extends Field {
|
|
|
56
56
|
* @returns {object} - The current form object.
|
|
57
57
|
*/
|
|
58
58
|
get currentForm(): object;
|
|
59
|
-
/**
|
|
60
|
-
* Set Row Index to row and update each component.
|
|
61
|
-
* @param {number} value - The row index.
|
|
62
|
-
* @returns {void}
|
|
63
|
-
*/
|
|
64
|
-
set rowIndex(value: number);
|
|
65
|
-
/**
|
|
66
|
-
* Get Row Index.
|
|
67
|
-
* @returns {number} - The row index.
|
|
68
|
-
*/
|
|
69
|
-
get rowIndex(): number;
|
|
70
|
-
_rowIndex: number | undefined;
|
|
71
59
|
/**
|
|
72
60
|
* Get Contextual data of the component.
|
|
73
61
|
* @returns {object} - The contextual data of the component.
|
|
@@ -115,14 +103,11 @@ export default class NestedComponent extends Field {
|
|
|
115
103
|
*/
|
|
116
104
|
eachComponent(fn: Function): void;
|
|
117
105
|
/**
|
|
118
|
-
* Returns a component provided a key. This performs a deep search within the
|
|
119
|
-
* component tree.
|
|
106
|
+
* Returns a component provided a key. This performs a deep search within the component tree.
|
|
120
107
|
* @param {string} path - The path to the component.
|
|
121
|
-
* @param {Function} [fn] - Called with the component once found.
|
|
122
|
-
* @param {string} [originalPath] - The original path to the component.
|
|
123
108
|
* @returns {any} - The component that is located.
|
|
124
109
|
*/
|
|
125
|
-
getComponent(path: string
|
|
110
|
+
getComponent(path: string): any;
|
|
126
111
|
/**
|
|
127
112
|
* Return a component provided the Id of the component.
|
|
128
113
|
* @param {string} id - The Id of the component.
|
|
@@ -211,12 +196,12 @@ export default class NestedComponent extends Field {
|
|
|
211
196
|
calculateValue(data: any, flags: any, row: any): any;
|
|
212
197
|
isLastPage(): boolean;
|
|
213
198
|
isValid(data: any, dirty: any): any;
|
|
214
|
-
validationProcessor({ scope, data, row, instance,
|
|
199
|
+
validationProcessor({ scope, data, row, instance, paths }: {
|
|
215
200
|
scope: any;
|
|
216
201
|
data: any;
|
|
217
202
|
row: any;
|
|
218
203
|
instance: any;
|
|
219
|
-
|
|
204
|
+
paths: any;
|
|
220
205
|
}, flags: any): void;
|
|
221
206
|
/**
|
|
222
207
|
* Perform a validation on all child components of this nested component.
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const Field_1 = __importDefault(require("../field/Field"));
|
|
8
8
|
const Components_1 = __importDefault(require("../../Components"));
|
|
9
|
+
'';
|
|
9
10
|
const utils_1 = require("../../../utils/utils");
|
|
10
11
|
const process_1 = require("@formio/core/process");
|
|
11
12
|
/**
|
|
@@ -201,7 +202,9 @@ class NestedComponent extends Field_1.default {
|
|
|
201
202
|
* @returns {void}
|
|
202
203
|
*/
|
|
203
204
|
set rowIndex(value) {
|
|
205
|
+
var _a, _b;
|
|
204
206
|
this._rowIndex = value;
|
|
207
|
+
this.paths = (0, utils_1.getComponentPaths)(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
|
|
205
208
|
this.eachComponent((component) => {
|
|
206
209
|
component.rowIndex = value;
|
|
207
210
|
});
|
|
@@ -297,56 +300,38 @@ class NestedComponent extends Field_1.default {
|
|
|
297
300
|
});
|
|
298
301
|
}
|
|
299
302
|
/**
|
|
300
|
-
* Returns a component provided a key. This performs a deep search within the
|
|
301
|
-
* component tree.
|
|
303
|
+
* Returns a component provided a key. This performs a deep search within the component tree.
|
|
302
304
|
* @param {string} path - The path to the component.
|
|
303
|
-
* @param {Function} [fn] - Called with the component once found.
|
|
304
|
-
* @param {string} [originalPath] - The original path to the component.
|
|
305
305
|
* @returns {any} - The component that is located.
|
|
306
306
|
*/
|
|
307
|
-
getComponent(path
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
possibleComp = component;
|
|
334
|
-
if (matchPath) {
|
|
335
|
-
comp = component;
|
|
336
|
-
if (remainingPath.length > 0 && 'getComponent' in component) {
|
|
337
|
-
comp = component.getComponent(remainingPath, fn, originalPath);
|
|
338
|
-
}
|
|
339
|
-
else if (fn) {
|
|
340
|
-
fn(component, components);
|
|
341
|
-
}
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
307
|
+
getComponent(path) {
|
|
308
|
+
var _a;
|
|
309
|
+
path = (0, utils_1.getStringFromComponentPath)(path);
|
|
310
|
+
const matches = {
|
|
311
|
+
path: undefined,
|
|
312
|
+
fullPath: undefined,
|
|
313
|
+
localPath: undefined,
|
|
314
|
+
fullLocalPath: undefined,
|
|
315
|
+
dataPath: undefined,
|
|
316
|
+
localDataPath: undefined,
|
|
317
|
+
key: undefined,
|
|
318
|
+
};
|
|
319
|
+
this.everyComponent((component) => {
|
|
320
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
321
|
+
// All searches are relative to this component so replace this path from the child paths.
|
|
322
|
+
(0, utils_1.componentMatches)(component.component, {
|
|
323
|
+
path: (_b = (_a = component.paths) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(new RegExp(`^${(_c = this.paths) === null || _c === void 0 ? void 0 : _c.path}\\.?`), ''),
|
|
324
|
+
fullPath: (_e = (_d = component.paths) === null || _d === void 0 ? void 0 : _d.fullPath) === null || _e === void 0 ? void 0 : _e.replace(new RegExp(`^${(_f = this.paths) === null || _f === void 0 ? void 0 : _f.fullPath}\\.?`), ''),
|
|
325
|
+
localPath: (_h = (_g = component.paths) === null || _g === void 0 ? void 0 : _g.localPath) === null || _h === void 0 ? void 0 : _h.replace(new RegExp(`^${(_j = this.paths) === null || _j === void 0 ? void 0 : _j.localPath}\\.?`), ''),
|
|
326
|
+
fullLocalPath: (_l = (_k = component.paths) === null || _k === void 0 ? void 0 : _k.fullLocalPath) === null || _l === void 0 ? void 0 : _l.replace(new RegExp(`^${(_m = this.paths) === null || _m === void 0 ? void 0 : _m.fullLocalPath}\\.?`), ''),
|
|
327
|
+
dataPath: (_p = (_o = component.paths) === null || _o === void 0 ? void 0 : _o.dataPath) === null || _p === void 0 ? void 0 : _p.replace(new RegExp(`^${(_q = this.paths) === null || _q === void 0 ? void 0 : _q.dataPath}\\.?`), ''),
|
|
328
|
+
localDataPath: (_s = (_r = component.paths) === null || _r === void 0 ? void 0 : _r.localDataPath) === null || _s === void 0 ? void 0 : _s.replace(new RegExp(`^${(_t = this.paths) === null || _t === void 0 ? void 0 : _t.localDataPath}\\.?`), ''),
|
|
329
|
+
}, path, this.rowIndex, matches, (type, match) => {
|
|
330
|
+
match.instance = component;
|
|
331
|
+
return match;
|
|
332
|
+
});
|
|
345
333
|
});
|
|
346
|
-
|
|
347
|
-
comp = possibleComp;
|
|
348
|
-
}
|
|
349
|
-
return comp;
|
|
334
|
+
return (_a = (0, utils_1.getBestMatch)(matches)) === null || _a === void 0 ? void 0 : _a.instance;
|
|
350
335
|
}
|
|
351
336
|
/**
|
|
352
337
|
* Return a component provided the Id of the component.
|
|
@@ -682,20 +667,17 @@ class NestedComponent extends Field_1.default {
|
|
|
682
667
|
isValid(data, dirty) {
|
|
683
668
|
return this.getComponents().reduce((valid, comp) => comp.isValid(data, dirty) && valid, super.isValid(data, dirty));
|
|
684
669
|
}
|
|
685
|
-
validationProcessor({ scope, data, row, instance,
|
|
670
|
+
validationProcessor({ scope, data, row, instance, paths }, flags) {
|
|
686
671
|
var _a;
|
|
687
672
|
const { dirty } = flags;
|
|
688
|
-
if (this.root.
|
|
689
|
-
instance = ((_a = this.
|
|
690
|
-
? this.
|
|
691
|
-
: this.getComponent(
|
|
673
|
+
if (this.root.hasExtraPages && this.page !== this.root.page) {
|
|
674
|
+
instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
|
|
675
|
+
? this.componentsMap[paths.dataPath]
|
|
676
|
+
: this.getComponent(paths.dataPath);
|
|
692
677
|
}
|
|
693
678
|
if (!instance) {
|
|
694
679
|
return;
|
|
695
680
|
}
|
|
696
|
-
if (!instance.component.path) {
|
|
697
|
-
instance.component.path = component.path;
|
|
698
|
-
}
|
|
699
681
|
instance.checkComponentValidity(data, dirty, row, flags, scope.errors);
|
|
700
682
|
if (instance.processOwnValidation) {
|
|
701
683
|
scope.noRecurse = true;
|
|
@@ -727,7 +709,10 @@ class NestedComponent extends Field_1.default {
|
|
|
727
709
|
components,
|
|
728
710
|
instances: this.componentsMap,
|
|
729
711
|
data: data,
|
|
712
|
+
local: !!flags.local,
|
|
730
713
|
scope: { errors: [] },
|
|
714
|
+
parent: this.component,
|
|
715
|
+
parentPaths: this.paths,
|
|
731
716
|
processors: [
|
|
732
717
|
{
|
|
733
718
|
process: validationProcessorProcess,
|
|
@@ -2,6 +2,8 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
2
2
|
static savedValueTypes(): string[];
|
|
3
3
|
componentContext(component: any): any;
|
|
4
4
|
get iteratableRows(): void;
|
|
5
|
+
set rowIndex(value: number | undefined);
|
|
6
|
+
get rowIndex(): number | undefined;
|
|
5
7
|
prevHasAddButton: any;
|
|
6
8
|
checkAddButtonChanged(): void;
|
|
7
9
|
checkData(data: any, flags: any, row: any): any;
|
|
@@ -10,7 +12,6 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
10
12
|
checkRow(...args: any[]): any;
|
|
11
13
|
processRow(method: any, data: any, opts: any, row: any, components: any, silentCheck: any): any;
|
|
12
14
|
hasAddButton(): any;
|
|
13
|
-
getComponent(path: any, fn: any, originalPath: any): any;
|
|
14
15
|
everyComponent(fn: any, rowIndex: any, options?: {}): void;
|
|
15
16
|
_getEmailTableHeader(options: any): string;
|
|
16
17
|
_getEmailTableBody(options: any): string;
|
|
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
|
-
const utils_1 = require("
|
|
7
|
+
const utils_1 = require("@formio/core/utils");
|
|
8
|
+
const { getComponentPaths } = utils_1.Utils;
|
|
9
|
+
const utils_2 = require("../../../utils/utils");
|
|
8
10
|
const Component_1 = __importDefault(require("../component/Component"));
|
|
9
11
|
const NestedDataComponent_1 = __importDefault(require("../nesteddata/NestedDataComponent"));
|
|
10
12
|
class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
@@ -14,7 +16,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
14
16
|
}, ...extend);
|
|
15
17
|
}
|
|
16
18
|
static savedValueTypes() {
|
|
17
|
-
return [
|
|
19
|
+
return [utils_2.componentValueTypes.array];
|
|
18
20
|
}
|
|
19
21
|
componentContext(component) {
|
|
20
22
|
return this.iteratableRows[component.rowIndex].data;
|
|
@@ -23,9 +25,11 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
23
25
|
throw new Error('Getter #iteratableRows() is not implemented');
|
|
24
26
|
}
|
|
25
27
|
get rowIndex() {
|
|
26
|
-
return
|
|
28
|
+
return this._rowIndex;
|
|
27
29
|
}
|
|
28
30
|
set rowIndex(value) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
this.paths = getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
|
|
29
33
|
this._rowIndex = value;
|
|
30
34
|
}
|
|
31
35
|
init() {
|
|
@@ -88,47 +92,6 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
88
92
|
value: this.dataValue,
|
|
89
93
|
}, 'show'));
|
|
90
94
|
}
|
|
91
|
-
getComponent(path, fn, originalPath) {
|
|
92
|
-
originalPath = originalPath || (0, utils_1.getStringFromComponentPath)(path);
|
|
93
|
-
if (this.componentsMap.hasOwnProperty(originalPath)) {
|
|
94
|
-
if (fn) {
|
|
95
|
-
return fn(this.componentsMap[originalPath]);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return this.componentsMap[originalPath];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
path = Array.isArray(path) ? path : [path];
|
|
102
|
-
let key = path.shift();
|
|
103
|
-
const remainingPath = path;
|
|
104
|
-
let result = [];
|
|
105
|
-
let possibleComp = null;
|
|
106
|
-
let comp = null;
|
|
107
|
-
let rowIndex = null;
|
|
108
|
-
if (lodash_1.default.isNumber(key)) {
|
|
109
|
-
rowIndex = key;
|
|
110
|
-
key = remainingPath.shift();
|
|
111
|
-
}
|
|
112
|
-
if (!lodash_1.default.isString(key)) {
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
this.everyComponent((component, components) => {
|
|
116
|
-
if (component.component.key === key) {
|
|
117
|
-
possibleComp = component;
|
|
118
|
-
if (remainingPath.length > 0 && 'getComponent' in component) {
|
|
119
|
-
comp = component.getComponent(remainingPath, fn, originalPath);
|
|
120
|
-
}
|
|
121
|
-
else if (fn) {
|
|
122
|
-
fn(component, components);
|
|
123
|
-
}
|
|
124
|
-
result = rowIndex !== null ? comp : result.concat(comp || possibleComp);
|
|
125
|
-
}
|
|
126
|
-
}, rowIndex);
|
|
127
|
-
if ((!result || result.length === 0) && possibleComp) {
|
|
128
|
-
result = rowIndex !== null ? possibleComp : [possibleComp];
|
|
129
|
-
}
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
95
|
everyComponent(fn, rowIndex, options = {}) {
|
|
133
96
|
if (lodash_1.default.isObject(rowIndex)) {
|
|
134
97
|
options = rowIndex;
|
|
@@ -163,7 +126,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
163
126
|
if (component.isInputComponent) {
|
|
164
127
|
row += getHeaderCell(component);
|
|
165
128
|
}
|
|
166
|
-
else if ((0,
|
|
129
|
+
else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
|
|
167
130
|
component.everyComponent((comp) => {
|
|
168
131
|
row += getHeaderCell(comp);
|
|
169
132
|
}, options);
|
|
@@ -185,7 +148,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
|
185
148
|
if (component.isInputComponent) {
|
|
186
149
|
row += getBodyCell(component);
|
|
187
150
|
}
|
|
188
|
-
else if ((0,
|
|
151
|
+
else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
|
|
189
152
|
component.everyComponent((comp) => {
|
|
190
153
|
row += getBodyCell(comp);
|
|
191
154
|
}, options);
|
|
@@ -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';
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
|
|
8
8
|
const utils_1 = require("../../utils/utils");
|
|
9
|
-
const Components_1 = __importDefault(require("../Components"));
|
|
10
9
|
class DataGridComponent extends NestedArrayComponent_1.default {
|
|
11
10
|
static schema(...extend) {
|
|
12
11
|
return NestedArrayComponent_1.default.schema({
|
|
@@ -426,7 +425,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
426
425
|
}
|
|
427
426
|
component.rowIndex = rowIndex;
|
|
428
427
|
component.row = `${rowIndex}-${colIndex}`;
|
|
429
|
-
component.path = Components_1.default.getComponentPath(component);
|
|
430
428
|
});
|
|
431
429
|
}
|
|
432
430
|
updateRowsComponents(rowIndex) {
|
|
@@ -492,6 +490,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
492
490
|
const options = lodash_1.default.clone(this.options);
|
|
493
491
|
options.name += `[${rowIndex}]`;
|
|
494
492
|
options.row = `${rowIndex}-${colIndex}`;
|
|
493
|
+
options.rowIndex = rowIndex;
|
|
495
494
|
let columnComponent;
|
|
496
495
|
if (this.builderMode) {
|
|
497
496
|
col.id = col.id + rowIndex;
|
|
@@ -614,49 +613,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
614
613
|
restoreComponentsContext() {
|
|
615
614
|
this.rows.forEach((row, index) => lodash_1.default.forIn(row, (component) => component.data = this.dataValue[index]));
|
|
616
615
|
}
|
|
617
|
-
getComponent(path, fn) {
|
|
618
|
-
path = Array.isArray(path) ? path : [path];
|
|
619
|
-
const [key, ...remainingPath] = path;
|
|
620
|
-
let result = [];
|
|
621
|
-
if (lodash_1.default.isNumber(key) && remainingPath.length) {
|
|
622
|
-
const compKey = remainingPath.pop();
|
|
623
|
-
result = this.rows[key][compKey];
|
|
624
|
-
// If the component is inside a Layout Component, try to find it among all the row's components
|
|
625
|
-
if (!result) {
|
|
626
|
-
Object.entries(this.rows[key]).forEach(([, comp]) => {
|
|
627
|
-
if ('getComponent' in comp) {
|
|
628
|
-
const possibleResult = comp.getComponent([compKey], fn);
|
|
629
|
-
if (possibleResult) {
|
|
630
|
-
result = possibleResult;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
if (result && lodash_1.default.isFunction(fn)) {
|
|
636
|
-
fn(result, this.getComponents());
|
|
637
|
-
}
|
|
638
|
-
if (remainingPath.length && 'getComponent' in result) {
|
|
639
|
-
return result.getComponent(remainingPath, fn);
|
|
640
|
-
}
|
|
641
|
-
return result;
|
|
642
|
-
}
|
|
643
|
-
if (!lodash_1.default.isString(key)) {
|
|
644
|
-
return result;
|
|
645
|
-
}
|
|
646
|
-
this.everyComponent((component, components) => {
|
|
647
|
-
if (component.component.key === key) {
|
|
648
|
-
let comp = component;
|
|
649
|
-
if (remainingPath.length > 0 && 'getComponent' in component) {
|
|
650
|
-
comp = component.getComponent(remainingPath, fn);
|
|
651
|
-
}
|
|
652
|
-
else if (fn) {
|
|
653
|
-
fn(component, components);
|
|
654
|
-
}
|
|
655
|
-
result = result.concat(comp);
|
|
656
|
-
}
|
|
657
|
-
});
|
|
658
|
-
return result.length > 0 ? result : null;
|
|
659
|
-
}
|
|
660
616
|
toggleGroup(element, index) {
|
|
661
617
|
element.classList.toggle('collapsed');
|
|
662
618
|
lodash_1.default.each(this.refs.chunks[index], row => {
|
|
@@ -8,7 +8,6 @@ const DataGrid_1 = __importDefault(require("../datagrid/DataGrid"));
|
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
10
10
|
const utils_1 = require("../../utils/utils");
|
|
11
|
-
const Components_1 = __importDefault(require("../Components"));
|
|
12
11
|
class DataMapComponent extends DataGrid_1.default {
|
|
13
12
|
static schema(...extend) {
|
|
14
13
|
return Component_1.default.schema({
|
|
@@ -232,6 +231,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
232
231
|
options.events = new eventemitter3_1.default();
|
|
233
232
|
options.name += `[${rowIndex}]`;
|
|
234
233
|
options.row = `${rowIndex}`;
|
|
234
|
+
options.rowIndex = rowIndex;
|
|
235
235
|
const components = {};
|
|
236
236
|
components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
|
|
237
237
|
components['__key'].on('componentChange', (event) => {
|
|
@@ -241,7 +241,6 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
241
241
|
delete dataValue[key];
|
|
242
242
|
const comp = components[this.valueKey];
|
|
243
243
|
comp.component.key = newKey;
|
|
244
|
-
comp.path = Components_1.default.getComponentPath(comp);
|
|
245
244
|
key = newKey;
|
|
246
245
|
});
|
|
247
246
|
const valueComponent = lodash_1.default.clone(this.component.valueComponent);
|
|
@@ -934,6 +934,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
934
934
|
const options = lodash_1.default.clone(this.options);
|
|
935
935
|
options.name += `[${rowIndex}]`;
|
|
936
936
|
options.row = `${rowIndex}-${colIndex}`;
|
|
937
|
+
options.rowIndex = rowIndex;
|
|
937
938
|
options.onChange = (flags = {}, changed, modified) => {
|
|
938
939
|
var _a, _b;
|
|
939
940
|
if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {
|
|
@@ -948,7 +949,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
948
949
|
const editRow = this.editRows[rowIndex];
|
|
949
950
|
if (editRow) {
|
|
950
951
|
this.processRow('checkData', null, Object.assign(Object.assign({}, flags), { changed }), editRow.data, editRow.components);
|
|
951
|
-
this.validateRow(editRow, false);
|
|
952
|
+
this.validateRow(editRow, false, false);
|
|
952
953
|
}
|
|
953
954
|
if (this.variableTypeComponentsIndexes.length) {
|
|
954
955
|
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
|
@@ -990,22 +991,21 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
990
991
|
var _a;
|
|
991
992
|
editRow.errors = [];
|
|
992
993
|
if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
|
|
993
|
-
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
|
994
|
+
const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
|
|
994
995
|
const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
|
|
995
996
|
const editGridValue = lodash_1.default.get(rootValue, this.path, []);
|
|
996
997
|
editGridValue[editRow.rowIndex] = editRow.data;
|
|
997
998
|
lodash_1.default.set(rootValue, this.path, editGridValue);
|
|
998
999
|
const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
|
|
999
1000
|
const errors = (0, process_1.processSync)({
|
|
1000
|
-
components:
|
|
1001
|
-
component.parentPath = `${this.path}[${editRow.rowIndex}]`;
|
|
1002
|
-
return component;
|
|
1003
|
-
}),
|
|
1001
|
+
components: this.component.components,
|
|
1004
1002
|
data: rootValue,
|
|
1005
1003
|
row: editRow.data,
|
|
1006
1004
|
process: 'validateRow',
|
|
1007
1005
|
instances: this.componentsMap,
|
|
1008
1006
|
scope: { errors: [] },
|
|
1007
|
+
parent: this.component,
|
|
1008
|
+
parentPaths: Object.assign(Object.assign({}, this.paths), { dataIndex: editRow.rowIndex }),
|
|
1009
1009
|
processors: [
|
|
1010
1010
|
{
|
|
1011
1011
|
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;
|