@formio/js 5.1.0-dev.6218.dde7b07 → 5.1.0-dev.6220.2e623f9

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.
@@ -529,8 +529,8 @@ class WebformBuilder extends Component_1.default {
529
529
  }
530
530
  return elem;
531
531
  };
532
- const hideShow = (group, show) => {
533
- if (show) {
532
+ const hideShow = (group, forceShow, toggle = false) => {
533
+ if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
534
534
  group.classList.add(['show']);
535
535
  group.style.display = 'inherit';
536
536
  }
@@ -552,7 +552,9 @@ class WebformBuilder extends Component_1.default {
552
552
  const openByDefault = getAttribute(group, 'default') === 'true';
553
553
  const groupId = group.getAttribute('id').slice('group-'.length);
554
554
  const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
555
- hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));
555
+ if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
556
+ hideShow(group, false, true);
557
+ }
556
558
  });
557
559
  }, true);
558
560
  });
@@ -183,6 +183,10 @@ class WizardBuilder extends WebformBuilder_1.default {
183
183
  this.navigationDragula = null;
184
184
  super.detach();
185
185
  }
186
+ destroy(all = false) {
187
+ this.off('saveComponent');
188
+ super.destroy(all);
189
+ }
186
190
  rebuild() {
187
191
  var _a;
188
192
  const page = this.currentPage;
@@ -91,10 +91,13 @@ class NumberComponent extends Input_1.default {
91
91
  }
92
92
  get defaultValue() {
93
93
  let defaultValue = super.defaultValue;
94
- if (typeof defaultValue === 'string') {
94
+ if (typeof defaultValue === 'string' && defaultValue) {
95
95
  // Default value may be a string or have custom thousands separators or decimal symbols, so we need to call
96
96
  // parseNumber on it
97
97
  defaultValue = this.parseNumber(defaultValue);
98
+ if (lodash_1.default.isNaN(defaultValue)) {
99
+ defaultValue = null;
100
+ }
98
101
  }
99
102
  if (!defaultValue && this.component.defaultValue === 0) {
100
103
  defaultValue = this.component.defaultValue;
@@ -515,8 +515,8 @@ export default class WebformBuilder extends Component {
515
515
  }
516
516
  return elem;
517
517
  };
518
- const hideShow = (group, show) => {
519
- if (show) {
518
+ const hideShow = (group, forceShow, toggle = false) => {
519
+ if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
520
520
  group.classList.add(['show']);
521
521
  group.style.display = 'inherit';
522
522
  }
@@ -538,7 +538,9 @@ export default class WebformBuilder extends Component {
538
538
  const openByDefault = getAttribute(group, 'default') === 'true';
539
539
  const groupId = group.getAttribute('id').slice('group-'.length);
540
540
  const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
541
- hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));
541
+ if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
542
+ hideShow(group, false, true);
543
+ }
542
544
  });
543
545
  }, true);
544
546
  });
@@ -178,6 +178,10 @@ export default class WizardBuilder extends WebformBuilder {
178
178
  this.navigationDragula = null;
179
179
  super.detach();
180
180
  }
181
+ destroy(all = false) {
182
+ this.off('saveComponent');
183
+ super.destroy(all);
184
+ }
181
185
  rebuild() {
182
186
  const page = this.currentPage;
183
187
  this.webform.setForm({
@@ -89,10 +89,13 @@ export default class NumberComponent extends Input {
89
89
  }
90
90
  get defaultValue() {
91
91
  let defaultValue = super.defaultValue;
92
- if (typeof defaultValue === 'string') {
92
+ if (typeof defaultValue === 'string' && defaultValue) {
93
93
  // Default value may be a string or have custom thousands separators or decimal symbols, so we need to call
94
94
  // parseNumber on it
95
95
  defaultValue = this.parseNumber(defaultValue);
96
+ if (_.isNaN(defaultValue)) {
97
+ defaultValue = null;
98
+ }
96
99
  }
97
100
  if (!defaultValue && this.component.defaultValue === 0) {
98
101
  defaultValue = this.component.defaultValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6218.dde7b07",
3
+ "version": "5.1.0-dev.6220.2e623f9",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {