@formio/js 5.0.0 → 5.1.0-rc.2
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.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +127 -116
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -3
- package/dist/formio.full.js +128 -117
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +3013 -283
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +14 -2
- package/dist/formio.utils.js +60 -49
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +3 -3
- package/lib/cjs/Webform.d.ts +8 -1
- package/lib/cjs/Webform.js +40 -32
- package/lib/cjs/WebformBuilder.js +4 -12
- package/lib/cjs/Wizard.js +4 -11
- 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 +52 -7
- package/lib/cjs/components/_classes/component/Component.js +120 -42
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- 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 +54 -60
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +7 -44
- 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 +2 -3
- package/lib/cjs/components/editgrid/EditGrid.js +8 -11
- package/lib/cjs/components/form/Form.d.ts +8 -3
- package/lib/cjs/components/form/Form.js +31 -29
- package/lib/cjs/components/html/HTML.js +15 -3
- package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/cjs/components/signature/Signature.d.ts +0 -1
- package/lib/cjs/components/signature/Signature.js +1 -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 -3
- package/lib/cjs/utils/utils.js +19 -35
- package/lib/mjs/Webform.d.ts +8 -1
- package/lib/mjs/Webform.js +37 -31
- package/lib/mjs/WebformBuilder.js +4 -12
- package/lib/mjs/Wizard.js +2 -8
- 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 +52 -7
- package/lib/mjs/components/_classes/component/Component.js +130 -43
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- 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 +55 -61
- 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 +2 -3
- package/lib/mjs/components/editgrid/EditGrid.js +11 -11
- package/lib/mjs/components/form/Form.d.ts +8 -3
- package/lib/mjs/components/form/Form.js +32 -29
- package/lib/mjs/components/html/HTML.js +15 -3
- package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/mjs/components/signature/Signature.d.ts +0 -1
- package/lib/mjs/components/signature/Signature.js +1 -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 -3
- package/lib/mjs/utils/utils.js +18 -33
- package/package.json +4 -4
@@ -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
|
/**
|
@@ -84,17 +85,26 @@ class NestedComponent extends Field_1.default {
|
|
84
85
|
const visibilityChanged = this._visible !== value;
|
85
86
|
this._visible = value;
|
86
87
|
const isVisible = this.visible;
|
88
|
+
const isConditionallyHidden = this.checkConditionallyHidden();
|
87
89
|
const forceShow = this.shouldForceShow();
|
88
90
|
const forceHide = this.shouldForceHide();
|
89
|
-
this.components.forEach(component => {
|
91
|
+
this.components.forEach((component) => {
|
90
92
|
// Set the parent visibility first since we may have nested components within nested components
|
91
93
|
// and they need to be able to determine their visibility based on the parent visibility.
|
92
94
|
component.parentVisible = isVisible;
|
93
|
-
|
94
|
-
|
95
|
+
component._parentConditionallyHidden = isConditionallyHidden;
|
96
|
+
let visible;
|
97
|
+
if (component.hasCondition()) {
|
98
|
+
component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
|
99
|
+
visible = !component.conditionallyHidden;
|
100
|
+
}
|
101
|
+
else {
|
102
|
+
visible = !component.component.hidden;
|
103
|
+
}
|
104
|
+
if (forceShow || visible) {
|
95
105
|
component.visible = true;
|
96
106
|
}
|
97
|
-
else if (forceHide || !isVisible || !
|
107
|
+
else if (forceHide || !isVisible || !visible) {
|
98
108
|
component.visible = false;
|
99
109
|
}
|
100
110
|
// If hiding a nested component, clear all errors below.
|
@@ -103,7 +113,6 @@ class NestedComponent extends Field_1.default {
|
|
103
113
|
}
|
104
114
|
});
|
105
115
|
if (visibilityChanged) {
|
106
|
-
this.clearOnHide();
|
107
116
|
this.redraw();
|
108
117
|
}
|
109
118
|
}
|
@@ -201,7 +210,9 @@ class NestedComponent extends Field_1.default {
|
|
201
210
|
* @returns {void}
|
202
211
|
*/
|
203
212
|
set rowIndex(value) {
|
213
|
+
var _a, _b;
|
204
214
|
this._rowIndex = value;
|
215
|
+
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
216
|
this.eachComponent((component) => {
|
206
217
|
component.rowIndex = value;
|
207
218
|
});
|
@@ -297,56 +308,38 @@ class NestedComponent extends Field_1.default {
|
|
297
308
|
});
|
298
309
|
}
|
299
310
|
/**
|
300
|
-
* Returns a component provided a key. This performs a deep search within the
|
301
|
-
* component tree.
|
311
|
+
* Returns a component provided a key. This performs a deep search within the component tree.
|
302
312
|
* @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
313
|
* @returns {any} - The component that is located.
|
306
314
|
*/
|
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
|
-
}
|
315
|
+
getComponent(path) {
|
316
|
+
var _a;
|
317
|
+
path = (0, utils_1.getStringFromComponentPath)(path);
|
318
|
+
const matches = {
|
319
|
+
path: undefined,
|
320
|
+
fullPath: undefined,
|
321
|
+
localPath: undefined,
|
322
|
+
fullLocalPath: undefined,
|
323
|
+
dataPath: undefined,
|
324
|
+
localDataPath: undefined,
|
325
|
+
key: undefined,
|
326
|
+
};
|
327
|
+
this.everyComponent((component) => {
|
328
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
329
|
+
// All searches are relative to this component so replace this path from the child paths.
|
330
|
+
(0, utils_1.componentMatches)(component.component, {
|
331
|
+
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}\\.?`), ''),
|
332
|
+
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}\\.?`), ''),
|
333
|
+
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}\\.?`), ''),
|
334
|
+
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}\\.?`), ''),
|
335
|
+
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}\\.?`), ''),
|
336
|
+
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}\\.?`), ''),
|
337
|
+
}, path, this.rowIndex, matches, (type, match) => {
|
338
|
+
match.instance = component;
|
339
|
+
return match;
|
340
|
+
});
|
345
341
|
});
|
346
|
-
|
347
|
-
comp = possibleComp;
|
348
|
-
}
|
349
|
-
return comp;
|
342
|
+
return (_a = (0, utils_1.getBestMatch)(matches)) === null || _a === void 0 ? void 0 : _a.instance;
|
350
343
|
}
|
351
344
|
/**
|
352
345
|
* Return a component provided the Id of the component.
|
@@ -384,6 +377,7 @@ class NestedComponent extends Field_1.default {
|
|
384
377
|
data = data || this.data;
|
385
378
|
options.parent = this;
|
386
379
|
options.parentVisible = this.visible;
|
380
|
+
options.parentConditionallyHidden = this.conditionallyHidden;
|
387
381
|
options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
|
388
382
|
options.localRoot = this.localRoot;
|
389
383
|
options.skipInit = true;
|
@@ -642,7 +636,7 @@ class NestedComponent extends Field_1.default {
|
|
642
636
|
clearOnHide(show) {
|
643
637
|
super.clearOnHide(show);
|
644
638
|
if (this.component.clearOnHide) {
|
645
|
-
if (this.allowData && !this.hasValue() && !
|
639
|
+
if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
|
646
640
|
this.dataValue = this.defaultValue;
|
647
641
|
}
|
648
642
|
if (this.hasValue()) {
|
@@ -671,7 +665,7 @@ class NestedComponent extends Field_1.default {
|
|
671
665
|
}
|
672
666
|
calculateValue(data, flags, row) {
|
673
667
|
// Do not iterate into children and calculateValues if this nested component is conditionally hidden.
|
674
|
-
if (
|
668
|
+
if (this.conditionallyHidden) {
|
675
669
|
return false;
|
676
670
|
}
|
677
671
|
return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
|
@@ -682,20 +676,17 @@ class NestedComponent extends Field_1.default {
|
|
682
676
|
isValid(data, dirty) {
|
683
677
|
return this.getComponents().reduce((valid, comp) => comp.isValid(data, dirty) && valid, super.isValid(data, dirty));
|
684
678
|
}
|
685
|
-
validationProcessor({ scope, data, row, instance,
|
679
|
+
validationProcessor({ scope, data, row, instance, paths }, flags) {
|
686
680
|
var _a;
|
687
681
|
const { dirty } = flags;
|
688
682
|
if (this.root.hasExtraPages && this.page !== this.root.page) {
|
689
|
-
instance = ((_a = this.
|
690
|
-
? this.
|
691
|
-
: this.getComponent(
|
683
|
+
instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
|
684
|
+
? this.componentsMap[paths.dataPath]
|
685
|
+
: this.getComponent(paths.dataPath);
|
692
686
|
}
|
693
687
|
if (!instance) {
|
694
688
|
return;
|
695
689
|
}
|
696
|
-
if (!instance.component.path) {
|
697
|
-
instance.component.path = component.path;
|
698
|
-
}
|
699
690
|
instance.checkComponentValidity(data, dirty, row, flags, scope.errors);
|
700
691
|
if (instance.processOwnValidation) {
|
701
692
|
scope.noRecurse = true;
|
@@ -727,7 +718,10 @@ class NestedComponent extends Field_1.default {
|
|
727
718
|
components,
|
728
719
|
instances: this.componentsMap,
|
729
720
|
data: data,
|
721
|
+
local: !!flags.local,
|
730
722
|
scope: { errors: [] },
|
723
|
+
parent: this.component,
|
724
|
+
parentPaths: this.paths,
|
731
725
|
processors: [
|
732
726
|
{
|
733
727
|
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
|
getComponents(rowIndex: any): any;
|
16
17
|
removeSubmissionMetadataRow(index: any): void;
|
@@ -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;
|
@@ -85,7 +85,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
85
85
|
show: boolean;
|
86
86
|
};
|
87
87
|
checkComponentConditions(data: any, flags: any, row: any): boolean;
|
88
|
-
getComponent(path: any, fn: any): any;
|
89
88
|
toggleGroup(element: any, index: any): void;
|
90
89
|
}
|
91
90
|
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
|
const dragula_1 = __importDefault(require("dragula"));
|
11
10
|
class DataGridComponent extends NestedArrayComponent_1.default {
|
12
11
|
static schema(...extend) {
|
@@ -411,7 +410,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
411
410
|
}
|
412
411
|
component.rowIndex = rowIndex;
|
413
412
|
component.row = `${rowIndex}-${colIndex}`;
|
414
|
-
component.path = Components_1.default.getComponentPath(component);
|
415
413
|
});
|
416
414
|
}
|
417
415
|
updateRowsComponents(rowIndex) {
|
@@ -477,6 +475,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
477
475
|
const options = lodash_1.default.clone(this.options);
|
478
476
|
options.name += `[${rowIndex}]`;
|
479
477
|
options.row = `${rowIndex}-${colIndex}`;
|
478
|
+
options.rowIndex = rowIndex;
|
480
479
|
let columnComponent;
|
481
480
|
if (this.builderMode) {
|
482
481
|
col.id = col.id + rowIndex;
|
@@ -599,49 +598,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
599
598
|
restoreComponentsContext() {
|
600
599
|
this.rows.forEach((row, index) => lodash_1.default.forIn(row, (component) => component.data = this.dataValue[index]));
|
601
600
|
}
|
602
|
-
getComponent(path, fn) {
|
603
|
-
path = Array.isArray(path) ? path : [path];
|
604
|
-
const [key, ...remainingPath] = path;
|
605
|
-
let result = [];
|
606
|
-
if (lodash_1.default.isNumber(key) && remainingPath.length) {
|
607
|
-
const compKey = remainingPath.pop();
|
608
|
-
result = this.rows[key][compKey];
|
609
|
-
// If the component is inside a Layout Component, try to find it among all the row's components
|
610
|
-
if (!result) {
|
611
|
-
Object.entries(this.rows[key]).forEach(([, comp]) => {
|
612
|
-
if ('getComponent' in comp) {
|
613
|
-
const possibleResult = comp.getComponent([compKey], fn);
|
614
|
-
if (possibleResult) {
|
615
|
-
result = possibleResult;
|
616
|
-
}
|
617
|
-
}
|
618
|
-
});
|
619
|
-
}
|
620
|
-
if (result && lodash_1.default.isFunction(fn)) {
|
621
|
-
fn(result, this.getComponents());
|
622
|
-
}
|
623
|
-
if (remainingPath.length && 'getComponent' in result) {
|
624
|
-
return result.getComponent(remainingPath, fn);
|
625
|
-
}
|
626
|
-
return result;
|
627
|
-
}
|
628
|
-
if (!lodash_1.default.isString(key)) {
|
629
|
-
return result;
|
630
|
-
}
|
631
|
-
this.everyComponent((component, components) => {
|
632
|
-
if (component.component.key === key) {
|
633
|
-
let comp = component;
|
634
|
-
if (remainingPath.length > 0 && 'getComponent' in component) {
|
635
|
-
comp = component.getComponent(remainingPath, fn);
|
636
|
-
}
|
637
|
-
else if (fn) {
|
638
|
-
fn(component, components);
|
639
|
-
}
|
640
|
-
result = result.concat(comp);
|
641
|
-
}
|
642
|
-
});
|
643
|
-
return result.length > 0 ? result : null;
|
644
|
-
}
|
645
601
|
toggleGroup(element, index) {
|
646
602
|
element.classList.toggle('collapsed');
|
647
603
|
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({
|
@@ -75,7 +74,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
75
74
|
}
|
76
75
|
get dataValue() {
|
77
76
|
if (!this.key ||
|
78
|
-
(
|
77
|
+
(this.conditionallyHidden && this.component.clearOnHide)) {
|
79
78
|
return this.emptyValue;
|
80
79
|
}
|
81
80
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -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);
|
@@ -924,6 +924,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
924
924
|
const options = lodash_1.default.clone(this.options);
|
925
925
|
options.name += `[${rowIndex}]`;
|
926
926
|
options.row = `${rowIndex}-${colIndex}`;
|
927
|
+
options.rowIndex = rowIndex;
|
927
928
|
options.onChange = (flags = {}, changed, modified) => {
|
928
929
|
var _a, _b;
|
929
930
|
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)) {
|
@@ -938,7 +939,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
938
939
|
const editRow = this.editRows[rowIndex];
|
939
940
|
if (editRow) {
|
940
941
|
this.processRow('checkData', null, Object.assign(Object.assign({}, flags), { changed }), editRow.data, editRow.components);
|
941
|
-
this.validateRow(editRow, false);
|
942
|
+
this.validateRow(editRow, false, false);
|
942
943
|
}
|
943
944
|
if (this.variableTypeComponentsIndexes.length) {
|
944
945
|
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
@@ -980,22 +981,21 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
980
981
|
var _a;
|
981
982
|
editRow.errors = [];
|
982
983
|
if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
|
983
|
-
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
984
|
+
const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
|
984
985
|
const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
|
985
986
|
const editGridValue = lodash_1.default.get(rootValue, this.path, []);
|
986
987
|
editGridValue[editRow.rowIndex] = editRow.data;
|
987
988
|
lodash_1.default.set(rootValue, this.path, editGridValue);
|
988
989
|
const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
|
989
990
|
const errors = (0, process_1.processSync)({
|
990
|
-
components:
|
991
|
-
component.parentPath = `${this.path}[${editRow.rowIndex}]`;
|
992
|
-
return component;
|
993
|
-
}),
|
991
|
+
components: this.component.components,
|
994
992
|
data: rootValue,
|
995
993
|
row: editRow.data,
|
996
994
|
process: 'validateRow',
|
997
995
|
instances: this.componentsMap,
|
998
996
|
scope: { errors: [] },
|
997
|
+
parent: this.component,
|
998
|
+
parentPaths: Object.assign(Object.assign({}, this.paths), { dataIndex: editRow.rowIndex }),
|
999
999
|
processors: [
|
1000
1000
|
{
|
1001
1001
|
process: validationProcessorProcess,
|
@@ -1141,7 +1141,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1141
1141
|
}
|
1142
1142
|
}
|
1143
1143
|
const changed = this.hasChanged(value, this.dataValue);
|
1144
|
-
if (this.parent
|
1144
|
+
if (this.parent) {
|
1145
1145
|
this.parent.checkComponentConditions();
|
1146
1146
|
}
|
1147
1147
|
this.dataValue = value;
|
@@ -1174,10 +1174,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1174
1174
|
this.editRows = this.editRows.slice(0, dataLength);
|
1175
1175
|
this.openWhenEmpty();
|
1176
1176
|
this.updateOnChange(flags, changed);
|
1177
|
-
|
1178
|
-
if (!this.options.server) {
|
1179
|
-
this.checkData();
|
1180
|
-
}
|
1177
|
+
this.checkData();
|
1181
1178
|
this.changeState(changed, flags);
|
1182
1179
|
return changed;
|
1183
1180
|
}
|
@@ -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;
|
@@ -90,6 +88,13 @@ export default class FormComponent extends Component {
|
|
90
88
|
isHidden(): boolean;
|
91
89
|
setValue(submission: any, flags?: {}): boolean;
|
92
90
|
setSubFormValue(submission: any, flags: any): void;
|
91
|
+
/**
|
92
|
+
* Sets the subform value
|
93
|
+
* @param {object|null|undefined} submission - The submission to set.
|
94
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
95
|
+
* @return {void}
|
96
|
+
*/
|
97
|
+
onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
|
93
98
|
areAllComponentsEmpty(data: any): boolean;
|
94
99
|
updateSubFormVisibility(): void;
|
95
100
|
/**
|