@formio/js 5.0.0-dev.5543.201e658 → 5.0.0-dev.5543.3c780dd

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 (40) hide show
  1. package/Changelog.md +6102 -0
  2. package/dist/formio.builder.css +2 -2
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.form.css +2 -2
  5. package/dist/formio.form.js +7 -7
  6. package/dist/formio.form.min.css +1 -1
  7. package/dist/formio.form.min.js +1 -1
  8. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  9. package/dist/formio.full.css +2 -2
  10. package/dist/formio.full.js +8 -8
  11. package/dist/formio.full.min.css +1 -1
  12. package/dist/formio.full.min.js +1 -1
  13. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  14. package/lib/cjs/Form.d.ts +8 -0
  15. package/lib/cjs/Form.js +32 -1
  16. package/lib/cjs/Webform.js +3 -2
  17. package/lib/cjs/WebformBuilder.js +18 -2
  18. package/lib/cjs/components/datagrid/DataGrid.js +1 -1
  19. package/lib/cjs/components/datetime/fixtures/comp13.d.ts +123 -0
  20. package/lib/cjs/components/datetime/fixtures/comp13.js +118 -0
  21. package/lib/cjs/components/datetime/fixtures/index.d.ts +2 -1
  22. package/lib/cjs/components/datetime/fixtures/index.js +3 -1
  23. package/lib/cjs/components/form/Form.js +25 -3
  24. package/lib/cjs/components/radio/Radio.d.ts +18 -0
  25. package/lib/cjs/components/radio/Radio.js +13 -0
  26. package/lib/cjs/widgets/CalendarWidget.js +8 -0
  27. package/lib/mjs/Form.d.ts +8 -0
  28. package/lib/mjs/Form.js +32 -1
  29. package/lib/mjs/Webform.js +3 -2
  30. package/lib/mjs/WebformBuilder.js +17 -1
  31. package/lib/mjs/components/datagrid/DataGrid.js +1 -1
  32. package/lib/mjs/components/datetime/fixtures/comp13.d.ts +123 -0
  33. package/lib/mjs/components/datetime/fixtures/comp13.js +116 -0
  34. package/lib/mjs/components/datetime/fixtures/index.d.ts +2 -1
  35. package/lib/mjs/components/datetime/fixtures/index.js +2 -1
  36. package/lib/mjs/components/form/Form.js +23 -2
  37. package/lib/mjs/components/radio/Radio.d.ts +18 -0
  38. package/lib/mjs/components/radio/Radio.js +16 -0
  39. package/lib/mjs/widgets/CalendarWidget.js +8 -0
  40. package/package.json +2 -2
@@ -115,6 +115,7 @@ export default class WebformBuilder extends Component {
115
115
  html,
116
116
  disableBuilderActions: self?.component?.disableBuilderActions,
117
117
  childComponent: component,
118
+ design: self?.options?.design
118
119
  });
119
120
  };
