@formio/js 5.1.2-rc.3 → 5.1.2-rc.4

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.1.2-rc.3 | https://unpkg.com/formiojs@5.1.2-rc.3/LICENSE.txt */
23
+ /*! formiojs v5.1.2-rc.4 | https://unpkg.com/formiojs@5.1.2-rc.4/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
 
@@ -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.1.2-rc.3 | https://unpkg.com/formiojs@5.1.2-rc.3/LICENSE.txt */
23
+ /*! formiojs v5.1.2-rc.4 | https://unpkg.com/formiojs@5.1.2-rc.4/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.1.2-rc.3';
421
+ Formio.version = '5.1.2-rc.4';
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.1.2-rc.3';
14
+ sdk_1.Formio.version = '5.1.2-rc.4';
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) {
@@ -9,7 +9,7 @@ export default class ButtonComponent extends Field {
9
9
  };
10
10
  static savedValueTypes(schema: any): string[];
11
11
  constructor(component: any, options: any, data: any);
12
- filesUploading: any[];
12
+ filesUploading: number;
13
13
  get inputInfo(): any;
14
14
  get labelInfo(): {
15
15
  hidden: boolean;
@@ -39,7 +39,7 @@ class ButtonComponent extends Field_1.default {
39
39
  }
40
40
  constructor(component, options, data) {
41
41
  super(component, options, data);
42
- this.filesUploading = [];
42
+ this.filesUploading = 0;
43
43
  }
44
44
  get defaultSchema() {
45
45
  return ButtonComponent.schema();
@@ -147,16 +147,13 @@ class ButtonComponent extends Field_1.default {
147
147
  this.addClass(this.refs.buttonMessageContainer, 'has-error');
148
148
  this.setContent(this.refs.buttonMessage, resultMessage);
149
149
  }, true);
150
- this.on('fileUploadingStart', (filePromise) => {
151
- this.filesUploading.push(filePromise);
150
+ this.on('fileUploadingStart', () => {
151
+ this.filesUploading++;
152
152
  this.disabled = true;
153
153
  this.setDisabled(this.refs.button, this.disabled);
154
154
  }, true);
155
- this.on('fileUploadingEnd', (filePromise) => {
156
- const index = this.filesUploading.indexOf(filePromise);
157
- if (index !== -1) {
158
- this.filesUploading.splice(index, 1);
159
- }
155
+ this.on('fileUploadingEnd', () => {
156
+ this.filesUploading--;
160
157
  this.disabled = this.shouldDisabled ? true : false;
161
158
  this.setDisabled(this.refs.button, this.disabled);
162
159
  }, true);
@@ -252,8 +249,7 @@ class ButtonComponent extends Field_1.default {
252
249
  }
253
250
  }
254
251
  get shouldDisabled() {
255
- var _a;
256
- return super.shouldDisabled || !!((_a = this.filesUploading) === null || _a === void 0 ? void 0 : _a.length) || this.isDisabledOnInvalid;
252
+ return super.shouldDisabled || this.filesUploading > 0 || this.isDisabledOnInvalid;
257
253
  }
258
254
  attach(element) {
259
255
  this.loadRefs(element, {
@@ -477,6 +477,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
477
477
  options.row = `${rowIndex}-${colIndex}`;
478
478
  options.rowIndex = rowIndex;
479
479
  options.onChange = (flags, changed, modified) => {
480
+ if (changed.component.type === 'form') {
481
+ const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
482
+ lodash_1.default.set(formComp, 'components', changed.component.components);
483
+ }
480
484
  this.triggerChange({ modified });
481
485
  };
482
486
  let columnComponent;
@@ -145,7 +145,7 @@ export default class FileComponent extends Field {
145
145
  }[]>;
146
146
  updateProgress(fileInfo: any, progressEvent: any): void;
147
147
  getMultipartOptions(fileToSync: any): any;
148
- uploadFile(fileToSync: any): any;
148
+ uploadFile(fileToSync: any): Promise<any>;
149
149
  upload(): Promise<void | {
150
150
  fileToSync: never;
151
151
  fileInfo: any;
@@ -898,17 +898,18 @@ class FileComponent extends Field_1.default {
898
898
  } }) : false;
899
899
  }
900
900
  uploadFile(fileToSync) {
901
- const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
902
- // Progress callback
903
- this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
904
- this.emit('fileUploadingStart', filePromise);
905
- },
906
- // Abort upload callback
907
- (abort) => this.abortUploads.push({
908
- id: fileToSync.id,
909
- abort,
910
- }), this.getMultipartOptions(fileToSync));
911
- return filePromise;
901
+ return __awaiter(this, void 0, void 0, function* () {
902
+ return yield this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
903
+ // Progress callback
904
+ this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
905
+ this.emit('fileUploadingStart');
906
+ },
907
+ // Abort upload callback
908
+ (abort) => this.abortUploads.push({
909
+ id: fileToSync.id,
910
+ abort,
911
+ }), this.getMultipartOptions(fileToSync));
912
+ });
912
913
  }
913
914
  upload() {
914
915
  return __awaiter(this, void 0, void 0, function* () {
@@ -916,7 +917,6 @@ class FileComponent extends Field_1.default {
916
917
  return Promise.resolve();
917
918
  }
918
919
  return yield Promise.all(this.filesToSync.filesToUpload.map((fileToSync) => __awaiter(this, void 0, void 0, function* () {
919
- let filePromise = null;
920
920
  let fileInfo = null;
921
921
  try {
922
922
  if (fileToSync.isValidationError) {
@@ -925,13 +925,12 @@ class FileComponent extends Field_1.default {
925
925
  fileInfo,
926
926
  };
927
927
  }
928
- filePromise = this.uploadFile(fileToSync);
929
- fileInfo = yield filePromise;
928
+ fileInfo = yield this.uploadFile(fileToSync);
930
929
  fileToSync.status = 'success';
931
930
  fileToSync.message = this.t('Succefully uploaded');
932
931
  fileInfo.originalName = fileToSync.originalName;
933
932
  fileInfo.hash = fileToSync.hash;
934
- this.emit('fileUploadingEnd', filePromise);
933
+ this.emit('fileUploadingEnd');
935
934
  }
936
935
  catch (response) {
937
936
  fileToSync.status = 'error';
@@ -941,7 +940,7 @@ class FileComponent extends Field_1.default {
941
940
  : response.type === 'abort'
942
941
  ? this.t('Request was aborted')
943
942
  : response.toString();
944
- this.emit('fileUploadingEnd', filePromise);
943
+ this.emit('fileUploadingEnd');
945
944
  this.emit('fileUploadError', {
946
945
  fileToSync,
947
946
  response,
@@ -27,7 +27,7 @@ class FormioUploadAdapter {
27
27
  null,
28
28
  null
29
29
  ];
30
- const uploadPromise = this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart', uploadPromise)).then((result) => {
30
+ this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart')).then((result) => {
31
31
  return this.fileService.downloadFile(result);
32
32
  }).then((result) => {
33
33
  return resolve({
@@ -37,7 +37,7 @@ class FormioUploadAdapter {
37
37
  console.warn('An Error occured while uploading file', err);
38
38
  reject(err);
39
39
  }).finally(() => {
40
- this.component.emit('fileUploadingEnd', uploadPromise);
40
+ this.component.emit('fileUploadingEnd');
41
41
  });
42
42
  }));
43
43
  }
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.1.2-rc.3';
17
+ static version = '5.1.2-rc.4';
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.1.2-rc.3';
7
+ FormioCore.version = '5.1.2-rc.4';
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) {
@@ -9,7 +9,7 @@ export default class ButtonComponent extends Field {
9
9
  };
10
10
  static savedValueTypes(schema: any): string[];
11
11
  constructor(component: any, options: any, data: any);
12
- filesUploading: any[];
12
+ filesUploading: number;
13
13
  get inputInfo(): any;
14
14
  get labelInfo(): {
15
15
  hidden: boolean;
@@ -34,7 +34,7 @@ export default class ButtonComponent extends Field {
34
34
  }
35
35
  constructor(component, options, data) {
36
36
  super(component, options, data);
37
- this.filesUploading = [];
37
+ this.filesUploading = 0;
38
38
  }
39
39
  get defaultSchema() {
40
40
  return ButtonComponent.schema();
@@ -142,16 +142,13 @@ export default class ButtonComponent extends Field {
142
142
  this.addClass(this.refs.buttonMessageContainer, 'has-error');
143
143
  this.setContent(this.refs.buttonMessage, resultMessage);
144
144
  }, true);
145
- this.on('fileUploadingStart', (filePromise) => {
146
- this.filesUploading.push(filePromise);
145
+ this.on('fileUploadingStart', () => {
146
+ this.filesUploading++;
147
147
  this.disabled = true;
148
148
  this.setDisabled(this.refs.button, this.disabled);
149
149
  }, true);
150
- this.on('fileUploadingEnd', (filePromise) => {
151
- const index = this.filesUploading.indexOf(filePromise);
152
- if (index !== -1) {
153
- this.filesUploading.splice(index, 1);
154
- }
150
+ this.on('fileUploadingEnd', () => {
151
+ this.filesUploading--;
155
152
  this.disabled = this.shouldDisabled ? true : false;
156
153
  this.setDisabled(this.refs.button, this.disabled);
157
154
  }, true);
@@ -247,7 +244,7 @@ export default class ButtonComponent extends Field {
247
244
  }
248
245
  }
249
246
  get shouldDisabled() {
250
- return super.shouldDisabled || !!this.filesUploading?.length || this.isDisabledOnInvalid;
247
+ return super.shouldDisabled || this.filesUploading > 0 || this.isDisabledOnInvalid;
251
248
  }
252
249
  attach(element) {
253
250
  this.loadRefs(element, {
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
3
- import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
3
+ import { fastCloneDeep, getFocusableElements, getComponent } from '../../utils/utils';
4
4
  import dragula from 'dragula';
5
5
  export default class DataGridComponent extends NestedArrayComponent {
6
6
  static schema(...extend) {
@@ -473,6 +473,10 @@ export default class DataGridComponent extends NestedArrayComponent {
473
473
  options.row = `${rowIndex}-${colIndex}`;
474
474
  options.rowIndex = rowIndex;
475
475
  options.onChange = (flags, changed, modified) => {
476
+ if (changed.component.type === 'form') {
477
+ const formComp = getComponent(this.component.components, changed.component.key);
478
+ _.set(formComp, 'components', changed.component.components);
479
+ }
476
480
  this.triggerChange({ modified });
477
481
  };
478
482
  let columnComponent;
@@ -145,7 +145,7 @@ export default class FileComponent extends Field {
145
145
  }[]>;
146
146
  updateProgress(fileInfo: any, progressEvent: any): void;
147
147
  getMultipartOptions(fileToSync: any): any;
148
- uploadFile(fileToSync: any): any;
148
+ uploadFile(fileToSync: any): Promise<any>;
149
149
  upload(): Promise<void | {
150
150
  fileToSync: never;
151
151
  fileInfo: any;
@@ -896,25 +896,23 @@ export default class FileComponent extends Field {
896
896
  },
897
897
  } : false;
898
898
  }
899
- uploadFile(fileToSync) {
900
- const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
899
+ async uploadFile(fileToSync) {
900
+ return await this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
901
901
  // Progress callback
902
902
  this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
903
- this.emit('fileUploadingStart', filePromise);
903
+ this.emit('fileUploadingStart');
904
904
  },
905
905
  // Abort upload callback
906
906
  (abort) => this.abortUploads.push({
907
907
  id: fileToSync.id,
908
908
  abort,
909
909
  }), this.getMultipartOptions(fileToSync));
910
- return filePromise;
911
910
  }
912
911
  async upload() {
913
912
  if (!this.filesToSync.filesToUpload.length) {
914
913
  return Promise.resolve();
915
914
  }
916
915
  return await Promise.all(this.filesToSync.filesToUpload.map(async (fileToSync) => {
917
- let filePromise = null;
918
916
  let fileInfo = null;
919
917
  try {
920
918
  if (fileToSync.isValidationError) {
@@ -923,13 +921,12 @@ export default class FileComponent extends Field {
923
921
  fileInfo,
924
922
  };
925
923
  }
926
- filePromise = this.uploadFile(fileToSync);
927
- fileInfo = await filePromise;
924
+ fileInfo = await this.uploadFile(fileToSync);
928
925
  fileToSync.status = 'success';
929
926
  fileToSync.message = this.t('Succefully uploaded');
930
927
  fileInfo.originalName = fileToSync.originalName;
931
928
  fileInfo.hash = fileToSync.hash;
932
- this.emit('fileUploadingEnd', filePromise);
929
+ this.emit('fileUploadingEnd');
933
930
  }
934
931
  catch (response) {
935
932
  fileToSync.status = 'error';
@@ -939,7 +936,7 @@ export default class FileComponent extends Field {
939
936
  : response.type === 'abort'
940
937
  ? this.t('Request was aborted')
941
938
  : response.toString();
942
- this.emit('fileUploadingEnd', filePromise);
939
+ this.emit('fileUploadingEnd');
943
940
  this.emit('fileUploadError', {
944
941
  fileToSync,
945
942
  response,
@@ -24,7 +24,7 @@ class FormioUploadAdapter {
24
24
  null,
25
25
  null
26
26
  ];
27
- const uploadPromise = this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart', uploadPromise)).then((result) => {
27
+ this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart')).then((result) => {
28
28
  return this.fileService.downloadFile(result);
29
29
  }).then((result) => {
30
30
  return resolve({
@@ -34,7 +34,7 @@ class FormioUploadAdapter {
34
34
  console.warn('An Error occured while uploading file', err);
35
35
  reject(err);
36
36
  }).finally(() => {
37
- this.component.emit('fileUploadingEnd', uploadPromise);
37
+ this.component.emit('fileUploadingEnd');
38
38
  });
39
39
  }));
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.2-rc.3",
3
+ "version": "5.1.2-rc.4",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {