@formio/js 5.0.0-rc.80 → 5.0.0-rc.82
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -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 @@ export default class SelectComponent extends ListComponent {
|
|
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() && !_.isObject(data.data)) ? { data: data } :
|
243
|
+
label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : data, value)
|
245
244
|
};
|
246
245
|
}
|
247
246
|
itemTemplate(data, value) {
|
@@ -258,7 +257,7 @@ export default class SelectComponent extends ListComponent {
|
|
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 && _.isArray(this.dataValue) ? this.dataValue.find((val) => value === val) : (this.dataValue === value)) {
|
260
|
+
if (this.component.multiple && _.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?._id ? value._id.toString() : value;
|
@@ -1288,6 +1287,23 @@ export default class SelectComponent extends ListComponent {
|
|
1288
1287
|
}
|
1289
1288
|
return changed;
|
1290
1289
|
}
|
1290
|
+
undoValueTyping(value) {
|
1291
|
+
let untypedValue = value;
|
1292
|
+
if (this.component.multiple && Array.isArray(value)) {
|
1293
|
+
untypedValue = value.map(v => {
|
1294
|
+
if (typeof v === 'boolean' || typeof v === 'number') {
|
1295
|
+
return v.toString();
|
1296
|
+
}
|
1297
|
+
return v;
|
1298
|
+
});
|
1299
|
+
}
|
1300
|
+
else {
|
1301
|
+
if (typeof value === 'boolean' || typeof value === 'number') {
|
1302
|
+
untypedValue = value.toString();
|
1303
|
+
}
|
1304
|
+
}
|
1305
|
+
return untypedValue;
|
1306
|
+
}
|
1291
1307
|
setValue(value, flags = {}) {
|
1292
1308
|
const previousValue = this.dataValue;
|
1293
1309
|
const changed = this.updateValue(value, flags);
|
@@ -1298,19 +1314,7 @@ export default class SelectComponent extends ListComponent {
|
|
1298
1314
|
const hasPreviousValue = !this.isEmpty(previousValue);
|
1299
1315
|
const hasValue = !this.isEmpty(value);
|
1300
1316
|
// Undo typing when searching to set the value.
|
1301
|
-
|
1302
|
-
value = value.map(value => {
|
1303
|
-
if (typeof value === 'boolean' || typeof value === 'number') {
|
1304
|
-
return value.toString();
|
1305
|
-
}
|
1306
|
-
return value;
|
1307
|
-
});
|
1308
|
-
}
|
1309
|
-
else {
|
1310
|
-
if (typeof value === 'boolean' || typeof value === 'number') {
|
1311
|
-
value = value.toString();
|
1312
|
-
}
|
1313
|
-
}
|
1317
|
+
value = this.undoValueTyping(value);
|
1314
1318
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
1315
1319
|
this.itemsLoaded.then(() => {
|
1316
1320
|
this.redraw();
|
@@ -1508,9 +1512,9 @@ export default class SelectComponent extends ListComponent {
|
|
1508
1512
|
}
|
1509
1513
|
asString(value, options = {}) {
|
1510
1514
|
value = value ?? this.getValue();
|
1511
|
-
if (options.modalPreview
|
1512
|
-
const
|
1513
|
-
return
|
1515
|
+
if (options.modalPreview) {
|
1516
|
+
const template = this.itemTemplate(value, value);
|
1517
|
+
return template;
|
1514
1518
|
}
|
1515
1519
|
//need to convert values to strings to be able to compare values with available options that are strings
|
1516
1520
|
const convertToString = (data, valueProperty) => {
|
@@ -1527,11 +1531,7 @@ export default class SelectComponent extends ListComponent {
|
|
1527
1531
|
data = data.toString();
|
1528
1532
|
}
|
1529
1533
|
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
|
-
});
|
1534
|
+
data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);
|
1535
1535
|
}
|
1536
1536
|
return data;
|
1537
1537
|
};
|
@@ -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;
|
package/lib/mjs/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/mjs/utils/utils.js
CHANGED
@@ -145,6 +145,11 @@ export function checkCalculated(component, submission, rowData) {
|
|
145
145
|
* @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
|
146
146
|
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
147
147
|
*/
|
148
|
+
/**
|
149
|
+
*
|
150
|
+
* @param conditionPaths
|
151
|
+
* @param data
|
152
|
+
*/
|
148
153
|
function getConditionalPathsRecursive(conditionPaths, data) {
|
149
154
|
let currentGlobalIndex = 0;
|
150
155
|
const conditionalPathsArray = [];
|
@@ -183,6 +188,14 @@ function getConditionalPathsRecursive(conditionPaths, data) {
|
|
183
188
|
getConditionalPaths(data);
|
184
189
|
return conditionalPathsArray;
|
185
190
|
}
|
191
|
+
/**
|
192
|
+
*
|
193
|
+
* @param component
|
194
|
+
* @param condition
|
195
|
+
* @param row
|
196
|
+
* @param data
|
197
|
+
* @param instance
|
198
|
+
*/
|
186
199
|
export function checkSimpleConditional(component, condition, row, data, instance) {
|
187
200
|
if (condition.when) {
|
188
201
|
const value = getComponentActualValue(condition.when, data, row);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.0.0-rc.
|
3
|
+
"version": "5.0.0-rc.82",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"dependencies": {
|
82
82
|
"@formio/bootstrap": "3.0.0-rc.37",
|
83
83
|
"@formio/choices.js": "^10.2.1",
|
84
|
-
"@formio/core": "2.
|
84
|
+
"@formio/core": "2.3.0-rc.3",
|
85
85
|
"@formio/text-mask-addons": "^3.8.0-formio.2",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|