120
121
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -472,6 +473,7 @@ export default class WebformBuilder extends Component {
472
473
  attach(element) {
473
474
  this.on('change', (form) => {
474
475
  this.populateRecaptchaSettings(form);
476
+ this.webform.setAlert(false);
475
477
  });
476
478
  return super.attach(element).then(() => {
477
479
  this.loadRefs(element, {
@@ -804,6 +806,20 @@ export default class WebformBuilder extends Component {
804
806
  return;
805
807
  }
806
808
  }
809
+ if (draggableComponent.uniqueComponent) {
810
+ let isCompAlreadyExists = false;
811
+ eachComponent(this.webform.components, (component) => {
812
+ if (component.key === draggableComponent.schema.key) {
813
+ isCompAlreadyExists = true;
814
+ return;
815
+ }
816
+ }, true);
817
+ if (isCompAlreadyExists) {
818
+ this.webform.redraw();
819
+ this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.title} component to one page.`);
820
+ return;
821
+ }
822
+ }
807
823
  if (target !== source) {
808
824
  // Ensure the key remains unique in its new container.
809
825
  BuilderUtils.uniquify(this.findNamespaceRoot(target.formioComponent), info);
@@ -836,7 +852,7 @@ export default class WebformBuilder extends Component {
836
852
  parent.addChildComponent(info, element, target, source, sibling);
837
853
  }
838
854
  const componentInDataGrid = parent.type === 'datagrid';
839
- if (isNew && !this.options.noNewEdit && !info.noNewEdit) {
855
+ if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
840
856
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
841
857
  }
842
858
  // Only rebuild the parts needing to be rebuilt.
@@ -195,7 +195,7 @@ export default class DataGridComponent extends NestedArrayComponent {
195
195
  return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
196
196
  }
197
197
  get canAddColumn() {
198
- return this.builderMode;
198
+ return this.builderMode && !this.options.design;
199
199
  }
200
200
  render() {
201
201
  const columns = this.getColumns();
@@ -0,0 +1,123 @@
1
+ declare namespace _default {
2
+ const type: string;
3
+ const display: string;
4
+ const components: ({
5
+ label: string;
6
+ tableView: boolean;
7
+ datePicker: {
8
+ disableWeekends: boolean;
9
+ disableWeekdays: boolean;
10
+ disableFunction?: undefined;
11
+ };
12
+ enableMinDateInput: boolean;
13
+ enableMaxDateInput: boolean;
14
+ key: string;
15
+ type: string;
16
+ input: boolean;
17
+ widget: {
18
+ type: string;
19
+ displayInTimezone: string;
20
+ locale: string;
21
+ useLocaleSettings: boolean;
22
+ allowInput: boolean;
23
+ mode: string;
24
+ enableTime: boolean;
25
+ noCalendar: boolean;
26
+ format: string;
27
+ hourIncrement: number;
28
+ minuteIncrement: number;
29
+ time_24hr: boolean;
30
+ minDate: null;
31
+ disableWeekends: boolean;
32
+ disableWeekdays: boolean;
33
+ maxDate: null;
34
+ disableFunction?: undefined;
35
+ };
36
+ validate?: undefined;
37
+ disableOnInvalid?: undefined;
38
+ } | {
39
+ label: string;
40
+ tableView: boolean;
41
+ enableMinDateInput: boolean;
42
+ datePicker: {
43
+ disableWeekends: boolean;
44
+ disableWeekdays: boolean;
45
+ disableFunction?: undefined;
46
+ };
47
+ enableMaxDateInput: boolean;
48
+ validate: {
49
+ custom: string;
50
+ };
51
+ key: string;
52
+ type: string;
53
+ input: boolean;
54
+ widget: {
55
+ type: string;
56
+ displayInTimezone: string;
57
+ locale: string;
58
+ useLocaleSettings: boolean;
59
+ allowInput: boolean;
60
+ mode: string;
61
+ enableTime: boolean;
62
+ noCalendar: boolean;
63
+ format: string;
64
+ hourIncrement: number;
65
+ minuteIncrement: number;
66
+ time_24hr: boolean;
67
+ minDate: null;
68
+ disableWeekends: boolean;
69
+ disableWeekdays: boolean;
70
+ maxDate: null;
71
+ disableFunction?: undefined;
72
+ };
73
+ disableOnInvalid?: undefined;
74
+ } | {
75
+ label: string;
76
+ tableView: boolean;
77
+ datePicker: {
78
+ disableFunction: string;
79
+ disableWeekends: boolean;
80
+ disableWeekdays: boolean;
81
+ };
82
+ enableMinDateInput: boolean;
83
+ enableMaxDateInput: boolean;
84
+ key: string;
85
+ customConditional: string;
86
+ type: string;
87
+ input: boolean;
88
+ widget: {
89
+ type: string;
90
+ displayInTimezone: string;
91
+ locale: string;
92
+ useLocaleSettings: boolean;
93
+ allowInput: boolean;
94
+ mode: string;
95
+ enableTime: boolean;
96
+ noCalendar: boolean;
97
+ format: string;
98
+ hourIncrement: number;
99
+ minuteIncrement: number;
100
+ time_24hr: boolean;
101
+ minDate: null;
102
+ disableWeekends: boolean;
103
+ disableWeekdays: boolean;
104
+ disableFunction: string;
105
+ maxDate: null;
106
+ };
107
+ validate?: undefined;
108
+ disableOnInvalid?: undefined;
109
+ } | {
110
+ type: string;
111
+ label: string;
112
+ key: string;
113
+ disableOnInvalid: boolean;
114
+ input: boolean;
115
+ tableView: boolean;
116
+ datePicker?: undefined;
117
+ enableMinDateInput?: undefined;
118
+ enableMaxDateInput?: undefined;
119
+ widget?: undefined;
120
+ validate?: undefined;
121
+ })[];
122
+ }
123
+ export default _default;
@@ -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
+ };
@@ -2,6 +2,7 @@ import comp1 from './comp1';
2
2
  import comp10 from './comp10';
3
3
  import comp11 from './comp11';
4
4
  import comp12 from './comp12';
5
+ import comp13 from './comp13';
5
6
  import comp2 from './comp2';
6
7
  import comp3 from './comp3';
7
8
  import comp5 from './comp5';
@@ -9,4 +10,4 @@ import comp6 from './comp6';
9
10
  import comp7 from './comp7';
10
11
  import comp8 from './comp8';
11
12
  import comp9 from './comp9';
12
- export { comp1, comp10, comp11, comp12, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
13
+ export { comp1, comp10, comp11, comp12, comp13, comp2, comp3, comp5, comp6, comp7, comp8, comp9 };
@@ -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 };
@@ -136,6 +136,7 @@ export default class FormComponent extends Component {
136
136
  return this.subForm.getComponent(path, fn, originalPathStr);
137
137
  }
138
138
  }
139
+ /* eslint-disable max-statements */
139
140
  getSubOptions(options = {}) {
140
141
  options.parentPath = `${this.path}.data.`;
141
142
  options.events = this.createEmitter();
@@ -189,8 +190,16 @@ export default class FormComponent extends Component {
189
190
  if (this.options.preview) {
190
191
  options.preview = this.options.preview;
191
192
  }
193
+ if (this.options.saveDraft) {
194
+ options.saveDraft = this.options.saveDraft;
195
+ options.formio = new Formio(this.formSrc);
196
+ }
197
+ if (this.options.saveDraftThrottle) {
198
+ options.saveDraftThrottle = this.options.saveDraftThrottle;
199
+ }
192
200
  return options;
193
201
  }
202
+ /* eslint-enable max-statements */
194
203
  render() {
195
204
  if (this.builderMode) {
196
205
  return super.render(this.component.label || 'Nested form');
@@ -425,7 +434,13 @@ export default class FormComponent extends Component {
425
434
  }
426
435
  else if (this.formSrc) {
427
436
  this.subFormLoading = true;
428
- return (new Formio(this.formSrc)).loadForm({ params: { live: 1 } })
437
+ const options = this.root.formio?.base && this.root.formio?.projectUrl
438
+ ? {
439
+ base: this.root.formio.base,
440
+ project: this.root.formio.projectUrl,
441
+ }
442
+ : {};
443
+ return (new Formio(this.formSrc, options)).loadForm({ params: { live: 1 } })
429
444
  .then((formObj) => {
430
445
  this.formObj = formObj;
431
446
  if (this.options.pdf && this.component.useOriginalRevision) {
@@ -601,7 +616,13 @@ export default class FormComponent extends Component {
601
616
  if (shouldLoadSubmissionById) {
602
617
  const formId = submission.form || this.formObj.form || this.component.form;
603
618
  const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
604
- 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 });
605
626
  this.subForm.loadSubmission().catch((err) => {
606
627
  console.error(`Unable to load subform submission ${submission._id}:`, err);
607
628
  });
@@ -25,6 +25,24 @@ export default class RadioComponent extends ListComponent {
25
25
  isPrototypeOf(v: Object): boolean;
26
26
  propertyIsEnumerable(v: PropertyKey): boolean;
27
27
  };
28
+ static get serverConditionSettings(): {
29
+ valueComponent(classComp: any): {
30
+ type: string;
31
+ dataSrc: string;
32
+ valueProperty: string;
33
+ dataType: any;
34
+ data: {
35
+ custom: string;
36
+ };
37
+ };
38
+ constructor: Function;
39
+ toString(): string;
40
+ toLocaleString(): string;
41
+ valueOf(): Object;
42
+ hasOwnProperty(v: PropertyKey): boolean;
43
+ isPrototypeOf(v: Object): boolean;
44
+ propertyIsEnumerable(v: PropertyKey): boolean;
45
+ };
28
46
  static savedValueTypes(schema: any): any[];
29
47
  constructor(component: any, options: any, data: any);
30
48
  previousValue: any;
@@ -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;
@@ -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-dev.5543.201e658",
3
+ "version": "5.0.0-dev.5543.3c780dd",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -109,7 +109,7 @@
109
109
  "moment": "^2.29.4",
110
110
  "moment-timezone": "^0.5.44",
111
111
  "quill": "^2.0.0-dev.3",
112
- "signature_pad": "^4.1.4",
112
+ "signature_pad": "^4.2.0",
113
113
  "string-hash": "^1.1.3",
114
114
  "tippy.js": "^6.3.7",
115
115
  "uuid": "^9.0.0",