@formio/js 5.0.0-rc.99 → 5.1.0-rc.1
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 +122 -121
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -11
- package/dist/formio.full.js +123 -122
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -11
- package/dist/formio.js +3011 -281
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +14 -2
- package/dist/formio.utils.js +65 -54
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +7 -5
- package/lib/cjs/Webform.d.ts +8 -1
- package/lib/cjs/Webform.js +40 -32
- package/lib/cjs/WebformBuilder.js +22 -18
- package/lib/cjs/Wizard.d.ts +0 -1
- package/lib/cjs/Wizard.js +19 -33
- 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 +37 -7
- package/lib/cjs/components/_classes/component/Component.js +70 -26
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- 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 +38 -53
- 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 +1 -2
- package/lib/cjs/components/editgrid/EditGrid.js +6 -6
- package/lib/cjs/components/form/Form.d.ts +8 -3
- package/lib/cjs/components/form/Form.js +26 -25
- package/lib/cjs/components/html/HTML.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +8 -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 +22 -18
- package/lib/mjs/Wizard.d.ts +0 -1
- package/lib/mjs/Wizard.js +16 -29
- 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 +37 -7
- package/lib/mjs/components/_classes/component/Component.js +80 -27
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- 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 +39 -54
- 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 +8 -3
- package/lib/mjs/components/form/Form.js +27 -25
- package/lib/mjs/components/html/HTML.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -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
@@ -234,6 +234,7 @@ class Component extends Element_1.default {
|
|
234
234
|
*/
|
235
235
|
/* eslint-disable max-statements */
|
236
236
|
constructor(component, options, data) {
|
237
|
+
var _a, _b, _c, _d;
|
237
238
|
super(Object.assign({
|
238
239
|
renderMode: 'form',
|
239
240
|
attachMode: 'full',
|
@@ -249,6 +250,10 @@ class Component extends Element_1.default {
|
|
249
250
|
* @private
|
250
251
|
*/
|
251
252
|
this._hasCondition = null;
|
253
|
+
/**
|
254
|
+
* The row index for this component.
|
255
|
+
*/
|
256
|
+
this._rowIndex = undefined;
|
252
257
|
/**
|
253
258
|
* References to dom elements
|
254
259
|
*/
|
@@ -259,11 +264,6 @@ class Component extends Element_1.default {
|
|
259
264
|
this.options.components[component.type]) {
|
260
265
|
lodash_1.default.merge(component, this.options.components[component.type]);
|
261
266
|
}
|
262
|
-
/**
|
263
|
-
* The data path to this specific component instance.
|
264
|
-
* @type {string}
|
265
|
-
*/
|
266
|
-
this.path = (component === null || component === void 0 ? void 0 : component.key) || '';
|
267
267
|
/**
|
268
268
|
* An array of all the children components errors.
|
269
269
|
*/
|
@@ -332,6 +332,11 @@ class Component extends Element_1.default {
|
|
332
332
|
* @type {Component}
|
333
333
|
*/
|
334
334
|
this.parent = this.options.parent;
|
335
|
+
/**
|
336
|
+
* The component paths for this component.
|
337
|
+
* @type {import('@formio/core').ComponentPaths} - The component paths.
|
338
|
+
*/
|
339
|
+
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 }));
|
335
340
|
this.options.name = this.options.name || 'data';
|
336
341
|
this._path = '';
|
337
342
|
// Needs for Nextgen Rules Engine
|
@@ -438,12 +443,7 @@ class Component extends Element_1.default {
|
|
438
443
|
/* eslint-enable max-statements */
|
439
444
|
get componentsMap() {
|
440
445
|
var _a;
|
441
|
-
|
442
|
-
return this.localRoot.childComponentsMap;
|
443
|
-
}
|
444
|
-
const localMap = {};
|
445
|
-
localMap[this.path] = this;
|
446
|
-
return localMap;
|
446
|
+
return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
|
447
447
|
}
|
448
448
|
get data() {
|
449
449
|
return this._data;
|
@@ -490,6 +490,23 @@ class Component extends Element_1.default {
|
|
490
490
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
491
491
|
}
|
492
492
|
}
|
493
|
+
/**
|
494
|
+
* Get Row Index.
|
495
|
+
* @returns {number} - The row index.
|
496
|
+
*/
|
497
|
+
get rowIndex() {
|
498
|
+
return this._rowIndex;
|
499
|
+
}
|
500
|
+
/**
|
501
|
+
* Set Row Index to row and update each component.
|
502
|
+
* @param {number} value - The row index.
|
503
|
+
* @returns {void}
|
504
|
+
*/
|
505
|
+
set rowIndex(value) {
|
506
|
+
var _a, _b;
|
507
|
+
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 }));
|
508
|
+
this._rowIndex = value;
|
509
|
+
}
|
493
510
|
afterComponentAssign() {
|
494
511
|
//implement in extended classes
|
495
512
|
}
|
@@ -559,6 +576,12 @@ class Component extends Element_1.default {
|
|
559
576
|
get key() {
|
560
577
|
return lodash_1.default.get(this.component, 'key', '');
|
561
578
|
}
|
579
|
+
get path() {
|
580
|
+
return this.paths.dataPath;
|
581
|
+
}
|
582
|
+
set path(path) {
|
583
|
+
throw new Error('Should not be setting the path of a component.');
|
584
|
+
}
|
562
585
|
set parentVisible(value) {
|
563
586
|
this._parentVisible = value;
|
564
587
|
}
|
@@ -1046,6 +1069,14 @@ class Component extends Element_1.default {
|
|
1046
1069
|
setOpenModalElement(template = null) {
|
1047
1070
|
this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
|
1048
1071
|
}
|
1072
|
+
/**
|
1073
|
+
* Renders a modal preview template and returns the markup as a string
|
1074
|
+
* @param {object|null|undefined} ctx - The rendering context
|
1075
|
+
* @return {string} - The modal preview markup
|
1076
|
+
*/
|
1077
|
+
renderModalPreview(ctx) {
|
1078
|
+
return this.renderTemplate('modalPreview', ctx || {});
|
1079
|
+
}
|
1049
1080
|
/**
|
1050
1081
|
* Returns the modal preview template.
|
1051
1082
|
* @returns {string} - The modal preview template.
|
@@ -1057,7 +1088,7 @@ class Component extends Element_1.default {
|
|
1057
1088
|
if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
|
1058
1089
|
modalLabel = { className: 'field-required' };
|
1059
1090
|
}
|
1060
|
-
return this.
|
1091
|
+
return this.renderModalPreview({
|
1061
1092
|
previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
|
1062
1093
|
messages: '',
|
1063
1094
|
labelInfo: modalLabel,
|
@@ -1106,6 +1137,19 @@ class Component extends Element_1.default {
|
|
1106
1137
|
}, topLevel);
|
1107
1138
|
}
|
1108
1139
|
}
|
1140
|
+
/**
|
1141
|
+
* Creates the tooltip instance using tippy.js and returns it
|
1142
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
1143
|
+
* @param {object|null|undefined} settings - tippy.js options
|
1144
|
+
* @return {import('tippy.js').Tippy} - tippy.js instance
|
1145
|
+
*/
|
1146
|
+
createTooltip(tooltipEl, settings = {}) {
|
1147
|
+
const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
|
1148
|
+
const tooltipDataTitle = tooltipEl.getAttribute('data-title');
|
1149
|
+
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
1150
|
+
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
1151
|
+
return (0, tippy_js_1.default)(tooltipEl, Object.assign(Object.assign({ allowHTML: true, trigger: 'mouseenter click focus', placement: 'right', zIndex: 10000, interactive: true }, settings), { content: this.t(this.sanitize(tooltipText), { _userInput: true }) }));
|
1152
|
+
}
|
1109
1153
|
/**
|
1110
1154
|
* Attaches all the tooltips provided the refs object.
|
1111
1155
|
* @param {object} toolTipsRefs - The refs for the tooltips within your template.
|
@@ -1114,18 +1158,7 @@ class Component extends Element_1.default {
|
|
1114
1158
|
attachTooltips(toolTipsRefs) {
|
1115
1159
|
toolTipsRefs === null || toolTipsRefs === void 0 ? void 0 : toolTipsRefs.forEach((tooltip, index) => {
|
1116
1160
|
if (tooltip) {
|
1117
|
-
|
1118
|
-
const tooltipDataTitle = tooltip.getAttribute('data-title');
|
1119
|
-
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
1120
|
-
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
1121
|
-
this.tooltips[index] = (0, tippy_js_1.default)(tooltip, {
|
1122
|
-
allowHTML: true,
|
1123
|
-
trigger: 'mouseenter click focus',
|
1124
|
-
placement: 'right',
|
1125
|
-
zIndex: 10000,
|
1126
|
-
interactive: true,
|
1127
|
-
content: this.t(this.sanitize(tooltipText), { _userInput: true }),
|
1128
|
-
});
|
1161
|
+
this.tooltips[index] = this.createTooltip(tooltip);
|
1129
1162
|
}
|
1130
1163
|
});
|
1131
1164
|
}
|
@@ -1255,6 +1288,7 @@ class Component extends Element_1.default {
|
|
1255
1288
|
* @returns {void}
|
1256
1289
|
*/
|
1257
1290
|
checkRefresh(refreshData, changed, flags) {
|
1291
|
+
var _a, _b;
|
1258
1292
|
const changePath = lodash_1.default.get(changed, 'instance.path', false);
|
1259
1293
|
// Don't let components change themselves.
|
1260
1294
|
if (changePath && this.path === changePath) {
|
@@ -1263,7 +1297,7 @@ class Component extends Element_1.default {
|
|
1263
1297
|
if (refreshData === 'data') {
|
1264
1298
|
this.refresh(this.data, changed, flags);
|
1265
1299
|
}
|
1266
|
-
else if ((changePath && (
|
1300
|
+
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 &&
|
1267
1301
|
// Make sure the changed component is not in a different "context". Solves issues where refreshOn being set
|
1268
1302
|
// in fields inside EditGrids could alter their state from other rows (which is bad).
|
1269
1303
|
this.inContext(changed.instance)) {
|
@@ -2864,6 +2898,10 @@ class Component extends Element_1.default {
|
|
2864
2898
|
* @returns {string} - The message to show when the component is invalid.
|
2865
2899
|
*/
|
2866
2900
|
invalidMessage(data, dirty, ignoreCondition, row) {
|
2901
|
+
var _a;
|
2902
|
+
if (!row) {
|
2903
|
+
row = (0, utils_1.getContextualRowData)(this.component, data, this.paths);
|
2904
|
+
}
|
2867
2905
|
if (!ignoreCondition && !this.checkCondition(row, data)) {
|
2868
2906
|
return '';
|
2869
2907
|
}
|
@@ -2881,6 +2919,8 @@ class Component extends Element_1.default {
|
|
2881
2919
|
data,
|
2882
2920
|
row,
|
2883
2921
|
path: this.path || this.component.key,
|
2922
|
+
parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
|
2923
|
+
paths: this.paths,
|
2884
2924
|
scope: validationScope,
|
2885
2925
|
instance: this,
|
2886
2926
|
processors: [
|
@@ -2934,7 +2974,7 @@ class Component extends Element_1.default {
|
|
2934
2974
|
if (flags.silentCheck) {
|
2935
2975
|
return [];
|
2936
2976
|
}
|
2937
|
-
let isDirty = this.dirty || flags.dirty;
|
2977
|
+
let isDirty = (flags.dirty === false) ? false : (this.dirty || flags.dirty);
|
2938
2978
|
if (this.options.alwaysDirty) {
|
2939
2979
|
isDirty = true;
|
2940
2980
|
}
|
@@ -2949,6 +2989,7 @@ class Component extends Element_1.default {
|
|
2949
2989
|
* @returns {Array<any>} - An array of errors if the component is invalid.
|
2950
2990
|
*/
|
2951
2991
|
validateComponent(data = null, row = null, flags = {}) {
|
2992
|
+
var _a;
|
2952
2993
|
data = data || this.rootValue;
|
2953
2994
|
row = row || this.data;
|
2954
2995
|
const { async = false } = flags;
|
@@ -2959,7 +3000,10 @@ class Component extends Element_1.default {
|
|
2959
3000
|
component: this.component,
|
2960
3001
|
data,
|
2961
3002
|
row,
|
3003
|
+
local: !!flags.local,
|
2962
3004
|
value: this.validationValue,
|
3005
|
+
parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
|
3006
|
+
paths: this.paths,
|
2963
3007
|
path: this.path || this.component.key,
|
2964
3008
|
instance: this,
|
2965
3009
|
form: this.root ? this.root._form : {},
|
@@ -27,7 +27,7 @@ exports.default = [
|
|
27
27
|
weight: 100,
|
28
28
|
type: 'checkbox',
|
29
29
|
label: 'Validate When Hidden',
|
30
|
-
tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission.',
|
30
|
+
tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission. Use caution when enabling this setting, as it can cause a hidden component to be invalid with no way for the form user to correct it.',
|
31
31
|
key: 'validateWhenHidden',
|
32
32
|
input: true
|
33
33
|
},
|
@@ -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
673
|
if (this.root.hasExtraPages && this.page !== this.root.page) {
|
689
|
-
instance = ((_a = this.
|
690
|
-
? this.
|
691
|
-
: this.getComponent(
|
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
|
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({
|
@@ -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);
|