@formio/js 5.0.0-dev.5780.6637ffb → 5.0.0-dev.5789.2e50e03

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.
@@ -1245,10 +1245,10 @@ class Webform extends NestedDataComponent_1.default {
1245
1245
  }
1246
1246
  this.checkData(value.data, flags);
1247
1247
  const shouldValidate = !flags.noValidate ||
1248
- flags.fromIframe ||
1248
+ flags.fromIFrame ||
1249
1249
  (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1250
1250
  const errors = shouldValidate
1251
- ? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: flags.fromIframe && this.submitted ? false : flags.noValidate, process: 'change' }))
1251
+ ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: "change" }))
1252
1252
  : [];
1253
1253
  value.isValid = errors.length === 0;
1254
1254
  this.loading = false;
@@ -3024,7 +3024,7 @@ class Component extends Element_1.default {
3024
3024
  this.parent.childErrors.push(...errors);
3025
3025
  }
3026
3026
  else {
3027
- lodash_1.default.remove(this.parent.childErrors, (err) => { var _a, _b; return (((_a = err === null || err === void 0 ? void 0 : err.component) === null || _a === void 0 ? void 0 : _a.key) || ((_b = err === null || err === void 0 ? void 0 : err.context) === null || _b === void 0 ? void 0 : _b.key)) === this.component.key; });
3027
+ lodash_1.default.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
3028
3028
  }
3029
3029
  }
3030
3030
  this.showValidationErrors(errors, data, row, flags);
@@ -3040,7 +3040,7 @@ class Component extends Element_1.default {
3040
3040
  this.parent.childErrors.push(...errors);
3041
3041
  }
3042
3042
  else {
3043
- lodash_1.default.remove(this.parent.childErrors, (err) => { var _a, _b; return (((_a = err === null || err === void 0 ? void 0 : err.component) === null || _a === void 0 ? void 0 : _a.key) || ((_b = err === null || err === void 0 ? void 0 : err.context) === null || _b === void 0 ? void 0 : _b.key)) === this.component.key; });
3043
+ lodash_1.default.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
3044
3044
  }
3045
3045
  }
3046
3046
  return errors.length === 0;
