@formio/js 5.0.0-rc.34 → 5.0.0-rc.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/dist/fonts/bootstrap-icons.woff +0 -0
  2. package/dist/fonts/bootstrap-icons.woff2 +0 -0
  3. package/dist/formio.builder.css +19 -15
  4. package/dist/formio.builder.min.css +1 -1
  5. package/dist/formio.embed.js +1 -1
  6. package/dist/formio.embed.min.js +1 -1
  7. package/dist/formio.form.css +19 -15
  8. package/dist/formio.form.js +19 -19
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  12. package/dist/formio.full.css +363 -19
  13. package/dist/formio.full.js +20 -20
  14. package/dist/formio.full.min.css +3 -3
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  17. package/dist/formio.js +8 -8
  18. package/dist/formio.min.js +1 -1
  19. package/lib/cjs/CDN.js +12 -6
  20. package/lib/cjs/Webform.js +4 -1
  21. package/lib/cjs/Wizard.js +6 -9
  22. package/lib/cjs/components/_classes/component/Component.js +6 -1
  23. package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -1
  24. package/lib/cjs/components/container/fixtures/comp4.js +45 -0
  25. package/lib/cjs/components/container/fixtures/index.js +3 -1
  26. package/lib/cjs/components/datetime/DateTime.js +6 -0
  27. package/lib/cjs/components/file/File.js +465 -215
  28. package/lib/cjs/components/file/editForm/File.edit.display.js +17 -0
  29. package/lib/cjs/components/textarea/TextArea.js +2 -2
  30. package/lib/cjs/components/textfield/TextField.js +3 -1
  31. package/lib/cjs/components/time/Time.js +3 -0
  32. package/lib/cjs/providers/storage/azure.js +6 -1
  33. package/lib/cjs/providers/storage/base64.js +1 -1
  34. package/lib/cjs/providers/storage/googleDrive.js +5 -1
  35. package/lib/cjs/providers/storage/indexeddb.js +1 -1
  36. package/lib/cjs/providers/storage/s3.js +5 -1
  37. package/lib/cjs/providers/storage/xhr.js +10 -0
  38. package/lib/mjs/CDN.js +12 -6
  39. package/lib/mjs/Webform.js +4 -1
  40. package/lib/mjs/Wizard.js +6 -9
  41. package/lib/mjs/components/_classes/component/Component.js +6 -1
  42. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -1
  43. package/lib/mjs/components/container/fixtures/comp4.js +43 -0
  44. package/lib/mjs/components/container/fixtures/index.js +2 -1
  45. package/lib/mjs/components/datetime/DateTime.js +6 -0
  46. package/lib/mjs/components/file/File.js +463 -224
  47. package/lib/mjs/components/file/editForm/File.edit.display.js +17 -0
  48. package/lib/mjs/components/textarea/TextArea.js +2 -2
  49. package/lib/mjs/components/textfield/TextField.js +6 -0
  50. package/lib/mjs/components/time/Time.js +3 -0
  51. package/lib/mjs/providers/storage/azure.js +6 -1
  52. package/lib/mjs/providers/storage/base64.js +1 -1
  53. package/lib/mjs/providers/storage/googleDrive.js +5 -1
  54. package/lib/mjs/providers/storage/indexeddb.js +1 -1
  55. package/lib/mjs/providers/storage/s3.js +5 -1
  56. package/lib/mjs/providers/storage/xhr.js +10 -0
  57. package/package.json +2 -2
@@ -5,4 +5,21 @@ exports.default = [
5
5
  key: 'placeholder',
6
6
  ignore: true
7
7
  },
8
+ {
9
+ type: 'checkbox',
10
+ label: 'Files Synchronization feature',
11
+ tooltip: 'Enable ability to control files synchronization. Files will be auto synced before submit.',
12
+ key: 'autoSync',
13
+ input: true,
14
+ conditional: {
15
+ json: {
16
+ in: [
17
+ {
18
+ var: 'data.storage'
19
+ },
20
+ ['s3', 'azure', 'googledrive']
21
+ ],
22
+ }
23
+ }
24
+ },
8
25
  ];
@@ -298,10 +298,10 @@ class TextAreaComponent extends TextField_1.default {
298
298
  if (this.options.readOnly || this.disabled) {
299
299
  if (this.refs.input && this.refs.input[index]) {
300
300
  if (this.component.inputFormat === 'plain') {
301
- this.refs.input[index].innerText = this.interpolate(value, {}, { noeval: true });
301
+ this.refs.input[index].innerText = this.isPlain ? value : this.interpolate(value, {}, { noeval: true });
302
302
  }
303
303
  else {
304
- this.setContent(this.refs.input[index], this.interpolate(value, {}, { noeval: true }), this.shouldSanitizeValue);
304
+ this.setContent(this.refs.input[index], this.isPlain ? value : this.interpolate(value, {}, { noeval: true }), this.shouldSanitizeValue);
305
305
  }
306
306
  }
307
307
  }
@@ -65,7 +65,9 @@ class TextFieldComponent extends Input_1.default {
65
65
  return TextFieldComponent.conditionOperatorsSettings;
66
66
  }
67
67
  static get conditionOperatorsSettings() {
68
- return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: [...super.conditionOperatorsSettings.operators, 'includes', 'notIncludes', 'endsWith', 'startsWith'] });
68
+ return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: [...super.conditionOperatorsSettings.operators, 'includes', 'notIncludes', 'endsWith', 'startsWith'], valueComponent(classComp) {
69
+ return Object.assign(Object.assign({}, classComp), { type: 'textfield' });
70
+ } });
69
71
  }
70
72
  static savedValueTypes(schema) {
71
73
  return FormioUtils.getComponentSavedTypes(schema) || [FormioUtils.componentValueTypes.string];
@@ -125,6 +125,9 @@ class TimeComponent extends TextField_1.default {
125
125
  return view ? (0, moment_1.default)(view, this.component.format).format(this.component.dataFormat) : view;
126
126
  }
127
127
  getValueAsString(value) {
128
+ if (Array.isArray(value) && this.component.multiple) {
129
+ return value.map(item => (0, moment_1.default)(item, this.component.dataFormat).format(this.component.format)).join(', ');
130
+ }
128
131
  return (value ? (0, moment_1.default)(value, this.component.dataFormat).format(this.component.format) : value) || '';
129
132
  }
130
133
  getInputMaskFromFormat(format) {
@@ -12,7 +12,7 @@ function azure(formio) {
12
12
  xhr.setRequestHeader('Content-Type', file.type);
13
13
  xhr.setRequestHeader('x-ms-blob-type', 'BlockBlob');
14
14
  return file;
15
- }, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback).then(() => {
15
+ }, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback).then((response) => {
16
16
  return {
17
17
  storage: 'azure',
18
18
  name: xhr_1.default.path([dir, fileName]),
@@ -20,11 +20,16 @@ function azure(formio) {
20
20
  type: file.type,
21
21
  groupPermissions,
22
22
  groupId,
23
+ key: response.key,
23
24
  };
24
25
  });
25
26
  },
26
27
  downloadFile(file) {
27
28
  return formio.makeRequest('file', `${formio.formUrl}/storage/azure?name=${xhr_1.default.trim(file.name)}`, 'GET');
29
+ },
30
+ deleteFile: function deleteFile(fileInfo) {
31
+ var url = `${formio.formUrl}/storage/azure?name=${xhr_1.default.trim(fileInfo.name)}&key=${xhr_1.default.trim(fileInfo.key)}`;
32
+ return formio.makeRequest('', url, 'delete');
28
33
  }
29
34
  };
30
35
  }
@@ -26,7 +26,7 @@ function base64() {
26
26
  downloadFile(file) {
27
27
  // Return the original as there is nothing to do.
28
28
  return Promise.resolve(file);
29
- }
29
+ },
30
30
  };
31
31
  }
32
32
  base64.title = 'Base64';
