@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.
@@ -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
- } | null)[];
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() || !((_a = instance.downloadedResources) === null || _a === void 0 ? void 0 : _a.length)) {
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) : undefined;
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: { 'and': [
688
- { '!==': [{ var: 'data.valueProperty' }, null] },
689
- { '!==': [{ var: 'data.valueProperty' }, ''] },
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;
@@ -21,6 +21,10 @@ exports.default = {
21
21
  }, {
22
22
  'label': 'test',
23
23
  'value': 'test'
24
+ },
25
+ {
26
+ 'label': '1',
27
+ 'value': [1, 2, 3]
24
28
  }],
25
29
  'resource': '',
26
30
  'json': '',
@@ -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
- } | null)[];
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.getComponent('selectData');
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) : undefined;
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: { 'and': [
682
- { '!==': [{ var: 'data.valueProperty' }, null] },
683
- { '!==': [{ var: 'data.valueProperty' }, ''] },
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;
@@ -19,6 +19,10 @@ export default {
19
19
  }, {
20
20
  'label': 'test',
21
21
  'value': 'test'
22
+ },
23
+ {
24
+ 'label': '1',
25
+ 'value': [1, 2, 3]
22
26
  }],
23
27
  'resource': '',
24
28
  'json': '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5804.10012e4",
3
+ "version": "5.0.0-dev.5807.065a0ba",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {