@formio/js 5.0.0-dev.5867.8552ccf → 5.0.0-dev.5871.544083b
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 +7 -7
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +7 -7
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Webform.js +1 -1
- package/lib/cjs/components/_classes/component/Component.js +4 -6
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/cjs/components/editgrid/EditGrid.js +6 -5
- package/lib/cjs/components/radio/Radio.d.ts +1 -0
- package/lib/cjs/components/radio/Radio.js +13 -4
- package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -2
- package/lib/cjs/components/textarea/TextArea.d.ts +4 -4
- package/lib/cjs/components/textarea/TextArea.js +4 -4
- package/lib/mjs/Webform.js +1 -1
- package/lib/mjs/components/_classes/component/Component.js +4 -6
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/mjs/components/editgrid/EditGrid.js +6 -5
- package/lib/mjs/components/radio/Radio.d.ts +1 -0
- package/lib/mjs/components/radio/Radio.js +13 -4
- package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -2
- package/lib/mjs/components/textarea/TextArea.d.ts +4 -4
- package/lib/mjs/components/textarea/TextArea.js +4 -4
- package/package.json +2 -2
package/lib/cjs/Webform.js
CHANGED
|
@@ -1533,7 +1533,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1533
1533
|
return;
|
|
1534
1534
|
}
|
|
1535
1535
|
const captchaComponent = [];
|
|
1536
|
-
|
|
1536
|
+
(0, formUtils_1.eachComponent)(this.components, (component) => {
|
|
1537
1537
|
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
|
1538
1538
|
captchaComponent.push(component);
|
|
1539
1539
|
}
|
|
@@ -2962,14 +2962,12 @@ class Component extends Element_1.default {
|
|
|
2962
2962
|
if (flags.silentCheck) {
|
|
2963
2963
|
return [];
|
|
2964
2964
|
}
|
|
2965
|
+
let isDirty = this.dirty || flags.dirty;
|
|
2965
2966
|
if (this.options.alwaysDirty) {
|
|
2966
|
-
|
|
2967
|
+
isDirty = true;
|
|
2967
2968
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
}
|
|
2971
|
-
this.setDirty(flags.dirty);
|
|
2972
|
-
return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
|
|
2969
|
+
this.setDirty(isDirty);
|
|
2970
|
+
return this.setComponentValidity(errors, isDirty, flags.silentCheck, flags.fromSubmission);
|
|
2973
2971
|
}
|
|
2974
2972
|
/**
|
|
2975
2973
|
* Perform a component validation.
|
|
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
89
89
|
hasOpenRows(): any;
|
|
90
90
|
getAttachedData(data?: null): any;
|
|
91
91
|
shouldValidateDraft(editRow: any): any;
|
|
92
|
-
shouldValidateRow(editRow: any, dirty: any): any;
|
|
93
|
-
validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
|
|
92
|
+
shouldValidateRow(editRow: any, dirty: any, fromSubmission: any): any;
|
|
93
|
+
validateRow(editRow: any, dirty: any, forceSilentCheck: any, fromSubmission: any): any;
|
|
94
94
|
showRowErrorAlerts(editRow: any, errors: any): void;
|
|
95
95
|
/**
|
|
96
96
|
* @returns {boolean} - Return that this component processes its own validation.
|
|
@@ -983,17 +983,18 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
983
983
|
!this.hasOpenRows()) ||
|
|
984
984
|
((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted);
|
|
985
985
|
}
|
|
986
|
-
shouldValidateRow(editRow, dirty) {
|
|
986
|
+
shouldValidateRow(editRow, dirty, fromSubmission) {
|
|
987
987
|
return this.shouldValidateDraft(editRow) ||
|
|
988
988
|
editRow.state === EditRowState.Saving ||
|
|
989
989
|
editRow.state === EditRowState.Editing ||
|
|
990
990
|
editRow.alerts ||
|
|
991
|
+
fromSubmission ||
|
|
991
992
|
dirty;
|
|
992
993
|
}
|
|
993
|
-
validateRow(editRow, dirty, forceSilentCheck) {
|
|
994
|
+
validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
|
|
994
995
|
var _a;
|
|
995
996
|
editRow.errors = [];
|
|
996
|
-
if (this.shouldValidateRow(editRow, dirty)) {
|
|
997
|
+
if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
|
|
997
998
|
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
|
998
999
|
const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
|
|
999
1000
|
const editGridValue = lodash_1.default.get(rootValue, this.path, []);
|
|
@@ -1065,7 +1066,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
1065
1066
|
}
|
|
1066
1067
|
checkComponentValidity(data, dirty, row, options = {}, errors = []) {
|
|
1067
1068
|
var _a, _b;
|
|
1068
|
-
const { silentCheck } = options;
|
|
1069
|
+
const { silentCheck, fromSubmission } = options;
|
|
1069
1070
|
const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
|
|
1070
1071
|
// If super tells us that component invalid and there is no need to update alerts, just return false
|
|
1071
1072
|
if (!superValid && (!this.alert && !this.hasOpenRows())) {
|
|
@@ -1075,7 +1076,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
1075
1076
|
const allRowErrors = [];
|
|
1076
1077
|
this.editRows.forEach((editRow, index) => {
|
|
1077
1078
|
// Trigger all errors on the row.
|
|
1078
|
-
const rowErrors = this.validateRow(editRow, dirty, silentCheck);
|
|
1079
|
+
const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);
|
|
1079
1080
|
errors.push(...rowErrors);
|
|
1080
1081
|
allRowErrors.push(...rowErrors);
|
|
1081
1082
|
if (this.rowRefs) {
|
|
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
21
21
|
get isRadio(): boolean;
|
|
22
22
|
get optionSelectedClass(): string;
|
|
23
23
|
get listData(): any;
|
|
24
|
+
get selectMetadata(): any;
|
|
24
25
|
templateData: {} | undefined;
|
|
25
26
|
triggerUpdate: ((...args: any[]) => any) | undefined;
|
|
26
27
|
itemsLoadedResolve: ((value: any) => void) | undefined;
|
|
@@ -109,6 +109,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
109
109
|
const listData = lodash_1.default.get(this.root, 'submission.metadata.listData', {});
|
|
110
110
|
return lodash_1.default.get(listData, this.path);
|
|
111
111
|
}
|
|
112
|
+
get selectMetadata() {
|
|
113
|
+
return super.selectData;
|
|
114
|
+
}
|
|
115
|
+
get selectData() {
|
|
116
|
+
return this.selectMetadata || this.component.selectData;
|
|
117
|
+
}
|
|
112
118
|
init() {
|
|
113
119
|
super.init();
|
|
114
120
|
this.templateData = {};
|
|
@@ -244,12 +250,15 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
244
250
|
else if (!lodash_1.default.isString(value)) {
|
|
245
251
|
value = lodash_1.default.toString(value);
|
|
246
252
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
253
|
+
const shouldUseSelectData = (options.modalPreview || this.inDataTable)
|
|
254
|
+
&& this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
|
|
255
|
+
if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
|
|
249
256
|
return value;
|
|
250
257
|
}
|
|
251
|
-
const values =
|
|
252
|
-
const option =
|
|
258
|
+
const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
|
|
259
|
+
const option = !(values === null || values === void 0 ? void 0 : values.length) && shouldUseSelectData ? {
|
|
260
|
+
label: this.itemTemplate(this.selectData),
|
|
261
|
+
} : lodash_1.default.find(values, (v) => v.value === value);
|
|
253
262
|
if (!value) {
|
|
254
263
|
return lodash_1.default.get(option, 'label', '');
|
|
255
264
|
}
|
|
@@ -166,12 +166,19 @@ class SelectBoxesComponent extends Radio_1.default {
|
|
|
166
166
|
return changed;
|
|
167
167
|
}
|
|
168
168
|
getValueAsString(value, options = {}) {
|
|
169
|
+
var _a, _b;
|
|
169
170
|
if (!value) {
|
|
170
171
|
return '';
|
|
171
172
|
}
|
|
172
173
|
if (this.isSelectURL) {
|
|
173
|
-
if (options.modalPreview
|
|
174
|
-
|
|
174
|
+
if (options.modalPreview || this.options.readOnly || this.inDataTable) {
|
|
175
|
+
const checkedItems = lodash_1.default.keys(lodash_1.default.pickBy(value, (val) => val));
|
|
176
|
+
if (((_a = this.selectData) === null || _a === void 0 ? void 0 : _a.length) === checkedItems.length) {
|
|
177
|
+
return this.selectData.map(item => this.itemTemplate(item)).join(', ');
|
|
178
|
+
}
|
|
179
|
+
else if ((_b = this.loadedOptions) === null || _b === void 0 ? void 0 : _b.length) {
|
|
180
|
+
return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
|
|
181
|
+
}
|
|
175
182
|
}
|
|
176
183
|
return (0, lodash_1.default)(value).pickBy((val) => val).keys().join(', ');
|
|
177
184
|
}
|
|
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
|
|
|
20
20
|
setReadOnlyValue(value: any, index: any): void;
|
|
21
21
|
get isJsonValue(): any;
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
24
|
+
* @param {*} value - The value to normalize
|
|
25
|
+
* @returns {*} - Returns the normalized value
|
|
26
|
+
*/
|
|
27
27
|
normalizeValue(value: any): any;
|
|
28
28
|
normalizeSingleValue(value: any): any;
|
|
29
29
|
setConvertedValue(value: any, index: any): any;
|
|
@@ -310,10 +310,10 @@ class TextAreaComponent extends TextField_1.default {
|
|
|
310
310
|
return this.component.as && this.component.as === 'json';
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
314
|
+
* @param {*} value - The value to normalize
|
|
315
|
+
* @returns {*} - Returns the normalized value
|
|
316
|
+
*/
|
|
317
317
|
normalizeValue(value) {
|
|
318
318
|
if (this.component.multiple && Array.isArray(value)) {
|
|
319
319
|
return value.map((singleValue) => this.normalizeSingleValue(singleValue));
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -1536,7 +1536,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
1536
1536
|
return;
|
|
1537
1537
|
}
|
|
1538
1538
|
const captchaComponent = [];
|
|
1539
|
-
this.
|
|
1539
|
+
eachComponent(this.components, (component) => {
|
|
1540
1540
|
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
|
1541
1541
|
captchaComponent.push(component);
|
|
1542
1542
|
}
|
|
@@ -2926,14 +2926,12 @@ export default class Component extends Element {
|
|
|
2926
2926
|
if (flags.silentCheck) {
|
|
2927
2927
|
return [];
|
|
2928
2928
|
}
|
|
2929
|
+
let isDirty = this.dirty || flags.dirty;
|
|
2929
2930
|
if (this.options.alwaysDirty) {
|
|
2930
|
-
|
|
2931
|
+
isDirty = true;
|
|
2931
2932
|
}
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
}
|
|
2935
|
-
this.setDirty(flags.dirty);
|
|
2936
|
-
return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
|
|
2933
|
+
this.setDirty(isDirty);
|
|
2934
|
+
return this.setComponentValidity(errors, isDirty, flags.silentCheck, flags.fromSubmission);
|
|
2937
2935
|
}
|
|
2938
2936
|
/**
|
|
2939
2937
|
* Perform a component validation.
|
|
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
89
89
|
hasOpenRows(): any;
|
|
90
90
|
getAttachedData(data?: null): any;
|
|
91
91
|
shouldValidateDraft(editRow: any): any;
|
|
92
|
-
shouldValidateRow(editRow: any, dirty: any): any;
|
|
93
|
-
validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
|
|
92
|
+
shouldValidateRow(editRow: any, dirty: any, fromSubmission: any): any;
|
|
93
|
+
validateRow(editRow: any, dirty: any, forceSilentCheck: any, fromSubmission: any): any;
|
|
94
94
|
showRowErrorAlerts(editRow: any, errors: any): void;
|
|
95
95
|
/**
|
|
96
96
|
* @returns {boolean} - Return that this component processes its own validation.
|
|
@@ -973,16 +973,17 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
973
973
|
!this.hasOpenRows()) ||
|
|
974
974
|
this.root?.submitted;
|
|
975
975
|
}
|
|
976
|
-
shouldValidateRow(editRow, dirty) {
|
|
976
|
+
shouldValidateRow(editRow, dirty, fromSubmission) {
|
|
977
977
|
return this.shouldValidateDraft(editRow) ||
|
|
978
978
|
editRow.state === EditRowState.Saving ||
|
|
979
979
|
editRow.state === EditRowState.Editing ||
|
|
980
980
|
editRow.alerts ||
|
|
981
|
+
fromSubmission ||
|
|
981
982
|
dirty;
|
|
982
983
|
}
|
|
983
|
-
validateRow(editRow, dirty, forceSilentCheck) {
|
|
984
|
+
validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
|
|
984
985
|
editRow.errors = [];
|
|
985
|
-
if (this.shouldValidateRow(editRow, dirty)) {
|
|
986
|
+
if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
|
|
986
987
|
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
|
987
988
|
const rootValue = fastCloneDeep(this.rootValue);
|
|
988
989
|
const editGridValue = _.get(rootValue, this.path, []);
|
|
@@ -1053,7 +1054,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1053
1054
|
return true;
|
|
1054
1055
|
}
|
|
1055
1056
|
checkComponentValidity(data, dirty, row, options = {}, errors = []) {
|
|
1056
|
-
const { silentCheck } = options;
|
|
1057
|
+
const { silentCheck, fromSubmission } = options;
|
|
1057
1058
|
const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
|
|
1058
1059
|
// If super tells us that component invalid and there is no need to update alerts, just return false
|
|
1059
1060
|
if (!superValid && (!this.alert && !this.hasOpenRows())) {
|
|
@@ -1063,7 +1064,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1063
1064
|
const allRowErrors = [];
|
|
1064
1065
|
this.editRows.forEach((editRow, index) => {
|
|
1065
1066
|
// Trigger all errors on the row.
|
|
1066
|
-
const rowErrors = this.validateRow(editRow, dirty, silentCheck);
|
|
1067
|
+
const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);
|
|
1067
1068
|
errors.push(...rowErrors);
|
|
1068
1069
|
allRowErrors.push(...rowErrors);
|
|
1069
1070
|
if (this.rowRefs) {
|
|
@@ -21,6 +21,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
21
21
|
get isRadio(): boolean;
|
|
22
22
|
get optionSelectedClass(): string;
|
|
23
23
|
get listData(): any;
|
|
24
|
+
get selectMetadata(): any;
|
|
24
25
|
templateData: {} | undefined;
|
|
25
26
|
triggerUpdate: ((...args: any[]) => any) | undefined;
|
|
26
27
|
itemsLoadedResolve: ((value: any) => void) | undefined;
|
|
@@ -109,6 +109,12 @@ export default class RadioComponent extends ListComponent {
|
|
|
109
109
|
const listData = _.get(this.root, 'submission.metadata.listData', {});
|
|
110
110
|
return _.get(listData, this.path);
|
|
111
111
|
}
|
|
112
|
+
get selectMetadata() {
|
|
113
|
+
return super.selectData;
|
|
114
|
+
}
|
|
115
|
+
get selectData() {
|
|
116
|
+
return this.selectMetadata || this.component.selectData;
|
|
117
|
+
}
|
|
112
118
|
init() {
|
|
113
119
|
super.init();
|
|
114
120
|
this.templateData = {};
|
|
@@ -244,12 +250,15 @@ export default class RadioComponent extends ListComponent {
|
|
|
244
250
|
else if (!_.isString(value)) {
|
|
245
251
|
value = _.toString(value);
|
|
246
252
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
253
|
+
const shouldUseSelectData = (options.modalPreview || this.inDataTable)
|
|
254
|
+
&& this.component.dataSrc === 'url' && (this.loadedOptions.length || this.selectData);
|
|
255
|
+
if (this.component.dataSrc !== 'values' && !shouldUseSelectData) {
|
|
249
256
|
return value;
|
|
250
257
|
}
|
|
251
|
-
const values =
|
|
252
|
-
const option =
|
|
258
|
+
const values = shouldUseSelectData ? this.loadedOptions : this.component.values;
|
|
259
|
+
const option = !values?.length && shouldUseSelectData ? {
|
|
260
|
+
label: this.itemTemplate(this.selectData),
|
|
261
|
+
} : _.find(values, (v) => v.value === value);
|
|
253
262
|
if (!value) {
|
|
254
263
|
return _.get(option, 'label', '');
|
|
255
264
|
}
|
|
@@ -172,8 +172,14 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
172
172
|
return '';
|
|
173
173
|
}
|
|
174
174
|
if (this.isSelectURL) {
|
|
175
|
-
if (options.modalPreview
|
|
176
|
-
|
|
175
|
+
if (options.modalPreview || this.options.readOnly || this.inDataTable) {
|
|
176
|
+
const checkedItems = _.keys(_.pickBy(value, (val) => val));
|
|
177
|
+
if (this.selectData?.length === checkedItems.length) {
|
|
178
|
+
return this.selectData.map(item => this.itemTemplate(item)).join(', ');
|
|
179
|
+
}
|
|
180
|
+
else if (this.loadedOptions?.length) {
|
|
181
|
+
return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
|
|
182
|
+
}
|
|
177
183
|
}
|
|
178
184
|
return _(value).pickBy((val) => val).keys().join(', ');
|
|
179
185
|
}
|
|
@@ -20,10 +20,10 @@ export default class TextAreaComponent extends TextFieldComponent {
|
|
|
20
20
|
setReadOnlyValue(value: any, index: any): void;
|
|
21
21
|
get isJsonValue(): any;
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
24
|
+
* @param {*} value - The value to normalize
|
|
25
|
+
* @returns {*} - Returns the normalized value
|
|
26
|
+
*/
|
|
27
27
|
normalizeValue(value: any): any;
|
|
28
28
|
normalizeSingleValue(value: any): any;
|
|
29
29
|
setConvertedValue(value: any, index: any): any;
|
|
@@ -305,10 +305,10 @@ export default class TextAreaComponent extends TextFieldComponent {
|
|
|
305
305
|
return this.component.as && this.component.as === 'json';
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
|
309
|
+
* @param {*} value - The value to normalize
|
|
310
|
+
* @returns {*} - Returns the normalized value
|
|
311
|
+
*/
|
|
312
312
|
normalizeValue(value) {
|
|
313
313
|
if (this.component.multiple && Array.isArray(value)) {
|
|
314
314
|
return value.map((singleValue) => this.normalizeSingleValue(singleValue));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.5871.544083b",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
|
|
84
84
|
"@formio/choices.js": "^10.2.1",
|
|
85
|
-
"@formio/core": "
|
|
85
|
+
"@formio/core": "2.3.0-dev.160.cabaa43",
|
|
86
86
|
"@formio/text-mask-addons": "^3.8.0-formio.2",
|
|
87
87
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
|
88
88
|
"abortcontroller-polyfill": "^1.7.5",
|