@@ -1,6 +1,5 @@
1
1
  export default class Multivalue extends Field {
2
2
  get addAnother(): string;
3
- useWrapper(): any;
4
3
  /**
5
4
  * @returns {Field} - The created field.
6
5
  */
@@ -6,12 +6,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Field_1 = __importDefault(require("../field/Field"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  class Multivalue extends Field_1.default {
9
- get dataValue() {
10
- const parent = super.dataValue;
11
- if (!parent && this.component.multiple) {
12
- return [];
9
+ /**
10
+ * Normalize values coming into updateValue.
11
+ * @param {*} value - The value to normalize before setting.
12
+ * @returns {*} - The normalized value.
13
+ */
14
+ normalizeValue(value) {
15
+ if (this.component.multiple) {
16
+ if (Array.isArray(value)) {
17
+ if (value.length === 0) {
18
+ return [this.emptyValue];
19
+ }
20
+ if (this.component.storeas === 'array') {
21
+ return super.normalizeValue([value]);
22
+ }
23
+ return super.normalizeValue(value);
24
+ }
25
+ else {
26
+ return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
27
+ }
28
+ }
29
+ else {
30
+ if (Array.isArray(value) && this.component.storeas !== 'array') {
31
+ if (this.component.storeas === 'string') {
32
+ return super.normalizeValue(value.join(this.delimiter || ''));
33
+ }
34
+ return super.normalizeValue(value[0] || this.emptyValue);
35
+ }
36
+ else {
37
+ return super.normalizeValue(value);
38
+ }
13
39
  }
14
- return parent;
40
+ }
41
+ get dataValue() {
42
+ return super.dataValue;
15
43
  }
16
44
  set dataValue(value) {
17
45
  super.dataValue = value;
@@ -31,30 +59,20 @@ class Multivalue extends Field_1.default {
31
59
  get addAnother() {
32
60
  return this.t(this.component.addAnother || 'Add Another');
33
61
  }
34
- useWrapper() {
35
- return this.component.hasOwnProperty('multiple') && this.component.multiple;
36
- }
37
62
  /**
38
63
  * @returns {Field} - The created field.
39
64
  */
40
65
  render() {
41
- // If single value field.
42
- if (!this.useWrapper()) {
43
- return super.render(`<div ${this._referenceAttributeName}="element">
44
- ${this.renderElement(this.component.type !== 'hidden' ? this.dataValue : '')}
45
- </div>`);
46
- }
47
- // Make sure dataValue is in the correct array format.
48
- let dataValue = this.dataValue;
49
- if (!Array.isArray(dataValue)) {
50
- dataValue = dataValue ? [dataValue] : [];
51
- }
52
- // If multiple value field.
53
- return super.render(this.renderTemplate('multiValueTable', {
54
- rows: dataValue.map(this.renderRow.bind(this)).join(''),
55
- disabled: this.disabled,
56
- addAnother: this.addAnother,
57
- }));
66
+ let dataValue = this.normalizeValue(this.dataValue);
67
+ return this.component.hasOwnProperty('multiple') && this.component.multiple
68
+ ? super.render(this.renderTemplate('multiValueTable', {
69
+ rows: dataValue.map(this.renderRow.bind(this)).join(''),
70
+ disabled: this.disabled,
71
+ addAnother: this.addAnother,
72
+ }))
73
+ : super.render(`<div ${this._referenceAttributeName}="element">
74
+ ${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
75
+ </div>`);
58
76
  }
59
77
  renderElement() {
60
78
  return '';
@@ -11,6 +11,12 @@ export default class AddressComponent extends ContainerComponent {
11
11
  weight: number;
12
12
  schema: any;
13
13
  };
14
+ static get serverConditionSettings(): {
15
+ operators: string[];
16
+ };
17
+ static get conditionOperatorsSettings(): {
18
+ operators: string[];
19
+ };
14
20
  static get modeSwitcherRef(): string;
15
21
  static get removeValueIconRef(): string;
16
22
  static get searchInputRef(): string;
@@ -97,6 +97,12 @@ class AddressComponent extends Container_1.default {
97
97
  schema: AddressComponent.schema(),
98
98
  };
99
99
  }
100
+ static get serverConditionSettings() {
101
+ return AddressComponent.conditionOperatorsSettings;
102
+ }
103
+ static get conditionOperatorsSettings() {
104
+ return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEmpty', 'isNotEmpty'] });
105
+ }
100
106
  mergeSchema(component = {}) {
101
107
  let { defaultSchema } = this;
102
108
  if (component.components) {
@@ -188,7 +194,7 @@ class AddressComponent extends Container_1.default {
188
194
  return (this.manualModeEnabled && this.dataValue) ? this.dataValue.address : this.dataValue;
189
195
  }
190
196
  set address(value) {
191
- if (this.manualModeEnabled && !this.isMultiple) {
197
+ if (this.manualModeEnabled && !this.isMultiple && !lodash_1.default.isEqual(value, this.emptyValue)) {
192
198
  this.dataValue.address = value;
193
199
  }
194
200
  else {
@@ -118,12 +118,12 @@ class TagsComponent extends Input_1.default {
118
118
  }
119
119
  normalizeValue(value) {
120
120
  if (this.component.storeas === 'string' && Array.isArray(value)) {
121
- return value.join(this.delimiter);
121
+ return super.normalizeValue(value.join(this.delimiter));
122
122
  }
123
123
  else if (this.component.storeas === 'array' && typeof value === 'string') {
124
- return value.split(this.delimiter).filter(result => result);
124
+ return super.normalizeValue(value.split(this.delimiter).filter(result => result));
125
125
  }
126
- return value;
126
+ return super.normalizeValue(value);
127
127
  }
128
128
  setValue(value, flags = {}) {
129
129
  const changed = super.setValue(value, flags);
@@ -1247,14 +1247,10 @@ export default class Webform extends NestedDataComponent {
1247
1247
  }
1248
1248
  this.checkData(value.data, flags);
1249
1249
  const shouldValidate = !flags.noValidate ||
1250
- flags.fromIframe ||
1250
+ flags.fromIFrame ||
1251
1251
  (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1252
1252
  const errors = shouldValidate
1253
- ? this.validate(value.data, {
1254
- ...flags,
1255
- noValidate: flags.fromIframe && this.submitted ? false : flags.noValidate,
1256
- process: 'change'
1257
- })
1253
+ ? this.validate(value.data, { ...flags, process: "change" })
1258
1254
  : [];
1259
1255
  value.isValid = errors.length === 0;
1260
1256
  this.loading = false;
@@ -2988,7 +2988,7 @@ export default class Component extends Element {
2988
2988
  this.parent.childErrors.push(...errors);
2989
2989
  }
2990
2990
  else {
2991
- _.remove(this.parent.childErrors, (err) => (err?.component?.key || err?.context?.key) === this.component.key);
2991
+ _.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
2992
2992
  }
2993
2993
  }
2994
2994
  this.showValidationErrors(errors, data, row, flags);
@@ -3004,7 +3004,7 @@ export default class Component extends Element {
3004
3004
  this.parent.childErrors.push(...errors);
3005
3005
  }
3006
3006
  else {
3007
- _.remove(this.parent.childErrors, (err) => (err?.component?.key || err?.context?.key) === this.component.key);
3007
+ _.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
3008
3008
  }
3009
3009
  }
3010
3010
  return errors.length === 0;
@@ -1,6 +1,5 @@
1
1
  export default class Multivalue extends Field {
2
2
  get addAnother(): string;
3
- useWrapper(): any;
4
3
  /**
5
4
  * @returns {Field} - The created field.
6
5
  */
@@ -1,12 +1,40 @@
1
1
  import Field from '../field/Field';
2
2
  import _ from 'lodash';
3
3
  export default class Multivalue extends Field {
4
- get dataValue() {
5
- const parent = super.dataValue;
6
- if (!parent && this.component.multiple) {
7
- return [];
4
+ /**
5
+ * Normalize values coming into updateValue.
6
+ * @param {*} value - The value to normalize before setting.
7
+ * @returns {*} - The normalized value.
8
+ */
9
+ normalizeValue(value) {
10
+ if (this.component.multiple) {
11
+ if (Array.isArray(value)) {
12
+ if (value.length === 0) {
13
+ return [this.emptyValue];
14
+ }
15
+ if (this.component.storeas === 'array') {
16
+ return super.normalizeValue([value]);
17
+ }
18
+ return super.normalizeValue(value);
19
+ }
20
+ else {
21
+ return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
22
+ }
23
+ }
24
+ else {
25
+ if (Array.isArray(value) && this.component.storeas !== 'array') {
26
+ if (this.component.storeas === 'string') {
27
+ return super.normalizeValue(value.join(this.delimiter || ''));
28
+ }
29
+ return super.normalizeValue(value[0] || this.emptyValue);
30
+ }
31
+ else {
32
+ return super.normalizeValue(value);
33
+ }
8
34
  }
9
- return parent;
35
+ }
36
+ get dataValue() {
37
+ return super.dataValue;
10
38
  }
11
39
  set dataValue(value) {
12
40
  super.dataValue = value;
@@ -26,30 +54,20 @@ export default class Multivalue extends Field {
26
54
  get addAnother() {
27
55
  return this.t(this.component.addAnother || 'Add Another');
28
56
  }
29
- useWrapper() {
30
- return this.component.hasOwnProperty('multiple') && this.component.multiple;
31
- }
32
57
  /**
33
58
  * @returns {Field} - The created field.
34
59
  */
35
60
  render() {
36
- // If single value field.
37
- if (!this.useWrapper()) {
38
- return super.render(`<div ${this._referenceAttributeName}="element">
39
- ${this.renderElement(this.component.type !== 'hidden' ? this.dataValue : '')}
40
- </div>`);
41
- }
42
- // Make sure dataValue is in the correct array format.
43
- let dataValue = this.dataValue;
44
- if (!Array.isArray(dataValue)) {
45
- dataValue = dataValue ? [dataValue] : [];
46
- }
47
- // If multiple value field.
48
- return super.render(this.renderTemplate('multiValueTable', {
49
- rows: dataValue.map(this.renderRow.bind(this)).join(''),
50
- disabled: this.disabled,
51
- addAnother: this.addAnother,
52
- }));
61
+ let dataValue = this.normalizeValue(this.dataValue);
62
+ return this.component.hasOwnProperty('multiple') && this.component.multiple
63
+ ? super.render(this.renderTemplate('multiValueTable', {
64
+ rows: dataValue.map(this.renderRow.bind(this)).join(''),
65
+ disabled: this.disabled,
66
+ addAnother: this.addAnother,
67
+ }))
68
+ : super.render(`<div ${this._referenceAttributeName}="element">
69
+ ${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
70
+ </div>`);
53
71
  }
54
72
  renderElement() {
55
73
  return '';
@@ -11,6 +11,12 @@ export default class AddressComponent extends ContainerComponent {
11
11
  weight: number;
12
12
  schema: any;
13
13
  };
14
+ static get serverConditionSettings(): {
15
+ operators: string[];
16
+ };
17
+ static get conditionOperatorsSettings(): {
18
+ operators: string[];
19
+ };
14
20
  static get modeSwitcherRef(): string;
15
21
  static get removeValueIconRef(): string;
16
22
  static get searchInputRef(): string;
@@ -91,6 +91,15 @@ export default class AddressComponent extends ContainerComponent {
91
91
  schema: AddressComponent.schema(),
92
92
  };
93
93
  }
94
+ static get serverConditionSettings() {
95
+ return AddressComponent.conditionOperatorsSettings;
96
+ }
97
+ static get conditionOperatorsSettings() {
98
+ return {
99
+ ...super.conditionOperatorsSettings,
100
+ operators: ['isEmpty', 'isNotEmpty'],
101
+ };
102
+ }
94
103
  mergeSchema(component = {}) {
95
104
  let { defaultSchema } = this;
96
105
  if (component.components) {
@@ -181,7 +190,7 @@ export default class AddressComponent extends ContainerComponent {
181
190
  return (this.manualModeEnabled && this.dataValue) ? this.dataValue.address : this.dataValue;
182
191
  }
183
192
  set address(value) {
184
- if (this.manualModeEnabled && !this.isMultiple) {
193
+ if (this.manualModeEnabled && !this.isMultiple && !_.isEqual(value, this.emptyValue)) {
185
194
  this.dataValue.address = value;
186
195
  }
187
196
  else {
@@ -116,12 +116,12 @@ export default class TagsComponent extends Input {
116
116
  }
117
117
  normalizeValue(value) {
118
118
  if (this.component.storeas === 'string' && Array.isArray(value)) {
119
- return value.join(this.delimiter);
119
+ return super.normalizeValue(value.join(this.delimiter));
120
120
  }
121
121
  else if (this.component.storeas === 'array' && typeof value === 'string') {
122
- return value.split(this.delimiter).filter(result => result);
122
+ return super.normalizeValue(value.split(this.delimiter).filter(result => result));
123
123
  }
124
- return value;
124
+ return super.normalizeValue(value);
125
125
  }
126
126
  setValue(value, flags = {}) {
127
127
  const changed = super.setValue(value, flags);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5780.6637ffb",
3
+ "version": "5.0.0-dev.5789.2e50e03",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {