@formio/js 5.2.1-rc.1 → 5.2.1-rc.3

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.
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
22
22
 
23
- /*! formiojs v5.2.1-rc.1 | https://unpkg.com/formiojs@5.2.1-rc.1/LICENSE.txt */
23
+ /*! formiojs v5.2.1-rc.3 | https://unpkg.com/formiojs@5.2.1-rc.3/LICENSE.txt */
24
24
 
25
25
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
26
26
 
package/lib/cjs/Embed.js CHANGED
@@ -418,7 +418,7 @@ Formio.formioReady = new Promise((ready, reject) => {
418
418
  _a._formioReady = ready;
419
419
  _a._formioReadyReject = reject;
420
420
  });
421
- Formio.version = '5.2.1-rc.1';
421
+ Formio.version = '5.2.1-rc.3';
422
422
  // Create a report.
423
423
  Formio.Report = {
424
424
  create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
package/lib/cjs/Formio.js CHANGED
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
11
11
  const providers_1 = __importDefault(require("./providers"));
12
12
  sdk_1.Formio.cdn = new CDN_1.default();
13
13
  sdk_1.Formio.Providers = providers_1.default;
14
- sdk_1.Formio.version = '5.2.1-rc.1';
14
+ sdk_1.Formio.version = '5.2.1-rc.3';
15
15
  CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
16
16
  const isNil = (val) => val === null || val === undefined;
17
17
  sdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -454,18 +454,20 @@ class PDFBuilder extends WebformBuilder_1.default {
454
454
  const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
455
455
  // update elements which path was duplicated if any pathes have been changed
456
456
  if (!lodash_1.default.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
457
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
458
- if (this.repeatablePathsComps.includes(comp.component)) {
459
- this.webform.postMessage({ name: 'updateElement', data: comp.component });
460
- }
461
- });
457
+ if (!lodash_1.default.isEmpty(this.repeatablePathsComps)) {
458
+ (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
459
+ if (this.repeatablePathsComps.includes(comp.component)) {
460
+ this.webform.postMessage({ name: 'updateElement', data: comp.component });
461
+ }
462
+ });
463
+ }
462
464
  this.repeatablePathsComps = repeatablePathsComps;
463
465
  }
464
466
  if (!repeatablePathsComps.length) {
465
467
  return;
466
468
  }
467
469
  (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
468
- if (this.repeatablePathsComps.includes(comp)) {
470
+ if (this.repeatablePathsComps.includes(comp.component)) {
469
471
  this.webform.postMessage({
470
472
  name: 'showBuilderErrors',
471
473
  data: {
@@ -1114,7 +1114,7 @@ class Webform extends NestedDataComponent_1.default {
1114
1114
  const componentErrors = {};
1115
1115
  errors.forEach((err) => {
1116
1116
  var _a, _b;
1117
- const path = err.path || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1117
+ const path = (0, utils_1.getStringFromComponentPath)(err.path) || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1118
1118
  if (!componentErrors[path]) {
1119
1119
  componentErrors[path] = [];
1120
1120
  }
@@ -89,6 +89,7 @@ export default class SelectComponent extends ListComponent {
89
89
  disableInfiniteScroll(): void;
90
90
  set serverCount(value: any);
91
91
  get serverCount(): any;
92
+ shouldResetChoicesItems(items: any): boolean;
92
93
  setItems(items: any, fromSearch: any): void;
93
94
  selectItems: any;
94
95
  set downloadedResources(value: any);
@@ -356,6 +356,18 @@ class SelectComponent extends ListComponent_1.default {
356
356
  this.downloadedResources.serverCount = this.downloadedResources.length;
357
357
  this.serverCount = this.downloadedResources.length;
358
358
  }
359
+ shouldResetChoicesItems(items) {
360
+ if (this.choices._store.choices.length !== items.length) {
361
+ return true;
362
+ }
363
+ for (let item of items) {
364
+ const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
365
+ if (!choicesItem) {
366
+ return true;
367
+ }
368
+ }
369
+ return false;
370
+ }
359
371
  /* eslint-disable max-statements */
360
372
  setItems(items, fromSearch) {
361
373
  var _a, _b;
@@ -442,7 +454,7 @@ class SelectComponent extends ListComponent_1.default {
442
454
  this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));
443
455
  });
444
456
  if (this.choices) {
445
- this.choices.setChoices(this.selectOptions, 'value', 'label', true);
457
+ this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
446
458
  }
447
459
  else if (this.loading) {
448
460
  // Re-attach select input.
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = '5.2.1-rc.1';
17
+ static version = '5.2.1-rc.3';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
package/lib/mjs/Formio.js CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
4
4
  import Providers from './providers';
5
5
  FormioCore.cdn = new CDN();
6
6
  FormioCore.Providers = Providers;
7
- FormioCore.version = '5.2.1-rc.1';
7
+ FormioCore.version = '5.2.1-rc.3';
8
8
  CDN.defaultCDN = FormioCore.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
9
9
  const isNil = (val) => val === null || val === undefined;
10
10
  FormioCore.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -447,18 +447,20 @@ export default class PDFBuilder extends WebformBuilder {
447
447
  const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
448
448
  // update elements which path was duplicated if any pathes have been changed
449
449
  if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
450
- eachComponent(this.webform.getComponents(), (comp) => {
451
- if (this.repeatablePathsComps.includes(comp.component)) {
452
- this.webform.postMessage({ name: 'updateElement', data: comp.component });
453
- }
454
- });
450
+ if (!_.isEmpty(this.repeatablePathsComps)) {
451
+ eachComponent(this.webform.getComponents(), (comp) => {
452
+ if (this.repeatablePathsComps.includes(comp.component)) {
453
+ this.webform.postMessage({ name: 'updateElement', data: comp.component });
454
+ }
455
+ });
456
+ }
455
457
  this.repeatablePathsComps = repeatablePathsComps;
456
458
  }
457
459
  if (!repeatablePathsComps.length) {
458
460
  return;
459
461
  }
460
462
  eachComponent(this.webform.getComponents(), (comp) => {
461
- if (this.repeatablePathsComps.includes(comp)) {
463
+ if (this.repeatablePathsComps.includes(comp.component)) {
462
464
  this.webform.postMessage({
463
465
  name: 'showBuilderErrors',
464
466
  data: {
@@ -1116,7 +1116,7 @@ export default class Webform extends NestedDataComponent {
1116
1116
  // Mark any components as invalid if in a custom message.
1117
1117
  const componentErrors = {};
1118
1118
  errors.forEach((err) => {
1119
- const path = err.path || err.context?.path || err.component?.key;
1119
+ const path = getStringFromComponentPath(err.path) || err.context?.path || err.component?.key;
1120
1120
  if (!componentErrors[path]) {
1121
1121
  componentErrors[path] = [];
1122
1122
  }
@@ -89,6 +89,7 @@ export default class SelectComponent extends ListComponent {
89
89
  disableInfiniteScroll(): void;
90
90
  set serverCount(value: any);
91
91
  get serverCount(): any;
92
+ shouldResetChoicesItems(items: any): boolean;
92
93
  setItems(items: any, fromSearch: any): void;
93
94
  selectItems: any;
94
95
  set downloadedResources(value: any);
@@ -360,6 +360,18 @@ export default class SelectComponent extends ListComponent {
360
360
  this.downloadedResources.serverCount = this.downloadedResources.length;
361
361
  this.serverCount = this.downloadedResources.length;
362
362
  }
363
+ shouldResetChoicesItems(items) {
364
+ if (this.choices._store.choices.length !== items.length) {
365
+ return true;
366
+ }
367
+ for (let item of items) {
368
+ const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
369
+ if (!choicesItem) {
370
+ return true;
371
+ }
372
+ }
373
+ return false;
374
+ }
363
375
  /* eslint-disable max-statements */
364
376
  setItems(items, fromSearch) {
365
377
  this.selectItems = items;
@@ -445,7 +457,7 @@ export default class SelectComponent extends ListComponent {
445
457
  this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, _.get(item, this.component.idPath, String(index)));
446
458
  });
447
459
  if (this.choices) {
448
- this.choices.setChoices(this.selectOptions, 'value', 'label', true);
460
+ this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
449
461
  }
450
462
  else if (this.loading) {
451
463
  // Re-attach select input.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.2.1-rc.1",
3
+ "version": "5.2.1-rc.3",
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
  "homepage": "https://github.com/formio/formio.js#readme",
81
81
  "dependencies": {
82
82
  "@formio/bootstrap": "3.1.2-rc.1",
83
- "@formio/core": "2.5.1-rc.2",
83
+ "@formio/core": "2.5.1-rc.3",
84
84
  "@formio/text-mask-addons": "^3.8.0-formio.4",
85
85
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
86
86
  "abortcontroller-polyfill": "^1.7.5",