@formio/js 5.0.0-dev.5878.d6b667a → 5.0.0-dev.5883.805c58d

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.
@@ -13,7 +13,6 @@ const utils_1 = require("../../utils/utils");
13
13
  const EditRowState = {
14
14
  New: 'new',
15
15
  Editing: 'editing',
16
- Saving: 'saving',
17
16
  Saved: 'saved',
18
17
  Viewing: 'viewing',
19
18
  Removed: 'removed',
@@ -809,10 +808,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
809
808
  if (!this.component.rowDrafts) {
810
809
  editRow.components.forEach((comp) => comp.setPristine(false));
811
810
  }
812
- // Mark the row with a 'Saving' state to trigger validation for future row changes
813
- if (editRow.state === EditRowState.New) {
814
- editRow.state = EditRowState.Saving;
815
- }
816
811
  const errors = this.validateRow(editRow, true);
817
812
  if (!this.component.rowDrafts) {
818
813
  if (errors.length) {
@@ -825,7 +820,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
825
820
  this.root.focusedComponent = null;
826
821
  }
827
822
  switch (editRow.state) {
828
- case EditRowState.Saving: {
823
+ case EditRowState.New: {
829
824
  const newIndex = dataValue.length;
830
825
  dataValue.push(editRow.data);
831
826
  editRow.components.forEach(component => component.rowIndex = newIndex);
@@ -985,7 +980,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
985
980
  }
986
981
  shouldValidateRow(editRow, dirty, fromSubmission) {
987
982
  return this.shouldValidateDraft(editRow) ||
988
- editRow.state === EditRowState.Saving ||
983
+ editRow.state === EditRowState.New ||
989
984
  editRow.state === EditRowState.Editing ||
990
985
  editRow.alerts ||
991
986
  fromSubmission ||
@@ -1001,7 +996,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1001
996
  editGridValue[editRow.rowIndex] = editRow.data;
1002
997
  lodash_1.default.set(rootValue, this.path, editGridValue);
1003
998
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
1004
- editRow.errors = (0, process_1.processSync)({
999
+ const errors = (0, process_1.processSync)({
1005
1000
  components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {
1006
1001
  component.parentPath = `${this.path}[${editRow.rowIndex}]`;
1007
1002
  return component;
@@ -1018,6 +1013,9 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1018
1013
  }
1019
1014
  ]
1020
1015
  }).errors;
1016
+ editRow.errors = (this.component.modal || this.component.rowDrafts)
1017
+ ? errors
1018
+ : errors.filter((err) => lodash_1.default.find(this.visibleErrors, ['component.id', err.component.id]));
1021
1019
  }
1022
1020
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1023
1021
  if (this.component.validate && this.component.validate.row) {
@@ -84,7 +84,6 @@ class NumberComponent extends Input_1.default {
84
84
  decimalLimit: lodash_1.default.get(this.component, 'decimalLimit', this.decimalLimit),
85
85
  allowNegative: lodash_1.default.get(this.component, 'allowNegative', true),
86
86
  allowDecimal: this.isDecimalAllowed(),
87
- allowScientificNotation: lodash_1.default.get(this.component, 'allowScientificNotation', false),
88
87
  });
89
88
  }
90
89
  get defaultSchema() {
@@ -117,10 +116,6 @@ class NumberComponent extends Input_1.default {
117
116
  parseNumber(value) {
118
117
  // Remove delimiters and convert decimal separator to dot.
119
118
  value = value.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
120
- // Add support for scientific notation
121
- if (/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/.test(value)) {
122
- return Number(value);
123
- }
124
119
  if (this.component.validate && this.component.validate.integer) {
125
120
  return parseInt(value, 10);
126
121
  }
@@ -176,9 +171,6 @@ class NumberComponent extends Input_1.default {
176
171
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
177
172
  }
178
173
  let value = parseFloat(input);
179
- if (this.component.allowScientificNotation) {
180
- value = Number(input);
181
- }
182
174
  if (!lodash_1.default.isNaN(value)) {
183
175
  // Format scientific notation
184
176
  if (/e/i.test(String(value))) {
@@ -25,14 +25,6 @@ exports.default = [
25
25
  label: 'Require Decimal',
26
26
  tooltip: 'Always show decimals, even if trailing zeros.'
27
27
  },
28
- {
29
- type: 'checkbox',
30
- input: true,
31
- weight: 100,
32
- key: 'allowScientificNotation',
33
- label: 'Allow Scientific Notation',
34
- tooltip: 'Allow scientific notation for numbers.'
35
- },
36
28
  {
37
29
  key: 'case',
38
30
  ignore: true,
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
131
131
  addCurrentChoices(values: any, items: any, keyValue: any): any;
132
132
  getValueAsString(data: any, options: any): any;
133
133
  normalizeSingleValue(value: any): any;
134
- setMetadata(value: any): any;
134
+ setMetadata(value: any, flags?: {}): any;
135
135
  updateValue(value: any, flags: any): boolean;
136
136
  undoValueTyping(value: any): any;
137
137
  setValue(value: any, flags?: {}): boolean;
@@ -1204,8 +1204,8 @@ class SelectComponent extends ListComponent_1.default {
1204
1204
  }
1205
1205
  return super.normalizeValue(this.normalizeSingleValue(value));
1206
1206
  }
1207
- setMetadata(value) {
1208
- var _a;
1207
+ setMetadata(value, flags = {}) {
1208
+ var _a, _b;
1209
1209
  if (lodash_1.default.isNil(value)) {
1210
1210
  return;
1211
1211
  }
@@ -1239,15 +1239,22 @@ class SelectComponent extends ListComponent_1.default {
1239
1239
  }
1240
1240
  lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
1241
1241
  }
1242
+ if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission)) {
1243
+ const submission = this.root.submission;
1244
+ if (!submission.metadata) {
1245
+ submission.metadata = {};
1246
+ }
1247
+ submission.metadata.selectData = {};
1248
+ }
1242
1249
  }
1243
1250
  updateValue(value, flags) {
1244
1251
  const changed = super.updateValue(value, flags);
1245
- if (changed || !this.selectMetadata) {
1252
+ if (changed || !this.selectMetadata || flags.resetValue) {
1246
1253
  if (this.component.multiple && Array.isArray(this.dataValue)) {
1247
- this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
1254
+ this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
1248
1255
  }
1249
1256
  else {
1250
- this.setMetadata(this.dataValue);
1257
+ this.setMetadata(this.dataValue, flags);
1251
1258
  }
1252
1259
  }
1253
1260
  return changed;
@@ -8,7 +8,6 @@ import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } fr
8
8
  const EditRowState = {
9
9
  New: 'new',
10
10
  Editing: 'editing',
11
- Saving: 'saving',
12
11
  Saved: 'saved',
13
12
  Viewing: 'viewing',
14
13
  Removed: 'removed',
@@ -799,10 +798,6 @@ export default class EditGridComponent extends NestedArrayComponent {
799
798
  if (!this.component.rowDrafts) {
800
799
  editRow.components.forEach((comp) => comp.setPristine(false));
801
800
  }
802
- // Mark the row with a 'Saving' state to trigger validation for future row changes
803
- if (editRow.state === EditRowState.New) {
804
- editRow.state = EditRowState.Saving;
805
- }
806
801
  const errors = this.validateRow(editRow, true);
807
802
  if (!this.component.rowDrafts) {
808
803
  if (errors.length) {
@@ -815,7 +810,7 @@ export default class EditGridComponent extends NestedArrayComponent {
815
810
  this.root.focusedComponent = null;
816
811
  }
817
812
  switch (editRow.state) {
818
- case EditRowState.Saving: {
813
+ case EditRowState.New: {
819
814
  const newIndex = dataValue.length;
820
815
  dataValue.push(editRow.data);
821
816
  editRow.components.forEach(component => component.rowIndex = newIndex);
@@ -975,7 +970,7 @@ export default class EditGridComponent extends NestedArrayComponent {
975
970
  }
976
971
  shouldValidateRow(editRow, dirty, fromSubmission) {
977
972
  return this.shouldValidateDraft(editRow) ||
978
- editRow.state === EditRowState.Saving ||
973
+ editRow.state === EditRowState.New ||
979
974
  editRow.state === EditRowState.Editing ||
980
975
  editRow.alerts ||
981
976
  fromSubmission ||
@@ -990,7 +985,7 @@ export default class EditGridComponent extends NestedArrayComponent {
990
985
  editGridValue[editRow.rowIndex] = editRow.data;
991
986
  _.set(rootValue, this.path, editGridValue);
992
987
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
993
- editRow.errors = processSync({
988
+ const errors = processSync({
994
989
  components: fastCloneDeep(this.component.components).map((component) => {
995
990
  component.parentPath = `${this.path}[${editRow.rowIndex}]`;
996
991
  return component;
@@ -1007,6 +1002,9 @@ export default class EditGridComponent extends NestedArrayComponent {
1007
1002
  }
1008
1003
  ]
1009
1004
  }).errors;
1005
+ editRow.errors = (this.component.modal || this.component.rowDrafts)
1006
+ ? errors
1007
+ : errors.filter((err) => _.find(this.visibleErrors, ['component.id', err.component.id]));
1010
1008
  }
1011
1009
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1012
1010
  if (this.component.validate && this.component.validate.row) {
@@ -82,7 +82,6 @@ export default class NumberComponent extends Input {
82
82
  decimalLimit: _.get(this.component, 'decimalLimit', this.decimalLimit),
83
83
  allowNegative: _.get(this.component, 'allowNegative', true),
84
84
  allowDecimal: this.isDecimalAllowed(),
85
- allowScientificNotation: _.get(this.component, 'allowScientificNotation', false),
86
85
  });
87
86
  }
88
87
  get defaultSchema() {
@@ -115,10 +114,6 @@ export default class NumberComponent extends Input {
115
114
  parseNumber(value) {
116
115
  // Remove delimiters and convert decimal separator to dot.
117
116
  value = value.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
118
- // Add support for scientific notation
119
- if (/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/.test(value)) {
120
- return Number(value);
121
- }
122
117
  if (this.component.validate && this.component.validate.integer) {
123
118
  return parseInt(value, 10);
124
119
  }
@@ -174,9 +169,6 @@ export default class NumberComponent extends Input {
174
169
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
175
170
  }
176
171
  let value = parseFloat(input);
177
- if (this.component.allowScientificNotation) {
178
- value = Number(input);
179
- }
180
172
  if (!_.isNaN(value)) {
181
173
  // Format scientific notation
182
174
  if (/e/i.test(String(value))) {
@@ -23,14 +23,6 @@ export default [
23
23
  label: 'Require Decimal',
24
24
  tooltip: 'Always show decimals, even if trailing zeros.'
25
25
  },
26
- {
27
- type: 'checkbox',
28
- input: true,
29
- weight: 100,
30
- key: 'allowScientificNotation',
31
- label: 'Allow Scientific Notation',
32
- tooltip: 'Allow scientific notation for numbers.'
33
- },
34
26
  {
35
27
  key: 'case',
36
28
  ignore: true,
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
131
131
  addCurrentChoices(values: any, items: any, keyValue: any): any;
132
132
  getValueAsString(data: any, options: any): any;
133
133
  normalizeSingleValue(value: any): any;
134
- setMetadata(value: any): any;
134
+ setMetadata(value: any, flags?: {}): any;
135
135
  updateValue(value: any, flags: any): boolean;
136
136
  undoValueTyping(value: any): any;
137
137
  setValue(value: any, flags?: {}): boolean;
@@ -1233,7 +1233,7 @@ export default class SelectComponent extends ListComponent {
1233
1233
  }
1234
1234
  return super.normalizeValue(this.normalizeSingleValue(value));
1235
1235
  }
1236
- setMetadata(value) {
1236
+ setMetadata(value, flags = {}) {
1237
1237
  if (_.isNil(value)) {
1238
1238
  return;
1239
1239
  }
@@ -1267,15 +1267,22 @@ export default class SelectComponent extends ListComponent {
1267
1267
  }
1268
1268
  _.set(submission.metadata.selectData, this.path, templateData);
1269
1269
  }
1270
+ if (flags.resetValue && this.root?.submission) {
1271
+ const submission = this.root.submission;
1272
+ if (!submission.metadata) {
1273
+ submission.metadata = {};
1274
+ }
1275
+ submission.metadata.selectData = {};
1276
+ }
1270
1277
  }
1271
1278
  updateValue(value, flags) {
1272
1279
  const changed = super.updateValue(value, flags);
1273
- if (changed || !this.selectMetadata) {
1280
+ if (changed || !this.selectMetadata || flags.resetValue) {
1274
1281
  if (this.component.multiple && Array.isArray(this.dataValue)) {
1275
- this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
1282
+ this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
1276
1283
  }
1277
1284
  else {
1278
- this.setMetadata(this.dataValue);
1285
+ this.setMetadata(this.dataValue, flags);
1279
1286
  }
1280
1287
  }
1281
1288
  return changed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5878.d6b667a",
3
+ "version": "5.0.0-dev.5883.805c58d",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -83,7 +83,7 @@
83
83
  "@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
84
84
  "@formio/choices.js": "^10.2.1",
85
85
  "@formio/core": "v2.1.0-dev.174.9a3c6ec",
86
- "@formio/text-mask-addons": "^3.8.0-formio.2",
86
+ "@formio/text-mask-addons": "^3.8.0-formio.3",
87
87
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
88
88
  "abortcontroller-polyfill": "^1.7.5",
89
89
  "autocompleter": "^8.0.4",