@@ -51,7 +51,11 @@ function googledrive(formio) {
51
51
  file.url =
52
52
  `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
53
53
  return Promise.resolve(file);
54
- }
54
+ },
55
+ deleteFile: function deleteFile(fileInfo) {
56
+ var url = ''.concat(formio.formUrl, `/storage/gdrive?id=${fileInfo.id}&name=${fileInfo.originalName}`);
57
+ return formio.makeRequest('', url, 'delete');
58
+ },
55
59
  };
56
60
  }
57
61
  googledrive.title = 'Google Drive';
@@ -115,7 +115,7 @@ function indexeddb() {
115
115
  };
116
116
  });
117
117
  });
118
- }
118
+ },
119
119
  };
120
120
  }
121
121
  indexeddb.title = 'IndexedDB';
@@ -142,7 +142,11 @@ function s3(formio) {
142
142
  else {
143
143
  return Promise.resolve(file);
144
144
  }
145
- }
145
+ },
146
+ deleteFile(fileInfo) {
147
+ const url = `${formio.formUrl}/storage/s3?bucket=${xhr_1.default.trim(fileInfo.bucket)}&key=${xhr_1.default.trim(fileInfo.key)}`;
148
+ return formio.makeRequest('', url, 'delete');
149
+ },
146
150
  };
147
151
  }
148
152
  s3.title = 'S3';
@@ -61,6 +61,11 @@ const XHR = {
61
61
  throw err;
62
62
  }
63
63
  if (!response.ok) {
64
+ if (response.status === 504) {
65
+ const error = new Error('Network request failed');
66
+ error.networkError = true;
67
+ throw error;
68
+ }
64
69
  const message = yield response.text();
65
70
  throw new Error(message || 'Unable to sign file.');
66
71
  }
@@ -104,6 +109,11 @@ const XHR = {
104
109
  if (xhr.status >= 200 && xhr.status < 300) {
105
110
  resolve(serverResponse);
106
111
  }
112
+ else if (xhr.status === 504) {
113
+ const error = new Error('Network request failed');
114
+ error.networkError = true;
115
+ reject(error);
116
+ }
107
117
  else {
108
118
  reject(xhr.response || 'Unable to upload file');
109
119
  }
package/lib/mjs/CDN.js CHANGED
@@ -56,19 +56,25 @@ class CDN {
56
56
  this.updateUrls();
57
57
  }
58
58
  buildUrl(cdnUrl, lib, version) {
59
- let url;
60
- if (version === 'latest' || version === '') {
61
- url = `${cdnUrl}/${lib}`;
59
+ let url = cdnUrl;
60
+ if (lib) {
61
+ url += `/${lib}`;
62
62
  }
63
- else {
64
- url = `${cdnUrl}/${lib}/${version}`;
63
+ if (version && version !== 'latest') {
64
+ url += `/${version}`;
65
65
  }
66
66
  return url;
67
67
  }
68
68
  updateUrls() {
69
69
  for (const lib in this.libs) {
70
70
  if (lib in this.overrides) {
71
- this[lib] = this.buildUrl(this.overrides[lib], lib, this.libs[lib]);
71
+ if (typeof this.overrides[lib] === 'string') {
72
+ this[lib] = this.buildUrl(this.overrides[lib], lib, this.libs[lib]);
73
+ }
74
+ else {
75
+ const override = this.overrides[lib];
76
+ this[lib] = this.buildUrl(override.cdn, override.lib || '', override.version || '');
77
+ }
72
78
  }
73
79
  else {
74
80
  this[lib] = this.buildUrl(this.baseUrl, lib, this.libs[lib]);
@@ -778,7 +778,10 @@ export default class Webform extends NestedDataComponent {
778
778
  this.component.input = false;
779
779
  this.addComponents();
780
780
  this.on('submitButton', options => {
781
- this.submit(false, options).catch(e => e !== false && e !== undefined && console.log(e));
781
+ this.submit(false, options).catch(e => {
782
+ options.instance.loading = false;
783
+ return e !== false && e !== undefined && console.log(e);
784
+ });
782
785
  }, true);
783
786
  this.on('checkValidity', (data) => this.validate(data, { dirty: true, process: 'change' }), true);
784
787
  this.on('requestUrl', (args) => (this.submitUrl(args.url, args.headers)), true);
package/lib/mjs/Wizard.js CHANGED
@@ -777,21 +777,18 @@ export default class Wizard extends Webform {
777
777
  }
778
778
  }
779
779
  setValue(submission, flags = {}, ignoreEstablishment) {
780
- this._submission = submission;
781
- if ((flags && flags.fromSubmission && (this.options.readOnly || this.editMode) && !this.isHtmlRenderMode()) ||
782
- (flags && flags.fromSubmission && (this.prefixComps.length || this.suffixComps.length) && submission._id) ||
783
- (this.options.server && (this.prefixComps.length || this.suffixComps.length))) {
784
- this._data = submission.data;
785
- }
786
- if (!ignoreEstablishment) {
787
- this.establishPages(submission.data);
788
- }
789
780
  const changed = this.getPages({ all: true }).reduce((changed, page) => {
790
781
  return this.setNestedValue(page, submission.data, flags, changed) || changed;
791
782
  }, false);
783
+ this.mergeData(this.data, submission.data);
792
784
  if (changed) {
793
785
  this.pageFieldLogic(this.page);
794
786
  }
787
+ submission.data = this.data;
788
+ this._submission = submission;
789
+ if (!ignoreEstablishment) {
790
+ this.establishPages(submission.data);
791
+ }
795
792
  this.setEditMode(submission);
796
793
  return changed;
797
794
  }
@@ -173,7 +173,12 @@ export default class Component extends Element {
173
173
  return {
174
174
  operators: ['isEqual', 'isNotEqual', 'isEmpty', 'isNotEmpty'],
175
175
  valueComponent() {
176
- return { type: 'textfield' };
176
+ return {
177
+ type: 'textfield',
178
+ widget: {
179
+ type: 'input'
180
+ }
181
+ };
177
182
  }
178
183
  };
179
184
  }
@@ -520,7 +520,7 @@ export default class NestedComponent extends Field {
520
520
  clearOnHide(show) {
521
521
  super.clearOnHide(show);
522
522
  if (this.component.clearOnHide) {
523
- if (this.allowData && !this.hasValue()) {
523
+ if (this.allowData && !this.hasValue() && !(this.options.server && !this.visible)) {
524
524
  this.dataValue = this.defaultValue;
525
525
  }
526
526
  if (this.hasValue()) {
@@ -0,0 +1,43 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'form',
4
+ components: [
5
+ {
6
+ label: 'Checkbox',
7
+ tableView: false,
8
+ key: 'checkbox',
9
+ type: 'checkbox',
10
+ input: true,
11
+ },
12
+ {
13
+ label: 'Container',
14
+ tableView: false,
15
+ key: 'container',
16
+ conditional: {
17
+ show: true,
18
+ when: 'checkbox',
19
+ eq: 'true',
20
+ },
21
+ type: 'container',
22
+ input: true,
23
+ components: [
24
+ {
25
+ label: 'Text Field',
26
+ applyMaskOn: 'change',
27
+ tableView: true,
28
+ key: 'textField',
29
+ type: 'textfield',
30
+ input: true,
31
+ },
32
+ ],
33
+ },
34
+ {
35
+ type: 'button',
36
+ label: 'Submit',
37
+ key: 'submit',
38
+ disableOnInvalid: true,
39
+ input: true,
40
+ tableView: false,
41
+ },
42
+ ],
43
+ };
@@ -1,4 +1,5 @@
1
1
  import comp1 from './comp1';
2
2
  import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
- export { comp1, comp2, comp3 };
4
+ import comp4 from './comp4';
5
+ export { comp1, comp2, comp3, comp4 };
@@ -178,8 +178,14 @@ export default class DateTimeComponent extends Input {
178
178
  format += format.match(/z$/) ? '' : ' z';
179
179
  const timezone = this.timezone;
180
180
  if (value && !this.attached && timezone) {
181
+ if (Array.isArray(value) && this.component.multiple) {
182
+ return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
183
+ }
181
184
  return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
182
185
  }
186
+ if (Array.isArray(value) && this.component.multiple) {
187
+ return value.map(item => _.trim(moment(item).format(format))).join(', ');
188
+ }
183
189
  return (value ? _.trim(moment(value).format(format)) : value) || '';
184
190
  }
185
191
  }