@formio/js 5.0.0-dev.5948.072adfa → 5.0.0-dev.5950.723a551

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.
@@ -103,6 +103,10 @@ class DateTimeComponent extends Input_1.default {
103
103
  }
104
104
  /* eslint-disable camelcase */
105
105
  this.component.widget = Object.assign({ type: 'calendar', timezone, displayInTimezone: lodash_1.default.get(this.component, 'displayInTimezone', 'viewer'), locale: this.options.language, useLocaleSettings: lodash_1.default.get(this.component, 'useLocaleSettings', false), allowInput: lodash_1.default.get(this.component, 'allowInput', true), mode: 'single', enableTime: lodash_1.default.get(this.component, 'enableTime', true), noCalendar: !lodash_1.default.get(this.component, 'enableDate', true), format: this.component.format, hourIncrement: lodash_1.default.get(this.component, 'timePicker.hourStep', 1), minuteIncrement: lodash_1.default.get(this.component, 'timePicker.minuteStep', 5), time_24hr: time24hr, readOnly: this.options.readOnly, minDate: lodash_1.default.get(this.component, 'datePicker.minDate'), disabledDates: lodash_1.default.get(this.component, 'datePicker.disable'), disableWeekends: lodash_1.default.get(this.component, 'datePicker.disableWeekends'), disableWeekdays: lodash_1.default.get(this.component, 'datePicker.disableWeekdays'), disableFunction: lodash_1.default.get(this.component, 'datePicker.disableFunction'), maxDate: lodash_1.default.get(this.component, 'datePicker.maxDate') }, customOptions);
106
+ // update originalComponent to include widget and other updated settings
107
+ // it is done here since these settings depend on properties present after the component is initialized
108
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
109
+ this.originalComponent = (0, utils_2.fastCloneDeep)(this.component);
106
110
  /* eslint-enable camelcase */
107
111
  }
108
112
  get defaultSchema() {
@@ -170,14 +170,21 @@ class NumberComponent extends Input_1.default {
170
170
  if (typeof input === 'string') {
171
171
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
172
172
  }
173
- let value = parseFloat(input);
174
- if (!lodash_1.default.isNaN(value)) {
173
+ let value;
174
+ if (!lodash_1.default.isNaN(input)) {
175
175
  // Format scientific notation
176
- if (/e/i.test(String(value))) {
176
+ if (/[0-9]+[eE]/.test(String(input))) {
177
+ // Convert to exponential notation will depend on the decimal limit set in the component
178
+ // Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
179
+ // Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
180
+ // if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
181
+ // if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
182
+ value = parseFloat(input);
177
183
  value = value.toExponential(this.decimalLimit);
178
184
  }
179
185
  else {
180
- value = String(value).replace('.', this.decimalSeparator);
186
+ value = parseFloat(input);
187
+ value = !lodash_1.default.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
181
188
  }
182
189
  }
183
190
  else {
@@ -102,6 +102,9 @@ class TextFieldComponent extends Input_1.default {
102
102
  if (((_c = this.component.widget) === null || _c === void 0 ? void 0 : _c.type) === 'calendar') {
103
103
  this.component.widget = Object.assign(Object.assign({}, this.component.widget), { readOnly: this.options.readOnly, timezone,
104
104
  displayInTimezone, locale: this.component.widget.locale || this.options.language, saveAs: 'text' });
105
+ // update originalComponent to include widget settings after component initialization
106
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
107
+ this.originalComponent = FormioUtils.fastCloneDeep(this.component);
105
108
  }
106
109
  }
107
110
  attach(element) {
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import FormioUtils from '../../utils';
4
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils/utils';
5
5
  import Input from '../_classes/input/Input';
6
6
  export default class DateTimeComponent extends Input {
7
7
  static schema(...extend) {
@@ -127,6 +127,10 @@ export default class DateTimeComponent extends Input {
127
127
  maxDate: _.get(this.component, 'datePicker.maxDate'),
128
128
  ...customOptions,
129
129
  };
130
+ // update originalComponent to include widget and other updated settings
131
+ // it is done here since these settings depend on properties present after the component is initialized
132
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
133
+ this.originalComponent = fastCloneDeep(this.component);
130
134
  /* eslint-enable camelcase */
131
135
  }
132
136
  get defaultSchema() {
@@ -168,14 +168,21 @@ export default class NumberComponent extends Input {
168
168
  if (typeof input === 'string') {
169
169
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
170
170
  }
171
- let value = parseFloat(input);
172
- if (!_.isNaN(value)) {
171
+ let value;
172
+ if (!_.isNaN(input)) {
173
173
  // Format scientific notation
174
- if (/e/i.test(String(value))) {
174
+ if (/[0-9]+[eE]/.test(String(input))) {
175
+ // Convert to exponential notation will depend on the decimal limit set in the component
176
+ // Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
177
+ // Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
178
+ // if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
179
+ // if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
180
+ value = parseFloat(input);
175
181
  value = value.toExponential(this.decimalLimit);
176
182
  }
177
183
  else {
178
- value = String(value).replace('.', this.decimalSeparator);
184
+ value = parseFloat(input);
185
+ value = !_.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
179
186
  }
180
187
  }
181
188
  else {
@@ -86,6 +86,9 @@ export default class TextFieldComponent extends Input {
86
86
  locale: this.component.widget.locale || this.options.language,
87
87
  saveAs: 'text'
88
88
  };
89
+ // update originalComponent to include widget settings after component initialization
90
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
91
+ this.originalComponent = FormioUtils.fastCloneDeep(this.component);
89
92
  }
90
93
  }
91
94
  attach(element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5948.072adfa",
3
+ "version": "5.0.0-dev.5950.723a551",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "homepage": "https://github.com/formio/formio.js#readme",
82
82
  "dependencies": {
83
- "@formio/bootstrap": "3.0.0-dev.118.f146cb4",
83
+ "@formio/bootstrap": "3.0.0-dev.111.ae7f187",
84
84
  "@formio/choices.js": "^10.2.1",
85
85
  "@formio/core": "2.1.0-dev.193.68cf8c3",
86
86
  "@formio/text-mask-addons": "3.8.0-formio.4",