@formio/js 5.0.0-dev.5879.21c1482 → 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.
@@ -172,7 +172,13 @@ class NumberComponent extends Input_1.default {
172
172
  }
173
173
  let value = parseFloat(input);
174
174
  if (!lodash_1.default.isNaN(value)) {
175
- value = String(value).replace('.', this.decimalSeparator);
175
+ // Format scientific notation
176
+ if (/e/i.test(String(value))) {
177
+ value = value.toExponential(this.decimalLimit);
178
+ }
179
+ else {
180
+ value = String(value).replace('.', this.decimalSeparator);
181
+ }
176
182
  }
177
183
  else {
178
184
  value = null;
@@ -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;
@@ -170,7 +170,13 @@ export default class NumberComponent extends Input {
170
170
  }
171
171
  let value = parseFloat(input);
172
172
  if (!_.isNaN(value)) {
173
- value = String(value).replace('.', this.decimalSeparator);
173
+ // Format scientific notation
174
+ if (/e/i.test(String(value))) {
175
+ value = value.toExponential(this.decimalLimit);
176
+ }
177
+ else {
178
+ value = String(value).replace('.', this.decimalSeparator);
179
+ }
174
180
  }
175
181
  else {
176
182
  value = null;
@@ -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.5879.21c1482",
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",