@formio/js 5.2.0-rc.8 → 5.2.0

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.0-rc.8 | https://unpkg.com/formiojs@5.2.0-rc.8/LICENSE.txt */
23
+ /*! formiojs v5.2.0 | https://unpkg.com/formiojs@5.2.0/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.0-rc.8';
421
+ Formio.version = '5.2.0';
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.0-rc.8';
14
+ sdk_1.Formio.version = '5.2.0';
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) {
@@ -51,5 +51,6 @@ export default class PDFBuilder extends WebformBuilder {
51
51
  onDropzoneDrop(e: any): boolean;
52
52
  dropEvent: any;
53
53
  onDragEnd(e: any): void;
54
+ repeatablePathsComps: any[] | undefined;
54
55
  }
55
56
  import WebformBuilder from './WebformBuilder';
@@ -451,21 +451,21 @@ class PDFBuilder extends WebformBuilder_1.default {
451
451
  e.target.style.cursor = 'default';
452
452
  }
453
453
  highlightInvalidComponents() {
454
- const repeatablePaths = this.findRepeatablePaths();
454
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
455
455
  // update elements which path was duplicated if any pathes have been changed
456
- if (!lodash_1.default.isEqual(this.repeatablePaths, repeatablePaths)) {
457
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
458
- if (this.repeatablePaths.includes(path)) {
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
459
  this.webform.postMessage({ name: 'updateElement', data: comp.component });
460
460
  }
461
461
  });
462
- this.repeatablePaths = repeatablePaths;
462
+ this.repeatablePathsComps = repeatablePathsComps;
463
463
  }
464
- if (!repeatablePaths.length) {
464
+ if (!repeatablePathsComps.length) {
465
465
  return;
466
466
  }
467
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
468
- if (this.repeatablePaths.includes(path)) {
467
+ (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
468
+ if (this.repeatablePathsComps.includes(comp)) {
469
469
  this.webform.postMessage({
470
470
  name: 'showBuilderErrors',
471
471
  data: {
@@ -77,7 +77,7 @@ export default class WebformBuilder extends Component {
77
77
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
- findRepeatablePaths(): any[];
80
+ findComponentsWithRepeatablePaths(): any[];
81
81
  highlightInvalidComponents(): void;
82
82
  /**
83
83
  * Called when a new component is saved.
@@ -1126,25 +1126,37 @@ class WebformBuilder extends Component_1.default {
1126
1126
  // Called when we update a component.
1127
1127
  this.emit('updateComponent', component);
1128
1128
  }
1129
- findRepeatablePaths() {
1130
- const repeatablePaths = [];
1129
+ findComponentsWithRepeatablePaths() {
1130
+ const repeatablePaths = {};
1131
1131
  const keys = new Map();
1132
1132
  (0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
1133
+ var _a, _b;
1134
+ const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1133
1135
  if (keys.has(paths.dataPath)) {
1134
- repeatablePaths.push(paths.dataPath);
1136
+ const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
1137
+ repeatablePaths[paths.dataPath] = {
1138
+ comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
1139
+ onlyRadioCheckboxes,
1140
+ };
1135
1141
  }
1136
1142
  else {
1137
- keys.set(paths.dataPath, true);
1143
+ keys.set(paths.dataPath, comp);
1138
1144
  }
1139
1145
  }, true);
1140
- return repeatablePaths;
1146
+ const componentsWithRepeatablePaths = [];
1147
+ Object.keys(repeatablePaths).forEach((path) => {
1148
+ const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
1149
+ if (!onlyRadioCheckboxes) {
1150
+ componentsWithRepeatablePaths.push(...comps);
1151
+ }
1152
+ });
1153
+ return componentsWithRepeatablePaths;
1141
1154
  }
1142
1155
  highlightInvalidComponents() {
1143
- const repeatablePaths = this.findRepeatablePaths();
1156
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
1144
1157
  let hasInvalidComponents = false;
1145
1158
  this.webform.everyComponent((comp) => {
1146
- const path = comp.path;
1147
- if (repeatablePaths.includes(path)) {
1159
+ if (repeatablePathsComps.includes(comp.component)) {
1148
1160
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1149
1161
  hasInvalidComponents = true;
1150
1162
  }
@@ -75,6 +75,12 @@ class Components {
75
75
  if (comp.path) {
76
76
  comp.componentsMap[comp.path] = comp;
77
77
  }
78
+ // Reset the componentMatches on the root element if any new component is created.
79
+ let parent = comp.parent;
80
+ while (parent) {
81
+ parent.componentMatches = {};
82
+ parent = parent.parent;
83
+ }
78
84
  return comp;
79
85
  }
80
86
  }
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
108
108
  * @returns {any} - The component that is located.
109
109
  */
110
110
  getComponent(path: string): any;
111
+ componentMatches: {} | undefined;
111
112
  /**
112
113
  * Return a component provided the Id of the component.
113
114
  * @param {string} id - The Id of the component.
@@ -311,6 +311,13 @@ class NestedComponent extends Field_1.default {
311
311
  */
312
312
  getComponent(path) {
313
313
  var _a;
314
+ // If the component is found
315
+ if (!this.componentMatches) {
316
+ this.componentMatches = {};
317
+ }
318
+ if (this.componentMatches && this.componentMatches[path]) {
319
+ return this.componentMatches[path];
320
+ }
314
321
  path = utils_1.default.getStringFromComponentPath(path);
315
322
  const matches = {
316
323
  path: undefined,
@@ -336,7 +343,8 @@ class NestedComponent extends Field_1.default {
336
343
  return match;
337
344
  });
338
345
  });
339
- return (_a = utils_1.default.getBestMatch(matches)) === null || _a === void 0 ? void 0 : _a.instance;
346
+ this.componentMatches[path] = (_a = utils_1.default.getBestMatch(matches)) === null || _a === void 0 ? void 0 : _a.instance;
347
+ return this.componentMatches[path];
340
348
  }
341
349
  /**
342
350
  * Return a component provided the Id of the component.
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.0-rc.8';
17
+ static version = '5.2.0';
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.0-rc.8';
7
+ FormioCore.version = '5.2.0';
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) {
@@ -51,5 +51,6 @@ export default class PDFBuilder extends WebformBuilder {
51
51
  onDropzoneDrop(e: any): boolean;
52
52
  dropEvent: any;
53
53
  onDragEnd(e: any): void;
54
+ repeatablePathsComps: any[] | undefined;
54
55
  }
55
56
  import WebformBuilder from './WebformBuilder';
@@ -444,21 +444,21 @@ export default class PDFBuilder extends WebformBuilder {
444
444
  e.target.style.cursor = 'default';
445
445
  }
446
446
  highlightInvalidComponents() {
447
- const repeatablePaths = this.findRepeatablePaths();
447
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
448
448
  // update elements which path was duplicated if any pathes have been changed
449
- if (!_.isEqual(this.repeatablePaths, repeatablePaths)) {
450
- eachComponent(this.webform.getComponents(), (comp, path) => {
451
- if (this.repeatablePaths.includes(path)) {
449
+ if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
450
+ eachComponent(this.webform.getComponents(), (comp) => {
451
+ if (this.repeatablePathsComps.includes(comp.component)) {
452
452
  this.webform.postMessage({ name: 'updateElement', data: comp.component });
453
453
  }
454
454
  });
455
- this.repeatablePaths = repeatablePaths;
455
+ this.repeatablePathsComps = repeatablePathsComps;
456
456
  }
457
- if (!repeatablePaths.length) {
457
+ if (!repeatablePathsComps.length) {
458
458
  return;
459
459
  }
460
- eachComponent(this.webform.getComponents(), (comp, path) => {
461
- if (this.repeatablePaths.includes(path)) {
460
+ eachComponent(this.webform.getComponents(), (comp) => {
461
+ if (this.repeatablePathsComps.includes(comp)) {
462
462
  this.webform.postMessage({
463
463
  name: 'showBuilderErrors',
464
464
  data: {
@@ -77,7 +77,7 @@ export default class WebformBuilder extends Component {
77
77
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
- findRepeatablePaths(): any[];
80
+ findComponentsWithRepeatablePaths(): any[];
81
81
  highlightInvalidComponents(): void;
82
82
  /**
83
83
  * Called when a new component is saved.
@@ -1110,25 +1110,36 @@ export default class WebformBuilder extends Component {
1110
1110
  // Called when we update a component.
1111
1111
  this.emit('updateComponent', component);
1112
1112
  }
1113
- findRepeatablePaths() {
1114
- const repeatablePaths = [];
1113
+ findComponentsWithRepeatablePaths() {
1114
+ const repeatablePaths = {};
1115
1115
  const keys = new Map();
1116
1116
  eachComponent(this.form.components, (comp, path, components, parent, paths) => {
1117
+ const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1117
1118
  if (keys.has(paths.dataPath)) {
1118
- repeatablePaths.push(paths.dataPath);
1119
+ const onlyRadioCheckboxes = repeatablePaths[paths.dataPath]?.onlyRadioCheckboxes === false ? false : isRadioCheckbox;
1120
+ repeatablePaths[paths.dataPath] = {
1121
+ comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
1122
+ onlyRadioCheckboxes,
1123
+ };
1119
1124
  }
1120
1125
  else {
1121
- keys.set(paths.dataPath, true);
1126
+ keys.set(paths.dataPath, comp);
1122
1127
  }
1123
1128
  }, true);
1124
- return repeatablePaths;
1129
+ const componentsWithRepeatablePaths = [];
1130
+ Object.keys(repeatablePaths).forEach((path) => {
1131
+ const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
1132
+ if (!onlyRadioCheckboxes) {
1133
+ componentsWithRepeatablePaths.push(...comps);
1134
+ }
1135
+ });
1136
+ return componentsWithRepeatablePaths;
1125
1137
  }
1126
1138
  highlightInvalidComponents() {
1127
- const repeatablePaths = this.findRepeatablePaths();
1139
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
1128
1140
  let hasInvalidComponents = false;
1129
1141
  this.webform.everyComponent((comp) => {
1130
- const path = comp.path;
1131
- if (repeatablePaths.includes(path)) {
1142
+ if (repeatablePathsComps.includes(comp.component)) {
1132
1143
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1133
1144
  hasInvalidComponents = true;
1134
1145
  }
@@ -72,6 +72,12 @@ export default class Components {
72
72
  if (comp.path) {
73
73
  comp.componentsMap[comp.path] = comp;
74
74
  }
75
+ // Reset the componentMatches on the root element if any new component is created.
76
+ let parent = comp.parent;
77
+ while (parent) {
78
+ parent.componentMatches = {};
79
+ parent = parent.parent;
80
+ }
75
81
  return comp;
76
82
  }
77
83
  }
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
108
108
  * @returns {any} - The component that is located.
109
109
  */
110
110
  getComponent(path: string): any;
111
+ componentMatches: {} | undefined;
111
112
  /**
112
113
  * Return a component provided the Id of the component.
113
114
  * @param {string} id - The Id of the component.
@@ -308,6 +308,13 @@ export default class NestedComponent extends Field {
308
308
  * @returns {any} - The component that is located.
309
309
  */
310
310
  getComponent(path) {
311
+ // If the component is found
312
+ if (!this.componentMatches) {
313
+ this.componentMatches = {};
314
+ }
315
+ if (this.componentMatches && this.componentMatches[path]) {
316
+ return this.componentMatches[path];
317
+ }
311
318
  path = FormioUtils.getStringFromComponentPath(path);
312
319
  const matches = {
313
320
  path: undefined,
@@ -332,7 +339,8 @@ export default class NestedComponent extends Field {
332
339
  return match;
333
340
  });
334
341
  });
335
- return FormioUtils.getBestMatch(matches)?.instance;
342
+ this.componentMatches[path] = FormioUtils.getBestMatch(matches)?.instance;
343
+ return this.componentMatches[path];
336
344
  }
337
345
  /**
338
346
  * Return a component provided the Id of the component.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.2.0-rc.8",
3
+ "version": "5.2.0",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -81,7 +81,7 @@
81
81
  "dependencies": {
82
82
  "@formio/bootstrap": "3.1.1",
83
83
  "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.5.0-rc.5",
84
+ "@formio/core": "2.5.0",
85
85
  "@formio/text-mask-addons": "^3.8.0-formio.4",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",