@formio/js 5.0.0-dev.5803.ec5a0e0 → 5.0.0-dev.5807.065a0ba
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/Changelog.md +1 -0
- package/dist/formio.form.js +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +2 -2
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/select/Select.js +2 -1
- 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/mjs/components/select/Select.js +2 -1
- 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/package.json +1 -1
|
@@ -257,7 +257,8 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
257
257
|
const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
|
258
258
|
return this.sanitize(value, this.shouldSanitizeValue);
|
|
259
259
|
}
|
|
260
|
-
if (this.component.multiple
|
|
260
|
+
if (this.component.multiple
|
|
261
|
+
&& lodash_1.default.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === value)) {
|
|
261
262
|
const selectData = this.selectData;
|
|
262
263
|
if (selectData) {
|
|
263
264
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
|
@@ -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
|
{
|
|
@@ -257,7 +257,8 @@ export default class SelectComponent extends ListComponent {
|
|
|
257
257
|
const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
|
258
258
|
return this.sanitize(value, this.shouldSanitizeValue);
|
|
259
259
|
}
|
|
260
|
-
if (this.component.multiple
|
|
260
|
+
if (this.component.multiple
|
|
261
|
+
&& _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === value)) {
|
|
261
262
|
const selectData = this.selectData;
|
|
262
263
|
if (selectData) {
|
|
263
264
|
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
|
|
@@ -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;
|
|
@@ -27,16 +27,20 @@ const setSelectData = (context) => {
|
|
|
27
27
|
// Wait before downloadedResources will be set
|
|
28
28
|
setTimeout(() => {
|
|
29
29
|
const { instance, data } = context;
|
|
30
|
-
const selectDataComponent = instance?.root
|
|
30
|
+
const selectDataComponent = instance?.root?.getComponent('selectData');
|
|
31
|
+
// clear selectData if conditions are not met or clearing default value
|
|
32
|
+
if (selectDataComponent && (!selectDataComponent.visible || !data.defaultValue)) {
|
|
33
|
+
selectDataComponent.setValue(null, { resetValue: true });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
31
36
|
// nothing can set if don't have downloaded resources
|
|
32
37
|
if (!selectDataComponent || !instance.getValue() || !instance.downloadedResources?.length) {
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
35
|
-
// if valueProperty is not provided, we have entire object
|
|
36
40
|
const shouldCalculateUrlData = data.dataSrc === 'url' && data.data.url && data.valueProperty;
|
|
37
41
|
const shouldCalculateResourceData = data.dataSrc === 'resource' && data.data.resource && data.valueProperty;
|
|
38
|
-
const newValue = shouldCalculateUrlData || shouldCalculateResourceData ? calculateSelectData(context) :
|
|
39
|
-
selectDataComponent.setValue(newValue);
|
|
42
|
+
const newValue = shouldCalculateUrlData || shouldCalculateResourceData ? calculateSelectData(context) : null;
|
|
43
|
+
selectDataComponent.setValue(newValue, { resetValue: newValue === null });
|
|
40
44
|
}, 0);
|
|
41
45
|
};
|
|
42
46
|
export default [
|
|
@@ -678,10 +682,25 @@ export default [
|
|
|
678
682
|
{
|
|
679
683
|
key: 'selectData',
|
|
680
684
|
conditional: {
|
|
681
|
-
json: {
|
|
682
|
-
|
|
683
|
-
{
|
|
684
|
-
|
|
685
|
+
json: {
|
|
686
|
+
and: [
|
|
687
|
+
{ var: 'data.valueProperty' },
|
|
688
|
+
{ '===': [{ var: 'data.lazyLoad' }, true] },
|
|
689
|
+
{ '!==': [{ var: 'data.widget' }, 'html5'] },
|
|
690
|
+
{
|
|
691
|
+
or: [
|
|
692
|
+
{ '===': [{ var: 'data.dataSrc' }, 'url'] },
|
|
693
|
+
{
|
|
694
|
+
and: [
|
|
695
|
+
{ '===': [{ var: 'data.dataSrc' }, 'resource'] },
|
|
696
|
+
// 'data' means entire object from resource will be used
|
|
697
|
+
{ '!==': [{ var: 'data.valueProperty' }, 'data'] },
|
|
698
|
+
],
|
|
699
|
+
}
|
|
700
|
+
]
|
|
701
|
+
}
|
|
702
|
+
]
|
|
703
|
+
},
|
|
685
704
|
},
|
|
686
705
|
},
|
|
687
706
|
{
|