@formio/js 5.0.0-dev.5804.10012e4 → 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 +1 -5
- 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/mjs/components/select/Select.js +1 -5
- 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/package.json +1 -1
|
@@ -1500,11 +1500,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1500
1500
|
data = data.toString();
|
|
1501
1501
|
}
|
|
1502
1502
|
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
|
-
});
|
|
1503
|
+
data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);
|
|
1508
1504
|
}
|
|
1509
1505
|
return data;
|
|
1510
1506
|
};
|
|
@@ -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;
|
|
@@ -1527,11 +1527,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1527
1527
|
data = data.toString();
|
|
1528
1528
|
}
|
|
1529
1529
|
if (Array.isArray(data) && data.some(item => this.isBooleanOrNumber(item))) {
|
|
1530
|
-
data = data.map(item =>
|
|
1531
|
-
if (this.isBooleanOrNumber(item)) {
|
|
1532
|
-
item = item.toString();
|
|
1533
|
-
}
|
|
1534
|
-
});
|
|
1530
|
+
data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);
|
|
1535
1531
|
}
|
|
1536
1532
|
return data;
|
|
1537
1533
|
};
|
|
@@ -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
|
{
|
|
@@ -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;
|