@formio/js 5.2.1-dev.6243.b3a30c7 → 5.2.1-dev.6247.62839b6

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.
@@ -552,7 +552,7 @@ class WebformBuilder extends Component_1.default {
552
552
  const groupId = group.getAttribute('id').slice('group-'.length);
553
553
  const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
554
554
  if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
555
- hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));
555
+ hideShow(group, false, true);
556
556
  }
557
557
  });
558
558
  }, true);
@@ -165,7 +165,6 @@ declare class Component extends Element {
165
165
  get componentsMap(): object;
166
166
  /**
167
167
  * Returns if the parent should conditionally clear.
168
- *
169
168
  * @returns {boolean} - If the parent should conditionally clear.
170
169
  */
171
170
  parentShouldConditionallyClear(): boolean;
@@ -424,7 +424,6 @@ class Component extends Element_1.default {
424
424
  }
425
425
  /**
426
426
  * Returns if the parent should conditionally clear.
427
- *
428
427
  * @returns {boolean} - If the parent should conditionally clear.
429
428
  */
430
429
  parentShouldConditionallyClear() {
@@ -53,11 +53,13 @@ class DayComponent extends Field_1.default {
53
53
  return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
54
54
  }
55
55
  constructor(component, options, data) {
56
- if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
57
- component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
58
- }
59
- if (component.minDate && component.minDate.indexOf('moment(') === -1) {
60
- component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
56
+ if (!options.inFormBuilder && !options.building) {
57
+ if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
+ component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
59
+ }
60
+ if (component.minDate && component.minDate.indexOf('moment(') === -1) {
61
+ component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
62
+ }
61
63
  }
62
64
  super(component, options, data);
63
65
  }
@@ -109,7 +109,8 @@ class FileComponent extends Field_1.default {
109
109
  if (this.component.privateDownload) {
110
110
  fileInfo.private = true;
111
111
  }
112
- return this.fileService.downloadFile(fileInfo).then((result) => result.url);
112
+ // pass the component to the downloadFile method
113
+ return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
113
114
  }
114
115
  get emptyValue() {
115
116
  return [];
@@ -13,7 +13,7 @@ export default class FormComponent extends Component {
13
13
  valueChanged: boolean | undefined;
14
14
  subForm: any;
15
15
  formSrc: any;
16
- get dataReady(): Promise<any>;
16
+ get dataReady(): any;
17
17
  get emptyValue(): {
18
18
  data: {};
19
19
  };
@@ -105,7 +105,8 @@ class FormComponent extends Component_1.default {
105
105
  return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
106
106
  }
107
107
  get dataReady() {
108
- return this.subFormReady || Promise.resolve();
108
+ var _a;
109
+ return ((_a = this.subFormReady) === null || _a === void 0 ? void 0 : _a.dataReady) || this.subFormReady || Promise.resolve();
109
110
  }
110
111
  get defaultValue() {
111
112
  // Not not provide a default value unless the subform is ready so that it will initialize correctly.
@@ -695,6 +696,9 @@ class FormComponent extends Component_1.default {
695
696
  */
696
697
  onSetSubFormValue(submission, flags) {
697
698
  this.subForm.setValue(submission, flags);
699
+ if (flags === null || flags === void 0 ? void 0 : flags.fromSubmission) {
700
+ this.subForm.submissionReadyResolve(submission);
701
+ }
698
702
  }
699
703
  isEmpty(value = this.dataValue) {
700
704
  return value === null || lodash_1.default.isEqual(value, this.emptyValue);
@@ -91,10 +91,14 @@ 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 default value does not contain valid value that could be parsed to number, set it to null to prevent errors
99
+ if (lodash_1.default.isNaN(defaultValue)) {
100
+ defaultValue = null;
101
+ }
98
102
  }
99
103
  if (!defaultValue && this.component.defaultValue === 0) {
100
104
  defaultValue = this.component.defaultValue;
@@ -52,10 +52,11 @@ function googledrive(formio) {
52
52
  xhr.send(fd);
53
53
  }));
54
54
  },
55
- downloadFile(file) {
55
+ downloadFile(file, component) {
56
56
  const token = formio.getToken();
57
+ // Constructed the url with the fileId, fileName, displayImage, imageSize if applicable
57
58
  file.url =
58
- `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
59
+ `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}${component.image ? '&displayImage=true' : ''}${component.imageSize ? `&imageSize=${component.imageSize}` : ''}`;
59
60
  return Promise.resolve(file);
60
61
  },
61
62
  deleteFile: function deleteFile(fileInfo) {
@@ -538,7 +538,7 @@ export default class WebformBuilder extends Component {
538
538
  const groupId = group.getAttribute('id').slice('group-'.length);
539
539
  const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
540
540
  if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
541
- hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));
541
+ hideShow(group, false, true);
542
542
  }
543
543
  });
544
544
  }, true);
@@ -165,7 +165,6 @@ declare class Component extends Element {
165
165
  get componentsMap(): object;
166
166
  /**
167
167
  * Returns if the parent should conditionally clear.
168
- *
169
168
  * @returns {boolean} - If the parent should conditionally clear.
170
169
  */
171
170
  parentShouldConditionallyClear(): boolean;
@@ -420,7 +420,6 @@ export default class Component extends Element {
420
420
  }
421
421
  /**
422
422
  * Returns if the parent should conditionally clear.
423
- *
424
423
  * @returns {boolean} - If the parent should conditionally clear.
425
424
  */
426
425
  parentShouldConditionallyClear() {
@@ -53,11 +53,13 @@ export default class DayComponent extends Field {
53
53
  // Empty value used before 9.3.x
54
54
  static oldEmptyValue = '00/00/0000';
55
55
  constructor(component, options, data) {
56
- if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
57
- component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
58
- }
59
- if (component.minDate && component.minDate.indexOf('moment(') === -1) {
60
- component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
56
+ if (!options.inFormBuilder && !options.building) {
57
+ if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
+ component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
59
+ }
60
+ if (component.minDate && component.minDate.indexOf('moment(') === -1) {
61
+ component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
62
+ }
61
63
  }
62
64
  super(component, options, data);
63
65
  }
@@ -98,7 +98,8 @@ export default class FileComponent extends Field {
98
98
  if (this.component.privateDownload) {
99
99
  fileInfo.private = true;
100
100
  }
101
- return this.fileService.downloadFile(fileInfo).then((result) => result.url);
101
+ // pass the component to the downloadFile method
102
+ return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
102
103
  }
103
104
  get emptyValue() {
104
105
  return [];
@@ -13,7 +13,7 @@ export default class FormComponent extends Component {
13
13
  valueChanged: boolean | undefined;
14
14
  subForm: any;
15
15
  formSrc: any;
16
- get dataReady(): Promise<any>;
16
+ get dataReady(): any;
17
17
  get emptyValue(): {
18
18
  data: {};
19
19
  };
@@ -100,7 +100,7 @@ export default class FormComponent extends Component {
100
100
  return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
101
101
  }
102
102
  get dataReady() {
103
- return this.subFormReady || Promise.resolve();
103
+ return this.subFormReady?.dataReady || this.subFormReady || Promise.resolve();
104
104
  }
105
105
  get defaultValue() {
106
106
  // Not not provide a default value unless the subform is ready so that it will initialize correctly.
@@ -684,6 +684,9 @@ export default class FormComponent extends Component {
684
684
  */
685
685
  onSetSubFormValue(submission, flags) {
686
686
  this.subForm.setValue(submission, flags);
687
+ if (flags?.fromSubmission) {
688
+ this.subForm.submissionReadyResolve(submission);
689
+ }
687
690
  }
688
691
  isEmpty(value = this.dataValue) {
689
692
  return value === null || _.isEqual(value, this.emptyValue);
@@ -89,10 +89,14 @@ 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 default value does not contain valid value that could be parsed to number, set it to null to prevent errors
97
+ if (_.isNaN(defaultValue)) {
98
+ defaultValue = null;
99
+ }
96
100
  }
97
101
  if (!defaultValue && this.component.defaultValue === 0) {
98
102
  defaultValue = this.component.defaultValue;
@@ -50,10 +50,11 @@ function googledrive(formio) {
50
50
  xhr.send(fd);
51
51
  }));
52
52
  },
53
- downloadFile(file) {
53
+ downloadFile(file, component) {
54
54
  const token = formio.getToken();
55
+ // Constructed the url with the fileId, fileName, displayImage, imageSize if applicable
55
56
  file.url =
56
- `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
57
+ `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}${component.image ? '&displayImage=true' : ''}${component.imageSize ? `&imageSize=${component.imageSize}` : ''}`;
57
58
  return Promise.resolve(file);
58
59
  },
59
60
  deleteFile: function deleteFile(fileInfo) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.2.1-dev.6243.b3a30c7",
3
+ "version": "5.2.1-dev.6247.62839b6",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {