@formio/js 5.1.0-dev.6214.89da41f → 5.1.0-dev.6214.fdfb58b

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
  });
@@ -1206,6 +1208,7 @@ class WebformBuilder extends Component_1.default {
1206
1208
  submissionData = submissionData.componentJson || submissionData;
1207
1209
  if (submissionData.components && this.originalDefaultValue) {
1208
1210
  submissionData.components = this.originalDefaultValue.components;
1211
+ this.originalDefaultValue = null;
1209
1212
  }
1210
1213
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1211
1214
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
@@ -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;
@@ -633,10 +633,13 @@ class Component extends Element_1.default {
633
633
  if (!component) {
634
634
  component = this.component;
635
635
  }
636
+ if (!this.path) {
637
+ return false;
638
+ }
636
639
  if (lodash_1.default.isArray(this.options[visibility])) {
637
- return this.options[visibility].includes(component.key);
640
+ return this.options[visibility].includes(this.path);
638
641
  }
639
- return this.options[visibility][component.key];
642
+ return this.options[visibility][this.path];
640
643
  }
641
644
  shouldForceHide(component) {
642
645
  return this.shouldForceVisibility(component, 'hide');
@@ -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;
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
23
23
  import Licenses from './licenses';
24
24
  import EventEmitter from './EventEmitter';
25
25
  import Webform from './Webform';
26
- export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
26
+ import { DefaultEvaluator } from './utils';
27
+ export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
6
+ exports.DefaultEvaluator = exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const Formio_1 = require("./Formio");
9
9
  Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return Formio_1.Formio; } });
@@ -30,6 +30,7 @@ const Webform_1 = __importDefault(require("./Webform"));
30
30
  exports.Webform = Webform_1.default;
31
31
  const core_1 = require("@formio/core");
32
32
  const utils_2 = require("./utils");
33
+ Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return utils_2.DefaultEvaluator; } });
33
34
  Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
34
35
  Formio_1.Formio.requireLibrary(name, name, path, true)
35
36
  .then((modules) => {
@@ -2,7 +2,6 @@ export * from "./utils";
2
2
  export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
- DefaultEvaluator: typeof DefaultEvaluator;
6
5
  Evaluator: DefaultEvaluator;
7
6
  interpolate: typeof interpolate;
8
7
  ConditionOperators: {
@@ -165,8 +164,8 @@ declare const FormioUtils: {
165
164
  interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
166
165
  };
167
166
  import { Evaluator } from './Evaluator';
168
- import { registerEvaluator } from './Evaluator';
169
167
  import { DefaultEvaluator } from './Evaluator';
168
+ import { registerEvaluator } from './Evaluator';
170
169
  import { interpolate } from './Evaluator';
171
170
  import moment from 'moment';
172
- export { FormioUtils as Utils, Evaluator, registerEvaluator };
171
+ export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
@@ -29,17 +29,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
32
+ exports.registerEvaluator = exports.DefaultEvaluator = exports.Evaluator = exports.Utils = void 0;
33
33
  const utils = __importStar(require("./utils"));
34
34
  const formUtils = __importStar(require("./formUtils"));
35
35
  const Evaluator_1 = require("./Evaluator");
36
36
  Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
37
37
  Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
38
+ Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return Evaluator_1.DefaultEvaluator; } });
38
39
  const conditionOperators_1 = __importDefault(require("./conditionOperators"));
39
40
  const lodash_1 = __importDefault(require("lodash"));
40
41
  const moment_1 = __importDefault(require("moment"));
41
- const FormioUtils = Object.assign(Object.assign(Object.assign({}, utils), formUtils), { DefaultEvaluator: Evaluator_1.DefaultEvaluator,
42
- Evaluator: Evaluator_1.Evaluator,
42
+ const FormioUtils = Object.assign(Object.assign(Object.assign({}, utils), formUtils), { Evaluator: Evaluator_1.Evaluator,
43
43
  interpolate: Evaluator_1.interpolate,
44
44
  ConditionOperators: conditionOperators_1.default,
45
45
  _: lodash_1.default,
@@ -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
  });
@@ -1188,6 +1190,7 @@ export default class WebformBuilder extends Component {
1188
1190
  submissionData = submissionData.componentJson || submissionData;
1189
1191
  if (submissionData.components && this.originalDefaultValue) {
1190
1192
  submissionData.components = this.originalDefaultValue.components;
1193
+ this.originalDefaultValue = null;
1191
1194
  }
1192
1195
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1193
1196
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
@@ -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({
@@ -620,10 +620,13 @@ export default class Component extends Element {
620
620
  if (!component) {
621
621
  component = this.component;
622
622
  }
623
+ if (!this.path) {
624
+ return false;
625
+ }
623
626
  if (_.isArray(this.options[visibility])) {
624
- return this.options[visibility].includes(component.key);
627
+ return this.options[visibility].includes(this.path);
625
628
  }
626
- return this.options[visibility][component.key];
629
+ return this.options[visibility][this.path];
627
630
  }
628
631
  shouldForceHide(component) {
629
632
  return this.shouldForceVisibility(component, 'hide');
@@ -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;
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
23
23
  import Licenses from './licenses';
24
24
  import EventEmitter from './EventEmitter';
25
25
  import Webform from './Webform';
26
- export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
26
+ import { DefaultEvaluator } from './utils';
27
+ export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
@@ -12,7 +12,7 @@ import Licenses from './licenses';
12
12
  import EventEmitter from './EventEmitter';
13
13
  import Webform from './Webform';
14
14
  import { I18n } from '@formio/core';
15
- import { Evaluator, registerEvaluator } from './utils';
15
+ import { Evaluator, registerEvaluator, DefaultEvaluator } from './utils';
16
16
  Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
17
17
  Formio.requireLibrary(name, name, path, true)
18
18
  .then((modules) => {
@@ -130,4 +130,4 @@ export function useModule(defaultFn = null) {
130
130
  Formio.use = useModule();
131
131
  export { Formio as FormioCore } from './Formio';
132
132
  // Export the components.
133
- export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
133
+ export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
@@ -2,7 +2,6 @@ export * from "./utils";
2
2
  export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
- DefaultEvaluator: typeof DefaultEvaluator;
6
5
  Evaluator: DefaultEvaluator;
7
6
  interpolate: typeof interpolate;
8
7
  ConditionOperators: {
@@ -165,8 +164,8 @@ declare const FormioUtils: {
165
164
  interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
166
165
  };
167
166
  import { Evaluator } from './Evaluator';
168
- import { registerEvaluator } from './Evaluator';
169
167
  import { DefaultEvaluator } from './Evaluator';
168
+ import { registerEvaluator } from './Evaluator';
170
169
  import { interpolate } from './Evaluator';
171
170
  import moment from 'moment';
172
- export { FormioUtils as Utils, Evaluator, registerEvaluator };
171
+ export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
@@ -7,7 +7,6 @@ import moment from 'moment';
7
7
  const FormioUtils = {
8
8
  ...utils,
9
9
  ...formUtils,
10
- DefaultEvaluator,
11
10
  Evaluator,
12
11
  interpolate,
13
12
  ConditionOperators,
@@ -18,7 +17,7 @@ if (typeof global === 'object') {
18
17
  global.FormioUtils = FormioUtils;
19
18
  }
20
19
  export { FormioUtils as Utils };
21
- export { Evaluator, registerEvaluator };
20
+ export { Evaluator, DefaultEvaluator, registerEvaluator };
22
21
  export * from './utils';
23
22
  export * from './formUtils';
24
23
  export default FormioUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6214.89da41f",
3
+ "version": "5.1.0-dev.6214.fdfb58b",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {