@formio/js 5.0.0-dev.5878.d6b667a → 5.0.0-dev.5879.21c1482

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,17 +171,8 @@ 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
- // Format scientific notation
184
- if (/e/i.test(String(value))) {
185
- value = value.toExponential(this.decimalLimit);
186
- }
187
- else {
188
- value = String(value).replace('.', this.decimalSeparator);
189
- }
175
+ value = String(value).replace('.', this.decimalSeparator);
190
176
  }
191
177
  else {
192
178
  value = null;
@@ -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,
@@ -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,17 +169,8 @@ 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
- // Format scientific notation
182
- if (/e/i.test(String(value))) {
183
- value = value.toExponential(this.decimalLimit);
184
- }
185
- else {
186
- value = String(value).replace('.', this.decimalSeparator);
187
- }
173
+ value = String(value).replace('.', this.decimalSeparator);
188
174
  }
189
175
  else {
190
176
  value = null;
@@ -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,
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.5879.21c1482",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {