@formio/js 5.0.0-rc.40 → 5.0.0-rc.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/dist/formio.builder.css +2 -2
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +2 -2
  7. package/dist/formio.form.js +114 -37
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +7 -7
  11. package/dist/formio.full.css +2 -2
  12. package/dist/formio.full.js +115 -38
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +7 -7
  16. package/dist/formio.js +76 -4
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +13 -1
  19. package/dist/formio.utils.js +48 -4
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +3 -3
  22. package/lib/cjs/Embed.js +11 -11
  23. package/lib/cjs/Form.js +32 -1
  24. package/lib/cjs/Webform.js +1 -1
  25. package/lib/cjs/WebformBuilder.js +18 -2
  26. package/lib/cjs/components/datagrid/DataGrid.js +1 -1
  27. package/lib/cjs/components/datetime/fixtures/comp13.js +118 -0
  28. package/lib/cjs/components/datetime/fixtures/index.js +3 -1
  29. package/lib/cjs/components/form/Form.js +27 -3
  30. package/lib/cjs/components/radio/Radio.js +13 -0
  31. package/lib/cjs/providers/storage/util.js +2 -2
  32. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +1 -1
  33. package/lib/cjs/widgets/CalendarWidget.js +8 -0
  34. package/lib/mjs/Form.js +32 -1
  35. package/lib/mjs/Webform.js +1 -1
  36. package/lib/mjs/WebformBuilder.js +17 -1
  37. package/lib/mjs/components/datagrid/DataGrid.js +1 -1
  38. package/lib/mjs/components/datetime/fixtures/comp13.js +116 -0
  39. package/lib/mjs/components/datetime/fixtures/index.js +2 -1
  40. package/lib/mjs/components/form/Form.js +25 -2
  41. package/lib/mjs/components/radio/Radio.js +16 -0
  42. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  43. package/lib/mjs/widgets/CalendarWidget.js +8 -0
  44. package/package.json +11 -11
@@ -0,0 +1,116 @@
1
+ export default {
2
+ type: 'form',
3
+ display: 'form',
4
+ components: [
5
+ {
6
+ label: 'Min Date',
7
+ tableView: false,
8
+ datePicker: {
9
+ disableWeekends: false,
10
+ disableWeekdays: false
11
+ },
12
+ enableMinDateInput: false,
13
+ enableMaxDateInput: false,
14
+ key: 'minDate',
15
+ type: 'datetime',
16
+ input: true,
17
+ widget: {
18
+ type: 'calendar',
19
+ displayInTimezone: 'viewer',
20
+ locale: 'en',
21
+ useLocaleSettings: false,
22
+ allowInput: true,
23
+ mode: 'single',
24
+ enableTime: true,
25
+ noCalendar: false,
26
+ format: 'yyyy-MM-dd hh:mm a',
27
+ hourIncrement: 1,
28
+ minuteIncrement: 1,
29
+ // eslint-disable-next-line camelcase
30
+ time_24hr: false,
31
+ minDate: null,
32
+ disableWeekends: false,
33
+ disableWeekdays: false,
34
+ maxDate: null
35
+ }
36
+ },
37
+ {
38
+ label: 'Max Date',
39
+ tableView: false,
40
+ enableMinDateInput: false,
41
+ datePicker: {
42
+ disableWeekends: false,
43
+ disableWeekdays: false
44
+ },
45
+ enableMaxDateInput: false,
46
+ validate: {
47
+ custom: "var minDate = moment(data.minDate);\nvar maxDate = moment(data.maxDate);\nvalid = maxDate.isAfter(minDate)? true : 'Max date must be after min date'"
48
+ },
49
+ key: 'maxDate',
50
+ type: 'datetime',
51
+ input: true,
52
+ widget: {
53
+ type: 'calendar',
54
+ displayInTimezone: 'viewer',
55
+ locale: 'en',
56
+ useLocaleSettings: false,
57
+ allowInput: true,
58
+ mode: 'single',
59
+ enableTime: true,
60
+ noCalendar: false,
61
+ format: 'yyyy-MM-dd hh:mm a',
62
+ hourIncrement: 1,
63
+ minuteIncrement: 1,
64
+ // eslint-disable-next-line camelcase
65
+ time_24hr: false,
66
+ minDate: null,
67
+ disableWeekends: false,
68
+ disableWeekdays: false,
69
+ maxDate: null
70
+ }
71
+ },
72
+ {
73
+ label: 'In Between Date',
74
+ tableView: false,
75
+ datePicker: {
76
+ disableFunction: '!moment(date).isBetween(moment(data.minDate), moment(data.maxDate))',
77
+ disableWeekends: false,
78
+ disableWeekdays: false
79
+ },
80
+ enableMinDateInput: false,
81
+ enableMaxDateInput: false,
82
+ key: 'inBetweenDate',
83
+ customConditional: 'show = !!data.minDate && !!data.maxDate',
84
+ type: 'datetime',
85
+ input: true,
86
+ widget: {
87
+ type: 'calendar',
88
+ displayInTimezone: 'viewer',
89
+ locale: 'en',
90
+ useLocaleSettings: false,
91
+ allowInput: true,
92
+ mode: 'single',
93
+ enableTime: true,
94
+ noCalendar: false,
95
+ format: 'yyyy-MM-dd hh:mm a',
96
+ hourIncrement: 1,
97
+ minuteIncrement: 1,
98
+ // eslint-disable-next-line camelcase
99
+ time_24hr: false,
100
+ minDate: null,
101
+ disableWeekends: false,
102
+ disableWeekdays: false,
103
+ disableFunction: '!moment(date).isBetween(moment(data.minDate), moment(data.maxDate))',
104
+ maxDate: null
105
+ }
106
+ },
107
+ {
108
+ type: 'button',
109
+ label: 'Submit',
110
+ key: 'submit',
111
+ disableOnInvalid: true,
112
+ input: true,
113
+ tableView: false
114
+ }
115
+ ],
116
+ };
@@ -9,4 +9,5 @@ import comp9 from './comp9';
9
9
  import comp10 from './comp10';
10
10
  import comp11 from './comp11';
11
11
  import comp12 from './comp12';
12
- export { comp1, comp10, comp11, comp12, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
12
+ import comp13 from './comp13';
13
+ export { comp1, comp10, comp11, comp12, comp13, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-statements */
1
2
  import _ from 'lodash';
2
3
  import Component from '../_classes/component/Component';
3
4
  import ComponentModal from '../_classes/componentModal/ComponentModal';
@@ -191,6 +192,12 @@ export default class FormComponent extends Component {
191
192
  if (this.options.inEditGrid) {
192
193
  options.inEditGrid = this.options.inEditGrid;
193
194
  }
195
+ if (this.options.saveDraft) {
196
+ options.saveDraft = this.options.saveDraft;
197
+ }
198
+ if (this.options.saveDraftThrottle) {
199
+ options.saveDraftThrottle = this.options.saveDraftThrottle;
200
+ }
194
201
  return options;
195
202
  }
196
203
  render() {
@@ -392,6 +399,10 @@ export default class FormComponent extends Component {
392
399
  this.subForm.nosubmit = true;
393
400
  this.subForm.root = this.root;
394
401
  this.subForm.localRoot = this.isNestedWizard ? this.localRoot : this.subForm;
402
+ if (this.parent) {
403
+ this.subForm.draftEnabled = this.parent.draftEnabled;
404
+ this.subForm.savingDraft = this.parent.savingDraft;
405
+ }
395
406
  this.restoreValue();
396
407
  this.valueChanged = this.hasSetValue;
397
408
  this.onChange();
@@ -427,7 +438,13 @@ export default class FormComponent extends Component {
427
438
  }
428
439
  else if (this.formSrc) {
429
440
  this.subFormLoading = true;
430
- return (new Formio(this.formSrc)).loadForm({ params: { live: 1 } })
441
+ const options = this.root.formio?.base && this.root.formio?.projectUrl
442
+ ? {
443
+ base: this.root.formio.base,
444
+ project: this.root.formio.projectUrl,
445
+ }
446
+ : {};
447
+ return (new Formio(this.formSrc, options)).loadForm({ params: { live: 1 } })
431
448
  .then((formObj) => {
432
449
  this.formObj = formObj;
433
450
  if (this.options.pdf && this.component.useOriginalRevision) {
@@ -599,7 +616,13 @@ export default class FormComponent extends Component {
599
616
  if (shouldLoadSubmissionById) {
600
617
  const formId = submission.form || this.formObj.form || this.component.form;
601
618
  const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
602
- this.subForm.setUrl(submissionUrl, this.options);
619
+ const options = this.root.formio?.base && this.root.formio?.projectUrl
620
+ ? {
621
+ base: this.root.formio.base,
622
+ project: this.root.formio.projectUrl,
623
+ }
624
+ : {};
625
+ this.subForm.setUrl(submissionUrl, { ...this.options, ...options });
603
626
  this.subForm.loadSubmission().catch((err) => {
604
627
  console.error(`Unable to load subform submission ${submission._id}:`, err);
605
628
  });
@@ -44,6 +44,22 @@ export default class RadioComponent extends ListComponent {
44
44
  }
45
45
  };
46
46
  }
47
+ static get serverConditionSettings() {
48
+ return {
49
+ ...super.serverConditionSettings,
50
+ valueComponent(classComp) {
51
+ return {
52
+ type: 'select',
53
+ dataSrc: 'custom',
54
+ valueProperty: 'value',
55
+ dataType: classComp.dataType || '',
56
+ data: {
57
+ custom: `values = ${classComp && classComp.values ? JSON.stringify(classComp.values) : []}`,
58
+ },
59
+ };
60
+ },
61
+ };
62
+ }
47
63
  static savedValueTypes(schema) {
48
64
  const { boolean, string, number, object, array } = componentValueTypes;
49
65
  const { dataType } = schema;
@@ -9,7 +9,7 @@ export default class IsEqualTo extends ConditionOperator {
9
9
  return 'Is Equal To';
10
10
  }
11
11
  execute({ value, comparedValue, instance, conditionComponentPath }) {
12
- if (value && comparedValue && typeof value !== typeof comparedValue && _.isString(comparedValue)) {
12
+ if ((value || value === false) && comparedValue && typeof value !== typeof comparedValue && _.isString(comparedValue)) {
13
13
  try {
14
14
  comparedValue = JSON.parse(comparedValue);
15
15
  }
@@ -409,6 +409,14 @@ export default class CalendarWidget extends InputWidget {
409
409
  }
410
410
  }
411
411
  });
412
+ // If other fields are used to calculate disabled dates, we need to redraw calendar to refresh disabled dates
413
+ if (this.settings.disableFunction && this.componentInstance && this.componentInstance.root) {
414
+ this.componentInstance.root.on('change', (e) => {
415
+ if (e.changed && this.calendar) {
416
+ this.calendar.redraw();
417
+ }
418
+ });
419
+ }
412
420
  // Restore the calendar value from the component value.
413
421
  this.setValue(this.componentValue);
414
422
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.40",
3
+ "version": "5.0.0-rc.42",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -84,9 +84,9 @@
84
84
  },
85
85
  "homepage": "https://github.com/formio/formio.js#readme",
86
86
  "dependencies": {
87
- "@formio/bootstrap": "^3.0.0-rc.20",
87
+ "@formio/bootstrap": "^3.0.0-rc.22",
88
88
  "@formio/choices.js": "^10.2.1",
89
- "@formio/core": "^2.0.0-rc.16",
89
+ "@formio/core": "^2.0.0-tt.dev-882e7ea",
90
90
  "@formio/text-mask-addons": "^3.8.0-formio.2",
91
91
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
92
92
  "abortcontroller-polyfill": "^1.7.5",
@@ -114,17 +114,17 @@
114
114
  "lodash": "^4.17.21",
115
115
  "moment": "^2.29.4",
116
116
  "moment-timezone": "^0.5.44",
117
- "quill": "^2.0.0-dev.3",
118
- "signature_pad": "^4.1.4",
117
+ "quill": "^2.0.0-rc.4",
118
+ "signature_pad": "^4.2.0",
119
119
  "string-hash": "^1.1.3",
120
120
  "tippy.js": "^6.3.7",
121
121
  "uuid": "^9.0.0",
122
- "vanilla-picker": "^2.12.2"
122
+ "vanilla-picker": "^2.12.3"
123
123
  },
124
124
  "devDependencies": {
125
- "@typescript-eslint/eslint-plugin": "^7.1.1",
126
- "@typescript-eslint/parser": "^7.1.1",
127
- "ace-builds": "1.32.7",
125
+ "@typescript-eslint/eslint-plugin": "^7.3.0",
126
+ "@typescript-eslint/parser": "^7.3.0",
127
+ "ace-builds": "1.32.9",
128
128
  "async-limiter": "^2.0.0",
129
129
  "bootstrap-icons": "^1.10.5",
130
130
  "bootswatch": "^5.3.3",
@@ -170,13 +170,13 @@
170
170
  "pretty": "^2.0.0",
171
171
  "pygments-css": "^1.0.0",
172
172
  "raw-loader": "^4.0.2",
173
- "sass": "^1.71.1",
173
+ "sass": "^1.72.0",
174
174
  "shortcut-buttons-flatpickr": "^0.4.0",
175
175
  "sinon": "^17.0.1",
176
176
  "string-replace-loader": "^3.1.0",
177
177
  "ts-loader": "^9.4.4",
178
178
  "ts-node": "^10.9.1",
179
- "typescript": "~5.4.2",
179
+ "typescript": "5.3.3",
180
180
  "webpack": "^5.90.3",
181
181
  "webpack-bundle-analyzer": "^4.9.0",
182
182
  "webpack-cli": "^5.1.1",