@formio/js 5.1.1 → 5.1.2-rc.2

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.
Files changed (36) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +532 -532
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +532 -532
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +6 -6
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +5 -5
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Embed.js +1 -1
  17. package/lib/cjs/Formio.js +1 -1
  18. package/lib/cjs/components/_classes/component/Component.js +3 -2
  19. package/lib/cjs/components/_classes/list/ListComponent.js +2 -2
  20. package/lib/cjs/components/file/File.js +7 -2
  21. package/lib/cjs/components/number/Number.js +11 -4
  22. package/lib/cjs/components/radio/Radio.js +10 -0
  23. package/lib/cjs/components/select/Select.js +2 -2
  24. package/lib/cjs/components/signature/Signature.js +3 -1
  25. package/lib/cjs/utils/utils.js +2 -1
  26. package/lib/mjs/Embed.js +1 -1
  27. package/lib/mjs/Formio.js +1 -1
  28. package/lib/mjs/components/_classes/component/Component.js +3 -2
  29. package/lib/mjs/components/_classes/list/ListComponent.js +2 -2
  30. package/lib/mjs/components/file/File.js +7 -2
  31. package/lib/mjs/components/number/Number.js +11 -4
  32. package/lib/mjs/components/radio/Radio.js +10 -0
  33. package/lib/mjs/components/select/Select.js +2 -2
  34. package/lib/mjs/components/signature/Signature.js +3 -1
  35. package/lib/mjs/utils/utils.js +2 -1
  36. package/package.json +3 -3
@@ -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.1 | https://unpkg.com/formiojs@5.1.1/LICENSE.txt */
23
+ /*! formiojs v5.1.2-rc.2 | https://unpkg.com/formiojs@5.1.2-rc.2/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.1';
421
+ Formio.version = '5.1.2-rc.2';
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.1';
14
+ sdk_1.Formio.version = '5.1.2-rc.2';
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) {
@@ -2605,7 +2605,7 @@ class Component extends Element_1.default {
2605
2605
  }
2606
2606
  return value;
2607
2607
  };
2608
- if (this.defaultMask) {
2608
+ if (Array.isArray(this.defaultMask) ? this.defaultMask.length > 0 : this.defaultMask) {
2609
2609
  if (Array.isArray(defaultValue)) {
2610
2610
  defaultValue = defaultValue.map(checkMask);
2611
2611
  }
@@ -2866,7 +2866,8 @@ class Component extends Element_1.default {
2866
2866
  if ((this.options.readOnly && !this.options.pdf && !this.component.calculateValue) ||
2867
2867
  !(this.component.calculateValue || this.component.calculateValueVariable) ||
2868
2868
  (this.options.server && !this.component.calculateServer) ||
2869
- (flags.dataSourceInitialLoading && allowOverride)) {
2869
+ (flags.dataSourceInitialLoading && allowOverride) ||
2870
+ (this.options.readOnly && this.options.pdf && allowOverride && lodash_1.default.get(this.root, 'submission._id', false))) {
2870
2871
  return false;
2871
2872
  }
2872
2873
  const dataValue = this.dataValue;
@@ -29,9 +29,9 @@ class ListComponent extends Field_1.default {
29
29
  get dataReady() {
30
30
  // If the root submission has been set, and we are still not attached, then assume
31
31
  // that our data is ready.
32
- if (this.root &&
32
+ if ((this.root &&
33
33
  this.root.submissionSet &&
34
- !this.attached) {
34
+ !this.attached) || !this.visible) {
35
35
  return Promise.resolve();
36
36
  }
37
37
  return this.itemsLoaded;
@@ -899,14 +899,17 @@ class FileComponent extends Field_1.default {
899
899
  }
900
900
  uploadFile(fileToSync) {
901
901
  return __awaiter(this, void 0, void 0, function* () {
902
- return yield this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
902
+ const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
903
903
  // Progress callback
904
- this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => { },
904
+ this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
905
+ this.emit('fileUploadingStart', filePromise);
906
+ },
905
907
  // Abort upload callback
906
908
  (abort) => this.abortUploads.push({
907
909
  id: fileToSync.id,
908
910
  abort,
909
911
  }), this.getMultipartOptions(fileToSync));
912
+ return yield filePromise;
910
913
  });
911
914
  }
912
915
  upload() {
@@ -928,6 +931,7 @@ class FileComponent extends Field_1.default {
928
931
  fileToSync.message = this.t('Succefully uploaded');
929
932
  fileInfo.originalName = fileToSync.originalName;
930
933
  fileInfo.hash = fileToSync.hash;
934
+ this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
931
935
  }
932
936
  catch (response) {
933
937
  fileToSync.status = 'error';
@@ -937,6 +941,7 @@ class FileComponent extends Field_1.default {
937
941
  : response.type === 'abort'
938
942
  ? this.t('Request was aborted')
939
943
  : response.toString();
944
+ this.emit('fileUploadingEnd', Promise.reject(response));
940
945
  this.emit('fileUploadError', {
941
946
  fileToSync,
942
947
  response,
@@ -170,14 +170,21 @@ class NumberComponent extends Input_1.default {
170
170
  if (typeof input === 'string') {
171
171
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
172
172
  }
173
- let value = parseFloat(input);
174
- if (!lodash_1.default.isNaN(value)) {
173
+ let value;
174
+ if (!lodash_1.default.isNaN(input)) {
175
175
  // Format scientific notation
176
- if (/e/i.test(String(value))) {
176
+ if (/[0-9]+[eE]/.test(String(input))) {
177
+ // Convert to exponential notation will depend on the decimal limit set in the component
178
+ // Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
179
+ // Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
180
+ // if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
181
+ // if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
182
+ value = parseFloat(input);
177
183
  value = value.toExponential(this.decimalLimit);
178
184
  }
179
185
  else {
180
- value = String(value).replace('.', this.decimalSeparator);
186
+ value = parseFloat(input);
187
+ value = !lodash_1.default.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
181
188
  }
182
189
  }
183
190
  else {
@@ -293,6 +293,16 @@ class RadioComponent extends ListComponent_1.default {
293
293
  if (method.toUpperCase() === 'GET') {
294
294
  body = null;
295
295
  }
296
+ const limit = this.component.limit || 100;
297
+ const skip = this.isScrollLoading ? this.selectOptions.length : 0;
298
+ // Allow for url interpolation.
299
+ url = this.sanitize(this.interpolate(url, {
300
+ formioBase: Formio_1.Formio.getBaseUrl(),
301
+ search,
302
+ limit,
303
+ skip,
304
+ page: Math.abs(Math.floor(skip / limit))
305
+ }), this.shouldSanitizeValue);
296
306
  // Set ignoreCache if it is
297
307
  options.ignoreCache = this.component.ignoreCache;
298
308
  // Make the request.
@@ -530,13 +530,13 @@ class SelectComponent extends ListComponent_1.default {
530
530
  skip,
531
531
  };
532
532
  // Allow for url interpolation.
533
- url = this.interpolate(url, {
533
+ url = this.sanitize(this.interpolate(url, {
534
534
  formioBase: Formio_1.Formio.getBaseUrl(),
535
535
  search,
536
536
  limit,
537
537
  skip,
538
538
  page: Math.abs(Math.floor(skip / limit))
539
- });
539
+ }), this.shouldSanitizeValue);
540
540
  // Add search capability.
541
541
  if (this.component.searchField && search) {
542
542
  const searchValue = Array.isArray(search)
@@ -159,7 +159,9 @@ class SignatureComponent extends Input_1.default {
159
159
  if (this.dataValue) {
160
160
  this.setDataToSigaturePad();
161
161
  }
162
- this.showCanvas(true);
162
+ if (!this.disabled) {
163
+ this.showCanvas(true);
164
+ }
163
165
  }
164
166
  }
165
167
  renderElement(value, index) {
@@ -34,6 +34,7 @@ const Evaluator_1 = require("./Evaluator");
34
34
  Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
35
35
  const conditionOperators_1 = __importDefault(require("./conditionOperators"));
36
36
  exports.ConditionOperators = conditionOperators_1.default;
37
+ const core_1 = require("@formio/core");
37
38
  const interpolate = Evaluator_1.Evaluator.interpolate;
38
39
  exports.interpolate = interpolate;
39
40
  __exportStar(require("./formUtils"), exports);
@@ -271,7 +272,7 @@ function checkSimpleConditional(component, condition, row, data, instance) {
271
272
  default:
272
273
  result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
273
274
  }
274
- return show ? result : !result;
275
+ return (0, core_1.convertShowToBoolean)(show) ? result : !result;
275
276
  }
276
277
  }
277
278
  exports.checkSimpleConditional = checkSimpleConditional;
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.1';
17
+ static version = '5.1.2-rc.2';
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.1';
7
+ FormioCore.version = '5.1.2-rc.2';
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) {
@@ -2585,7 +2585,7 @@ export default class Component extends Element {
2585
2585
  }
2586
2586
  return value;
2587
2587
  };
2588
- if (this.defaultMask) {
2588
+ if (Array.isArray(this.defaultMask) ? this.defaultMask.length > 0 : this.defaultMask) {
2589
2589
  if (Array.isArray(defaultValue)) {
2590
2590
  defaultValue = defaultValue.map(checkMask);
2591
2591
  }
@@ -2845,7 +2845,8 @@ export default class Component extends Element {
2845
2845
  if ((this.options.readOnly && !this.options.pdf && !this.component.calculateValue) ||
2846
2846
  !(this.component.calculateValue || this.component.calculateValueVariable) ||
2847
2847
  (this.options.server && !this.component.calculateServer) ||
2848
- (flags.dataSourceInitialLoading && allowOverride)) {
2848
+ (flags.dataSourceInitialLoading && allowOverride) ||
2849
+ (this.options.readOnly && this.options.pdf && allowOverride && _.get(this.root, 'submission._id', false))) {
2849
2850
  return false;
2850
2851
  }
2851
2852
  const dataValue = this.dataValue;
@@ -24,9 +24,9 @@ export default class ListComponent extends Field {
24
24
  get dataReady() {
25
25
  // If the root submission has been set, and we are still not attached, then assume
26
26
  // that our data is ready.
27
- if (this.root &&
27
+ if ((this.root &&
28
28
  this.root.submissionSet &&
29
- !this.attached) {
29
+ !this.attached) || !this.visible) {
30
30
  return Promise.resolve();
31
31
  }
32
32
  return this.itemsLoaded;
@@ -897,14 +897,17 @@ export default class FileComponent extends Field {
897
897
  } : false;
898
898
  }
899
899
  async uploadFile(fileToSync) {
900
- return await this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
900
+ const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
901
901
  // Progress callback
902
- this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => { },
902
+ this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
903
+ this.emit('fileUploadingStart', filePromise);
904
+ },
903
905
  // Abort upload callback
904
906
  (abort) => this.abortUploads.push({
905
907
  id: fileToSync.id,
906
908
  abort,
907
909
  }), this.getMultipartOptions(fileToSync));
910
+ return await filePromise;
908
911
  }
909
912
  async upload() {
910
913
  if (!this.filesToSync.filesToUpload.length) {
@@ -924,6 +927,7 @@ export default class FileComponent extends Field {
924
927
  fileToSync.message = this.t('Succefully uploaded');
925
928
  fileInfo.originalName = fileToSync.originalName;
926
929
  fileInfo.hash = fileToSync.hash;
930
+ this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
927
931
  }
928
932
  catch (response) {
929
933
  fileToSync.status = 'error';
@@ -933,6 +937,7 @@ export default class FileComponent extends Field {
933
937
  : response.type === 'abort'
934
938
  ? this.t('Request was aborted')
935
939
  : response.toString();
940
+ this.emit('fileUploadingEnd', Promise.reject(response));
936
941
  this.emit('fileUploadError', {
937
942
  fileToSync,
938
943
  response,
@@ -168,14 +168,21 @@ export default class NumberComponent extends Input {
168
168
  if (typeof input === 'string') {
169
169
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
170
170
  }
171
- let value = parseFloat(input);
172
- if (!_.isNaN(value)) {
171
+ let value;
172
+ if (!_.isNaN(input)) {
173
173
  // Format scientific notation
174
- if (/e/i.test(String(value))) {
174
+ if (/[0-9]+[eE]/.test(String(input))) {
175
+ // Convert to exponential notation will depend on the decimal limit set in the component
176
+ // Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
177
+ // Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
178
+ // if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
179
+ // if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
180
+ value = parseFloat(input);
175
181
  value = value.toExponential(this.decimalLimit);
176
182
  }
177
183
  else {
178
- value = String(value).replace('.', this.decimalSeparator);
184
+ value = parseFloat(input);
185
+ value = !_.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
179
186
  }
180
187
  }
181
188
  else {
@@ -293,6 +293,16 @@ export default class RadioComponent extends ListComponent {
293
293
  if (method.toUpperCase() === 'GET') {
294
294
  body = null;
295
295
  }
296
+ const limit = this.component.limit || 100;
297
+ const skip = this.isScrollLoading ? this.selectOptions.length : 0;
298
+ // Allow for url interpolation.
299
+ url = this.sanitize(this.interpolate(url, {
300
+ formioBase: Formio.getBaseUrl(),
301
+ search,
302
+ limit,
303
+ skip,
304
+ page: Math.abs(Math.floor(skip / limit))
305
+ }), this.shouldSanitizeValue);
296
306
  // Set ignoreCache if it is
297
307
  options.ignoreCache = this.component.ignoreCache;
298
308
  // Make the request.
@@ -532,13 +532,13 @@ export default class SelectComponent extends ListComponent {
532
532
  skip,
533
533
  };
534
534
  // Allow for url interpolation.
535
- url = this.interpolate(url, {
535
+ url = this.sanitize(this.interpolate(url, {
536
536
  formioBase: Formio.getBaseUrl(),
537
537
  search,
538
538
  limit,
539
539
  skip,
540
540
  page: Math.abs(Math.floor(skip / limit))
541
- });
541
+ }), this.shouldSanitizeValue);
542
542
  // Add search capability.
543
543
  if (this.component.searchField && search) {
544
544
  const searchValue = Array.isArray(search)
@@ -156,7 +156,9 @@ export default class SignatureComponent extends Input {
156
156
  if (this.dataValue) {
157
157
  this.setDataToSigaturePad();
158
158
  }
159
- this.showCanvas(true);
159
+ if (!this.disabled) {
160
+ this.showCanvas(true);
161
+ }
160
162
  }
161
163
  }
162
164
  renderElement(value, index) {
@@ -8,6 +8,7 @@ import dompurify from 'dompurify';
8
8
  import { getValue } from './formUtils';
9
9
  import { Evaluator } from './Evaluator';
10
10
  import ConditionOperators from './conditionOperators';
11
+ import { convertShowToBoolean } from '@formio/core';
11
12
  const interpolate = Evaluator.interpolate;
12
13
  export * from './formUtils';
13
14
  // Configure JsonLogic
@@ -236,7 +237,7 @@ export function checkSimpleConditional(component, condition, row, data, instance
236
237
  default:
237
238
  result = _.every(conditionsResult.flat(), res => !!res);
238
239
  }
239
- return show ? result : !result;
240
+ return convertShowToBoolean(show) ? result : !result;
240
241
  }
241
242
  }
242
243
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.1",
3
+ "version": "5.1.2-rc.2",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -79,9 +79,9 @@
79
79
  },
80
80
  "homepage": "https://github.com/formio/formio.js#readme",
81
81
  "dependencies": {
82
- "@formio/bootstrap": "3.1.0",
82
+ "@formio/bootstrap": "3.1.1-rc.2",
83
83
  "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.4.0",
84
+ "@formio/core": "2.4.1-rc.3",
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",