@formio/js 5.1.0-dev.6211.5d30602 → 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.
@@ -533,9 +533,9 @@ class Element {
533
533
  if (this.component.filter === string && !this.options.building) {
534
534
  const evalContext = this.evalContext(data);
535
535
  evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
536
- return utils_1.default.Evaluator.interpolate(string, evalContext, options);
536
+ return utils_1.default.interpolate(string, evalContext, options);
537
537
  }
538
- return utils_1.default.Evaluator.interpolate(string, this.evalContext(data), options);
538
+ return utils_1.default.interpolate(string, this.evalContext(data), options);
539
539
  }
540
540
  /**
541
541
  * Performs an evaluation using the evaluation context of this component.
@@ -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,7 @@ export * from "./utils";
2
2
  export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
- Evaluator: import("./Evaluator").DefaultEvaluator;
5
+ Evaluator: DefaultEvaluator;
6
6
  interpolate: typeof interpolate;
7
7
  ConditionOperators: {
8
8
  [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
@@ -164,7 +164,8 @@ declare const FormioUtils: {
164
164
  interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
165
165
  };
166
166
  import { Evaluator } from './Evaluator';
167
+ import { DefaultEvaluator } from './Evaluator';
167
168
  import { registerEvaluator } from './Evaluator';
168
169
  import { interpolate } from './Evaluator';
169
170
  import moment from 'moment';
170
- export { FormioUtils as Utils, Evaluator, registerEvaluator };
171
+ export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
@@ -29,12 +29,13 @@ 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"));
@@ -246,9 +246,6 @@ class CalendarWidget extends InputWidget_1.default {
246
246
  if (!this.calendar) {
247
247
  return super.getValue();
248
248
  }
249
- if (this.settings.isManuallyOverriddenValue) {
250
- return this.settings.manualInputValue;
251
- }
252
249
  // Get the selected dates from the calendar widget.
253
250
  const dates = this.calendar.selectedDates;
254
251
  if (!dates || !dates.length) {
@@ -356,15 +353,6 @@ class CalendarWidget extends InputWidget_1.default {
356
353
  this.calendar.updateValue(false);
357
354
  });
358
355
  }
359
- // Move input attributes to altInput.
360
- const labelledbyIds = this.calendar.input.getAttribute('aria-labelledby');
361
- const isRequired = this.calendar.input.getAttribute('aria-required');
362
- this.calendar.altInput.id = this._input.id;
363
- this.calendar.altInput.setAttribute('aria-labelledby', labelledbyIds);
364
- this.calendar.altInput.setAttribute('aria-required', isRequired);
365
- this._input.removeAttribute('id');
366
- this._input.removeAttribute('aria-labelledby');
367
- this._input.removeAttribute('aria-required');
368
356
  const excludedFromMaskFormats = ['MMMM'];
369
357
  if (!this.settings.readOnly && !lodash_1.default.some(excludedFromMaskFormats, format => lodash_1.default.includes(this.settings.format, format))) {
370
358
  // Enforce the input mask of the format.
@@ -525,9 +525,9 @@ export default class Element {
525
525
  if (this.component.filter === string && !this.options.building) {
526
526
  const evalContext = this.evalContext(data);
527
527
  evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
528
- return FormioUtils.Evaluator.interpolate(string, evalContext, options);
528
+ return FormioUtils.interpolate(string, evalContext, options);
529
529
  }
530
- return FormioUtils.Evaluator.interpolate(string, this.evalContext(data), options);
530
+ return FormioUtils.interpolate(string, this.evalContext(data), options);
531
531
  }
532
532
  /**
533
533
  * Performs an evaluation using the evaluation context of this component.
@@ -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,7 @@ export * from "./utils";
2
2
  export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
- Evaluator: import("./Evaluator").DefaultEvaluator;
5
+ Evaluator: DefaultEvaluator;
6
6
  interpolate: typeof interpolate;
7
7
  ConditionOperators: {
8
8
  [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
@@ -164,7 +164,8 @@ declare const FormioUtils: {
164
164
  interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
165
165
  };
166
166
  import { Evaluator } from './Evaluator';
167
+ import { DefaultEvaluator } from './Evaluator';
167
168
  import { registerEvaluator } from './Evaluator';
168
169
  import { interpolate } from './Evaluator';
169
170
  import moment from 'moment';
170
- export { FormioUtils as Utils, Evaluator, registerEvaluator };
171
+ export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
@@ -1,6 +1,6 @@
1
1
  import * as utils from './utils';
2
2
  import * as formUtils from './formUtils';
3
- import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
3
+ import { Evaluator, registerEvaluator, interpolate, DefaultEvaluator } from './Evaluator';
4
4
  import ConditionOperators from './conditionOperators';
5
5
  import _ from 'lodash';
6
6
  import moment from 'moment';
@@ -17,7 +17,7 @@ if (typeof global === 'object') {
17
17
  global.FormioUtils = FormioUtils;
18
18
  }
19
19
  export { FormioUtils as Utils };
20
- export { Evaluator, registerEvaluator };
20
+ export { Evaluator, DefaultEvaluator, registerEvaluator };
21
21
  export * from './utils';
22
22
  export * from './formUtils';
23
23
  export default FormioUtils;
@@ -238,9 +238,6 @@ export default class CalendarWidget extends InputWidget {
238
238
  if (!this.calendar) {
239
239
  return super.getValue();
240
240
  }
241
- if (this.settings.isManuallyOverriddenValue) {
242
- return this.settings.manualInputValue;
243
- }
244
241
  // Get the selected dates from the calendar widget.
245
242
  const dates = this.calendar.selectedDates;
246
243
  if (!dates || !dates.length) {
@@ -347,15 +344,6 @@ export default class CalendarWidget extends InputWidget {
347
344
  this.calendar.updateValue(false);
348
345
  });
349
346
  }
350
- // Move input attributes to altInput.
351
- const labelledbyIds = this.calendar.input.getAttribute('aria-labelledby');
352
- const isRequired = this.calendar.input.getAttribute('aria-required');
353
- this.calendar.altInput.id = this._input.id;
354
- this.calendar.altInput.setAttribute('aria-labelledby', labelledbyIds);
355
- this.calendar.altInput.setAttribute('aria-required', isRequired);
356
- this._input.removeAttribute('id');
357
- this._input.removeAttribute('aria-labelledby');
358
- this._input.removeAttribute('aria-required');
359
347
  const excludedFromMaskFormats = ['MMMM'];
360
348
  if (!this.settings.readOnly && !_.some(excludedFromMaskFormats, format => _.includes(this.settings.format, format))) {
361
349
  // Enforce the input mask of the format.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6211.5d30602",
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": {