@formio/js 5.0.0-rc.80 → 5.0.0-rc.82
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 +8 -8
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +9 -9
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +3 -3
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/components/_classes/component/Component.js +1 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -0
- package/lib/cjs/components/editgrid/fixtures/comp18.d.ts +38 -0
- package/lib/cjs/components/editgrid/fixtures/comp18.js +74 -0
- package/lib/cjs/components/editgrid/fixtures/index.d.ts +8 -7
- package/lib/cjs/components/editgrid/fixtures/index.js +7 -1
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +24 -24
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +36 -2
- package/lib/cjs/components/select/editForm/Select.edit.data.js +29 -10
- package/lib/cjs/components/select/fixtures/comp4.d.ts +5 -2
- package/lib/cjs/components/select/fixtures/comp4.js +4 -0
- package/lib/cjs/utils/utils.d.ts +8 -0
- package/lib/cjs/utils/utils.js +13 -0
- package/lib/mjs/components/_classes/component/Component.js +1 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -0
- package/lib/mjs/components/editgrid/fixtures/comp18.d.ts +38 -0
- package/lib/mjs/components/editgrid/fixtures/comp18.js +72 -0
- package/lib/mjs/components/editgrid/fixtures/index.d.ts +8 -7
- package/lib/mjs/components/editgrid/fixtures/index.js +4 -1
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +24 -24
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +36 -2
- package/lib/mjs/components/select/editForm/Select.edit.data.js +27 -8
- package/lib/mjs/components/select/fixtures/comp4.d.ts +5 -2
- package/lib/mjs/components/select/fixtures/comp4.js +4 -0
- package/lib/mjs/utils/utils.d.ts +8 -0
- package/lib/mjs/utils/utils.js +13 -0
- package/package.json +2 -2
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
/*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
|
22
22
|
|
23
|
-
/*! formiojs v5.0.0-rc.
|
23
|
+
/*! formiojs v5.0.0-rc.82 | https://unpkg.com/formiojs@5.0.0-rc.82/LICENSE.txt */
|
24
24
|
|
25
25
|
/**
|
26
26
|
* @license
|
@@ -2187,7 +2187,7 @@ class Component extends Element_1.default {
|
|
2187
2187
|
this.addClass(this.getElement(), 'formio-modified');
|
2188
2188
|
}
|
2189
2189
|
// If we are supposed to validate on blur, then don't trigger validation yet.
|
2190
|
-
if (this.component.validateOn === 'blur') {
|
2190
|
+
if (this.component.validateOn === 'blur' || this.component.validateOn === 'submit') {
|
2191
2191
|
flags.noValidate = true;
|
2192
2192
|
}
|
2193
2193
|
if (this.component.onChange) {
|
@@ -37,6 +37,9 @@ class Multivalue extends Field_1.default {
|
|
37
37
|
if (this.component.storeas === 'string') {
|
38
38
|
return super.normalizeValue(value.join(this.delimiter || ''), flags);
|
39
39
|
}
|
40
|
+
if (this.component.type === 'hidden' && value.length > 1) {
|
41
|
+
return super.normalizeValue(value, flags);
|
42
|
+
}
|
40
43
|
return super.normalizeValue(value[0] || emptyValue, flags);
|
41
44
|
}
|
42
45
|
else {
|
@@ -0,0 +1,38 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let title: string;
|
3
|
+
let name: string;
|
4
|
+
let path: string;
|
5
|
+
let type: string;
|
6
|
+
let display: string;
|
7
|
+
let components: {
|
8
|
+
label: string;
|
9
|
+
tableView: boolean;
|
10
|
+
validateWhenHidden: boolean;
|
11
|
+
rowDrafts: boolean;
|
12
|
+
key: string;
|
13
|
+
validateOn: string;
|
14
|
+
type: string;
|
15
|
+
displayAsTable: boolean;
|
16
|
+
input: boolean;
|
17
|
+
components: {
|
18
|
+
label: string;
|
19
|
+
widget: string;
|
20
|
+
tableView: boolean;
|
21
|
+
data: {
|
22
|
+
values: {
|
23
|
+
label: string;
|
24
|
+
value: string;
|
25
|
+
}[];
|
26
|
+
};
|
27
|
+
validate: {
|
28
|
+
required: boolean;
|
29
|
+
};
|
30
|
+
validateWhenHidden: boolean;
|
31
|
+
validateOn: string;
|
32
|
+
key: string;
|
33
|
+
type: string;
|
34
|
+
input: boolean;
|
35
|
+
}[];
|
36
|
+
}[];
|
37
|
+
}
|
38
|
+
export default _default;
|
@@ -0,0 +1,74 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
title: "validate_submit",
|
5
|
+
name: "validate_submit",
|
6
|
+
path: "validate_submit",
|
7
|
+
type: "form",
|
8
|
+
display: "form",
|
9
|
+
components: [
|
10
|
+
{
|
11
|
+
label: "Edit Grid",
|
12
|
+
tableView: false,
|
13
|
+
validateWhenHidden: false,
|
14
|
+
rowDrafts: false,
|
15
|
+
key: "editGrid",
|
16
|
+
validateOn: 'submit',
|
17
|
+
type: "editgrid",
|
18
|
+
displayAsTable: false,
|
19
|
+
input: true,
|
20
|
+
components: [
|
21
|
+
{
|
22
|
+
label: "Select",
|
23
|
+
widget: "choicesjs",
|
24
|
+
tableView: true,
|
25
|
+
data: {
|
26
|
+
values: [
|
27
|
+
{
|
28
|
+
label: "one",
|
29
|
+
value: "one",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
label: "two",
|
33
|
+
value: "two",
|
34
|
+
},
|
35
|
+
],
|
36
|
+
},
|
37
|
+
validate: {
|
38
|
+
required: true,
|
39
|
+
},
|
40
|
+
validateWhenHidden: false,
|
41
|
+
validateOn: 'submit',
|
42
|
+
key: "select1",
|
43
|
+
type: "select",
|
44
|
+
input: true,
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "Select",
|
48
|
+
widget: "choicesjs",
|
49
|
+
tableView: true,
|
50
|
+
data: {
|
51
|
+
values: [
|
52
|
+
{
|
53
|
+
label: "three",
|
54
|
+
value: "three",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
label: "four",
|
58
|
+
value: "four",
|
59
|
+
},
|
60
|
+
],
|
61
|
+
},
|
62
|
+
validate: {
|
63
|
+
required: true,
|
64
|
+
},
|
65
|
+
validateWhenHidden: false,
|
66
|
+
validateOn: 'submit',
|
67
|
+
key: "select2",
|
68
|
+
type: "select",
|
69
|
+
input: true,
|
70
|
+
},
|
71
|
+
],
|
72
|
+
},
|
73
|
+
],
|
74
|
+
};
|
@@ -1,6 +1,12 @@
|
|
1
1
|
import comp1 from './comp1';
|
2
2
|
import comp2 from './comp2';
|
3
3
|
import comp3 from './comp3';
|
4
|
+
import comp4 from './comp4';
|
5
|
+
import comp5 from './comp5';
|
6
|
+
import comp6 from './comp6';
|
7
|
+
import comp7 from './comp7';
|
8
|
+
import comp8 from './comp8';
|
9
|
+
import comp9 from './comp9';
|
4
10
|
import comp10 from './comp10';
|
5
11
|
import comp11 from './comp11';
|
6
12
|
import comp12 from './comp12';
|
@@ -8,13 +14,8 @@ import comp13 from './comp13';
|
|
8
14
|
import comp14 from './comp14';
|
9
15
|
import comp15 from './comp15';
|
10
16
|
import comp16 from './comp16';
|
11
|
-
import
|
12
|
-
import comp5 from './comp5';
|
13
|
-
import comp6 from './comp6';
|
14
|
-
import comp7 from './comp7';
|
15
|
-
import comp8 from './comp8';
|
16
|
-
import comp9 from './comp9';
|
17
|
+
import comp18 from './comp18';
|
17
18
|
import compOpenWhenEmpty from './comp-openWhenEmpty';
|
18
19
|
import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
|
19
20
|
import compWithCustomDefaultValue from './comp-with-custom-default-value';
|
20
|
-
export { comp1, comp2, comp3,
|
21
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.compWithCustomDefaultValue = exports.withOpenWhenEmptyAndConditions = exports.compOpenWhenEmpty = exports.
|
6
|
+
exports.compTestEvents = exports.compWithCustomDefaultValue = exports.withOpenWhenEmptyAndConditions = exports.compOpenWhenEmpty = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
7
7
|
const comp1_1 = __importDefault(require("./comp1"));
|
8
8
|
exports.comp1 = comp1_1.default;
|
9
9
|
const comp2_1 = __importDefault(require("./comp2"));
|
@@ -36,9 +36,15 @@ const comp15_1 = __importDefault(require("./comp15"));
|
|
36
36
|
exports.comp15 = comp15_1.default;
|
37
37
|
const comp16_1 = __importDefault(require("./comp16"));
|
38
38
|
exports.comp16 = comp16_1.default;
|
39
|
+
const comp17_1 = __importDefault(require("./comp17"));
|
40
|
+
exports.comp17 = comp17_1.default;
|
41
|
+
const comp18_1 = __importDefault(require("./comp18"));
|
42
|
+
exports.comp18 = comp18_1.default;
|
39
43
|
const comp_with_conditions_and_openWhenEmpty_1 = __importDefault(require("./comp-with-conditions-and-openWhenEmpty"));
|
40
44
|
exports.withOpenWhenEmptyAndConditions = comp_with_conditions_and_openWhenEmpty_1.default;
|
41
45
|
const comp_openWhenEmpty_1 = __importDefault(require("./comp-openWhenEmpty"));
|
42
46
|
exports.compOpenWhenEmpty = comp_openWhenEmpty_1.default;
|
43
47
|
const comp_with_custom_default_value_1 = __importDefault(require("./comp-with-custom-default-value"));
|
44
48
|
exports.compWithCustomDefaultValue = comp_with_custom_default_value_1.default;
|
49
|
+
const comp_test_events_1 = __importDefault(require("./comp-test-events"));
|
50
|
+
exports.compTestEvents = comp_test_events_1.default;
|
@@ -136,6 +136,7 @@ export default class SelectComponent extends ListComponent {
|
|
136
136
|
normalizeSingleValue(value: any): any;
|
137
137
|
setMetadata(value: any): any;
|
138
138
|
updateValue(value: any, flags: any): boolean;
|
139
|
+
undoValueTyping(value: any): any;
|
139
140
|
setValue(value: any, flags?: {}): boolean;
|
140
141
|
lazyLoadInit: boolean | undefined;
|
141
142
|
isInitApiCallNeeded(hasValue: any): any;
|
@@ -238,10 +238,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
238
238
|
}
|
239
239
|
selectValueAndLabel(data) {
|
240
240
|
const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
|
241
|
-
const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
|
242
241
|
return {
|
243
242
|
value,
|
244
|
-
label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } :
|
243
|
+
label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)
|
245
244
|
};
|
246
245
|
}
|
247
246
|
itemTemplate(data, value) {
|
@@ -258,7 +257,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
258
257
|
const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
259
258
|
return this.sanitize(value, this.shouldSanitizeValue);
|
260
259
|
}
|
261
|
-
if (this.component.multiple && lodash_1.default.isArray(this.dataValue) ? this.dataValue.find((val) => value === val) : (this.dataValue === value)) {
|
260
|
+
if (this.component.multiple && lodash_1.default.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
|
262
261
|
const selectData = this.selectData;
|
263
262
|
if (selectData) {
|
264
263
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
@@ -1260,6 +1259,23 @@ class SelectComponent extends ListComponent_1.default {
|
|
1260
1259
|
}
|
1261
1260
|
return changed;
|
1262
1261
|
}
|
1262
|
+
undoValueTyping(value) {
|
1263
|
+
let untypedValue = value;
|
1264
|
+
if (this.component.multiple && Array.isArray(value)) {
|
1265
|
+
untypedValue = value.map(v => {
|
1266
|
+
if (typeof v === 'boolean' || typeof v === 'number') {
|
1267
|
+
return v.toString();
|
1268
|
+
}
|
1269
|
+
return v;
|
1270
|
+
});
|
1271
|
+
}
|
1272
|
+
else {
|
1273
|
+
if (typeof value === 'boolean' || typeof value === 'number') {
|
1274
|
+
untypedValue = value.toString();
|
1275
|
+
}
|
1276
|
+
}
|
1277
|
+
return untypedValue;
|
1278
|
+
}
|
1263
1279
|
setValue(value, flags = {}) {
|
1264
1280
|
const previousValue = this.dataValue;
|
1265
1281
|
const changed = this.updateValue(value, flags);
|
@@ -1270,19 +1286,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
1270
1286
|
const hasPreviousValue = !this.isEmpty(previousValue);
|
1271
1287
|
const hasValue = !this.isEmpty(value);
|
1272
1288
|
// Undo typing when searching to set the value.
|
1273
|
-
|
1274
|
-
value = value.map(value => {
|
1275
|
-
if (typeof value === 'boolean' || typeof value === 'number') {
|
1276
|
-
return value.toString();
|
1277
|
-
}
|
1278
|
-
return value;
|
1279
|
-
});
|
1280
|
-
}
|
1281
|
-
else {
|
1282
|
-
if (typeof value === 'boolean' || typeof value === 'number') {
|
1283
|
-
value = value.toString();
|
1284
|
-
}
|
1285
|
-
}
|
1289
|
+
value = this.undoValueTyping(value);
|
1286
1290
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
1287
1291
|
this.itemsLoaded.then(() => {
|
1288
1292
|
this.redraw();
|
@@ -1481,9 +1485,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
1481
1485
|
asString(value, options = {}) {
|
1482
1486
|
var _a;
|
1483
1487
|
value = value !== null && value !== void 0 ? value : this.getValue();
|
1484
|
-
if (options.modalPreview
|
1485
|
-
const
|
1486
|
-
return
|
1488
|
+
if (options.modalPreview) {
|
1489
|
+
const template = this.itemTemplate(value, value);
|
1490
|
+
return template;
|
1487
1491
|
}
|
1488
1492
|
//need to convert values to strings to be able to compare values with available options that are strings
|
1489
1493
|
const convertToString = (data, valueProperty) => {
|
@@ -1500,11 +1504,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
1500
1504
|
data = data.toString();
|
1501
1505
|
}
|
1502
1506
|
if (Array.isArray(data) && data.some(item => this.isBooleanOrNumber(item))) {
|
1503
|
-
data = data.map(item =>
|
1504
|
-
if (this.isBooleanOrNumber(item)) {
|
1505
|
-
item = item.toString();
|
1506
|
-
}
|
1507
|
-
});
|
1507
|
+
data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);
|
1508
1508
|
}
|
1509
1509
|
return data;
|
1510
1510
|
};
|
@@ -1102,13 +1102,47 @@ declare const _default: ({
|
|
1102
1102
|
conditional: {
|
1103
1103
|
json: {
|
1104
1104
|
and: ({
|
1105
|
-
|
1105
|
+
var: string;
|
1106
|
+
'==='?: undefined;
|
1107
|
+
'!=='?: undefined;
|
1108
|
+
or?: undefined;
|
1109
|
+
} | {
|
1110
|
+
'===': (boolean | {
|
1106
1111
|
var: string;
|
1107
|
-
}
|
1112
|
+
})[];
|
1113
|
+
var?: undefined;
|
1114
|
+
'!=='?: undefined;
|
1115
|
+
or?: undefined;
|
1108
1116
|
} | {
|
1109
1117
|
'!==': (string | {
|
1110
1118
|
var: string;
|
1111
1119
|
})[];
|
1120
|
+
var?: undefined;
|
1121
|
+
'==='?: undefined;
|
1122
|
+
or?: undefined;
|
1123
|
+
} | {
|
1124
|
+
or: ({
|
1125
|
+
'===': (string | {
|
1126
|
+
var: string;
|
1127
|
+
})[];
|
1128
|
+
and?: undefined;
|
1129
|
+
} | {
|
1130
|
+
and: ({
|
1131
|
+
'===': (string | {
|
1132
|
+
var: string;
|
1133
|
+
})[];
|
1134
|
+
'!=='?: undefined;
|
1135
|
+
} | {
|
1136
|
+
'!==': (string | {
|
1137
|
+
var: string;
|
1138
|
+
})[];
|
1139
|
+
'==='?: undefined;
|
1140
|
+
})[];
|
1141
|
+
'==='?: undefined;
|
1142
|
+
})[];
|
1143
|
+
var?: undefined;
|
1144
|
+
'==='?: undefined;
|
1145
|
+
'!=='?: undefined;
|
1112
1146
|
})[];
|
1113
1147
|
'==='?: undefined;
|
1114
1148
|
in?: undefined;
|
@@ -31,18 +31,22 @@ const calculateSelectData = (context) => {
|
|
31
31
|
const setSelectData = (context) => {
|
32
32
|
// Wait before downloadedResources will be set
|
33
33
|
setTimeout(() => {
|
34
|
-
var _a;
|
34
|
+
var _a, _b;
|
35
35
|
const { instance, data } = context;
|
36
|
-
const selectDataComponent = instance === null || instance === void 0 ? void 0 : instance.root.getComponent('selectData');
|
36
|
+
const selectDataComponent = (_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('selectData');
|
37
|
+
// clear selectData if conditions are not met or clearing default value
|
38
|
+
if (selectDataComponent && (!selectDataComponent.visible || !data.defaultValue)) {
|
39
|
+
selectDataComponent.setValue(null, { resetValue: true });
|
40
|
+
return;
|
41
|
+
}
|
37
42
|
// nothing can set if don't have downloaded resources
|
38
|
-
if (!selectDataComponent || !instance.getValue() || !((
|
43
|
+
if (!selectDataComponent || !instance.getValue() || !((_b = instance.downloadedResources) === null || _b === void 0 ? void 0 : _b.length)) {
|
39
44
|
return;
|
40
45
|
}
|
41
|
-
// if valueProperty is not provided, we have entire object
|
42
46
|
const shouldCalculateUrlData = data.dataSrc === 'url' && data.data.url && data.valueProperty;
|
43
47
|
const shouldCalculateResourceData = data.dataSrc === 'resource' && data.data.resource && data.valueProperty;
|
44
|
-
const newValue = shouldCalculateUrlData || shouldCalculateResourceData ? calculateSelectData(context) :
|
45
|
-
selectDataComponent.setValue(newValue);
|
48
|
+
const newValue = shouldCalculateUrlData || shouldCalculateResourceData ? calculateSelectData(context) : null;
|
49
|
+
selectDataComponent.setValue(newValue, { resetValue: newValue === null });
|
46
50
|
}, 0);
|
47
51
|
};
|
48
52
|
exports.default = [
|
@@ -684,10 +688,25 @@ exports.default = [
|
|
684
688
|
{
|
685
689
|
key: 'selectData',
|
686
690
|
conditional: {
|
687
|
-
json: {
|
688
|
-
|
689
|
-
{
|
690
|
-
|
691
|
+
json: {
|
692
|
+
and: [
|
693
|
+
{ var: 'data.valueProperty' },
|
694
|
+
{ '===': [{ var: 'data.lazyLoad' }, true] },
|
695
|
+
{ '!==': [{ var: 'data.widget' }, 'html5'] },
|
696
|
+
{
|
697
|
+
or: [
|
698
|
+
{ '===': [{ var: 'data.dataSrc' }, 'url'] },
|
699
|
+
{
|
700
|
+
and: [
|
701
|
+
{ '===': [{ var: 'data.dataSrc' }, 'resource'] },
|
702
|
+
// 'data' means entire object from resource will be used
|
703
|
+
{ '!==': [{ var: 'data.valueProperty' }, 'data'] },
|
704
|
+
],
|
705
|
+
}
|
706
|
+
]
|
707
|
+
}
|
708
|
+
]
|
709
|
+
},
|
691
710
|
},
|
692
711
|
},
|
693
712
|
{
|
@@ -7,10 +7,13 @@ declare namespace _default {
|
|
7
7
|
export let multiple: boolean;
|
8
8
|
export let dataSrc: string;
|
9
9
|
export namespace data {
|
10
|
-
let values: {
|
10
|
+
let values: ({
|
11
11
|
label: string;
|
12
12
|
value: string;
|
13
|
-
}
|
13
|
+
} | {
|
14
|
+
label: string;
|
15
|
+
value: number[];
|
16
|
+
})[];
|
14
17
|
let resource: string;
|
15
18
|
let json: string;
|
16
19
|
let url: string;
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -56,6 +56,14 @@ export function isMongoId(text: string): boolean;
|
|
56
56
|
* @param {*} rowData - The contextual row data for the component.
|
57
57
|
*/
|
58
58
|
export function checkCalculated(component: import('@formio/core').Component, submission: import('@formio/core').Submission, rowData: any): void;
|
59
|
+
/**
|
60
|
+
*
|
61
|
+
* @param component
|
62
|
+
* @param condition
|
63
|
+
* @param row
|
64
|
+
* @param data
|
65
|
+
* @param instance
|
66
|
+
*/
|
59
67
|
export function checkSimpleConditional(component: any, condition: any, row: any, data: any, instance: any): boolean;
|
60
68
|
/**
|
61
69
|
* Returns a components normalized value.
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -190,6 +190,11 @@ exports.checkCalculated = checkCalculated;
|
|
190
190
|
* @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
|
191
191
|
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
192
192
|
*/
|
193
|
+
/**
|
194
|
+
*
|
195
|
+
* @param conditionPaths
|
196
|
+
* @param data
|
197
|
+
*/
|
193
198
|
function getConditionalPathsRecursive(conditionPaths, data) {
|
194
199
|
let currentGlobalIndex = 0;
|
195
200
|
const conditionalPathsArray = [];
|
@@ -228,6 +233,14 @@ function getConditionalPathsRecursive(conditionPaths, data) {
|
|
228
233
|
getConditionalPaths(data);
|
229
234
|
return conditionalPathsArray;
|
230
235
|
}
|
236
|
+
/**
|
237
|
+
*
|
238
|
+
* @param component
|
239
|
+
* @param condition
|
240
|
+
* @param row
|
241
|
+
* @param data
|
242
|
+
* @param instance
|
243
|
+
*/
|
231
244
|
function checkSimpleConditional(component, condition, row, data, instance) {
|
232
245
|
if (condition.when) {
|
233
246
|
const value = getComponentActualValue(condition.when, data, row);
|
@@ -2151,7 +2151,7 @@ export default class Component extends Element {
|
|
2151
2151
|
this.addClass(this.getElement(), 'formio-modified');
|
2152
2152
|
}
|
2153
2153
|
// If we are supposed to validate on blur, then don't trigger validation yet.
|
2154
|
-
if (this.component.validateOn === 'blur') {
|
2154
|
+
if (this.component.validateOn === 'blur' || this.component.validateOn === 'submit') {
|
2155
2155
|
flags.noValidate = true;
|
2156
2156
|
}
|
2157
2157
|
if (this.component.onChange) {
|
@@ -32,6 +32,9 @@ export default class Multivalue extends Field {
|
|
32
32
|
if (this.component.storeas === 'string') {
|
33
33
|
return super.normalizeValue(value.join(this.delimiter || ''), flags);
|
34
34
|
}
|
35
|
+
if (this.component.type === 'hidden' && value.length > 1) {
|
36
|
+
return super.normalizeValue(value, flags);
|
37
|
+
}
|
35
38
|
return super.normalizeValue(value[0] || emptyValue, flags);
|
36
39
|
}
|
37
40
|
else {
|
@@ -0,0 +1,38 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let title: string;
|
3
|
+
let name: string;
|
4
|
+
let path: string;
|
5
|
+
let type: string;
|
6
|
+
let display: string;
|
7
|
+
let components: {
|
8
|
+
label: string;
|
9
|
+
tableView: boolean;
|
10
|
+
validateWhenHidden: boolean;
|
11
|
+
rowDrafts: boolean;
|
12
|
+
key: string;
|
13
|
+
validateOn: string;
|
14
|
+
type: string;
|
15
|
+
displayAsTable: boolean;
|
16
|
+
input: boolean;
|
17
|
+
components: {
|
18
|
+
label: string;
|
19
|
+
widget: string;
|
20
|
+
tableView: boolean;
|
21
|
+
data: {
|
22
|
+
values: {
|
23
|
+
label: string;
|
24
|
+
value: string;
|
25
|
+
}[];
|
26
|
+
};
|
27
|
+
validate: {
|
28
|
+
required: boolean;
|
29
|
+
};
|
30
|
+
validateWhenHidden: boolean;
|
31
|
+
validateOn: string;
|
32
|
+
key: string;
|
33
|
+
type: string;
|
34
|
+
input: boolean;
|
35
|
+
}[];
|
36
|
+
}[];
|
37
|
+
}
|
38
|
+
export default _default;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
export default {
|
2
|
+
title: "validate_submit",
|
3
|
+
name: "validate_submit",
|
4
|
+
path: "validate_submit",
|
5
|
+
type: "form",
|
6
|
+
display: "form",
|
7
|
+
components: [
|
8
|
+
{
|
9
|
+
label: "Edit Grid",
|
10
|
+
tableView: false,
|
11
|
+
validateWhenHidden: false,
|
12
|
+
rowDrafts: false,
|
13
|
+
key: "editGrid",
|
14
|
+
validateOn: 'submit',
|
15
|
+
type: "editgrid",
|
16
|
+
displayAsTable: false,
|
17
|
+
input: true,
|
18
|
+
components: [
|
19
|
+
{
|
20
|
+
label: "Select",
|
21
|
+
widget: "choicesjs",
|
22
|
+
tableView: true,
|
23
|
+
data: {
|
24
|
+
values: [
|
25
|
+
{
|
26
|
+
label: "one",
|
27
|
+
value: "one",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
label: "two",
|
31
|
+
value: "two",
|
32
|
+
},
|
33
|
+
],
|
34
|
+
},
|
35
|
+
validate: {
|
36
|
+
required: true,
|
37
|
+
},
|
38
|
+
validateWhenHidden: false,
|
39
|
+
validateOn: 'submit',
|
40
|
+
key: "select1",
|
41
|
+
type: "select",
|
42
|
+
input: true,
|
43
|
+
},
|
44
|
+
{
|
45
|
+
label: "Select",
|
46
|
+
widget: "choicesjs",
|
47
|
+
tableView: true,
|
48
|
+
data: {
|
49
|
+
values: [
|
50
|
+
{
|
51
|
+
label: "three",
|
52
|
+
value: "three",
|
53
|
+
},
|
54
|
+
{
|
55
|
+
label: "four",
|
56
|
+
value: "four",
|
57
|
+
},
|
58
|
+
],
|
59
|
+
},
|
60
|
+
validate: {
|
61
|
+
required: true,
|
62
|
+
},
|
63
|
+
validateWhenHidden: false,
|
64
|
+
validateOn: 'submit',
|
65
|
+
key: "select2",
|
66
|
+
type: "select",
|
67
|
+
input: true,
|
68
|
+
},
|
69
|
+
],
|
70
|
+
},
|
71
|
+
],
|
72
|
+
};
|
@@ -1,6 +1,12 @@
|
|
1
1
|
import comp1 from './comp1';
|
2
2
|
import comp2 from './comp2';
|
3
3
|
import comp3 from './comp3';
|
4
|
+
import comp4 from './comp4';
|
5
|
+
import comp5 from './comp5';
|
6
|
+
import comp6 from './comp6';
|
7
|
+
import comp7 from './comp7';
|
8
|
+
import comp8 from './comp8';
|
9
|
+
import comp9 from './comp9';
|
4
10
|
import comp10 from './comp10';
|
5
11
|
import comp11 from './comp11';
|
6
12
|
import comp12 from './comp12';
|
@@ -8,13 +14,8 @@ import comp13 from './comp13';
|
|
8
14
|
import comp14 from './comp14';
|
9
15
|
import comp15 from './comp15';
|
10
16
|
import comp16 from './comp16';
|
11
|
-
import
|
12
|
-
import comp5 from './comp5';
|
13
|
-
import comp6 from './comp6';
|
14
|
-
import comp7 from './comp7';
|
15
|
-
import comp8 from './comp8';
|
16
|
-
import comp9 from './comp9';
|
17
|
+
import comp18 from './comp18';
|
17
18
|
import compOpenWhenEmpty from './comp-openWhenEmpty';
|
18
19
|
import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
|
19
20
|
import compWithCustomDefaultValue from './comp-with-custom-default-value';
|
20
|
-
export { comp1, comp2, comp3,
|
21
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
@@ -14,7 +14,10 @@ import comp13 from './comp13';
|
|
14
14
|
import comp14 from './comp14';
|
15
15
|
import comp15 from './comp15';
|
16
16
|
import comp16 from './comp16';
|
17
|
+
import comp17 from './comp17';
|
18
|
+
import comp18 from './comp18';
|
17
19
|
import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
|
18
20
|
import compOpenWhenEmpty from './comp-openWhenEmpty';
|
19
21
|
import compWithCustomDefaultValue from './comp-with-custom-default-value';
|
20
|
-
|
22
|
+
import compTestEvents from './comp-test-events';
|
23
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|