@formio/js 5.1.0-dev.6048.c77fe06 → 5.1.0-dev.6050.f1c0fbe

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.
@@ -1623,6 +1623,10 @@ class WebformBuilder extends Component_1.default {
1623
1623
  info.type);
1624
1624
  }
1625
1625
  hasEditTabs(type) {
1626
+ // If the component type does not exist then it has no edit tabs
1627
+ if (!Components_1.default.components[type]) {
1628
+ return false;
1629
+ }
1626
1630
  const editTabs = (0, formUtils_1.getComponent)(Components_1.default.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
1627
1631
  const hiddenEditTabs = lodash_1.default.filter(lodash_1.default.get(this.options, `editForm.${type}`, []), 'ignore');
1628
1632
  return lodash_1.default.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
@@ -106,6 +106,7 @@ declare class Wizard extends Webform {
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
108
  focusOnComponent(key: any): void | Promise<void>;
109
+ triggerButtonCaptcha(page: any): void;
109
110
  }
110
111
  declare namespace Wizard {
111
112
  let setBaseUrl: any;
package/lib/cjs/Wizard.js CHANGED
@@ -670,6 +670,7 @@ class Wizard extends Webform_1.default {
670
670
  beforeSubmit() {
671
671
  const pages = this.getPages({ all: true });
672
672
  return Promise.all(pages.map((page) => {
673
+ this.triggerButtonCaptcha(page);
673
674
  page.options.beforeSubmit = true;
674
675
  return page.beforeSubmit();
675
676
  }));
@@ -945,6 +946,22 @@ class Wizard extends Webform_1.default {
945
946
  }
946
947
  return super.focusOnComponent(key);
947
948
  }
949
+ triggerButtonCaptcha(page) {
950
+ if (!page.components) {
951
+ return;
952
+ }
953
+ let captchaComponent;
954
+ page.eachComponent((component) => {
955
+ if (/^(re)?captcha$/.test(component.component.type) &&
956
+ component.component.eventType === 'buttonClick' &&
957
+ component.component.buttonKey === 'submit') {
958
+ captchaComponent = component;
959
+ }
960
+ });
961
+ if (captchaComponent) {
962
+ captchaComponent.verify(`submitClick`);
963
+ }
964
+ }
948
965
  }
949
966
  exports.default = Wizard;
950
967
  Wizard.setBaseUrl = Formio_1.Formio.setBaseUrl;
@@ -43,6 +43,14 @@ export default class AddressComponent extends ContainerComponent {
43
43
  isValueInLegacyFormat(value: any): any;
44
44
  normalizeValue(value: any): any;
45
45
  get modeSwitcher(): any;
46
+ get providerOptions(): {
47
+ params: any;
48
+ url: any;
49
+ queryProperty: any;
50
+ responseProperty: any;
51
+ displayValueProperty: any;
52
+ autocompleteOptions: any;
53
+ };
46
54
  get removeValueIcon(): any;
47
55
  get searchInput(): any;
48
56
  get addRowButton(): any;
@@ -26,7 +26,6 @@ class AddressComponent extends Container_1.default {
26
26
  key: 'address',
27
27
  switchToManualModeLabel: 'Can\'t find address? Switch to manual mode.',
28
28
  provider: '',
29
- providerOptions: {},
30
29
  manualModeViewString: '',
31
30
  hideLabel: false,
32
31
  disableClearIcon: false,
@@ -116,20 +115,20 @@ class AddressComponent extends Container_1.default {
116
115
  NestedComponent_1.default.prototype.addComponents.call(this, this.manualMode ? this.address : {});
117
116
  }
118
117
  Field_1.default.prototype.init.call(this);
118
+ let provider = this.component.provider;
119
+ const providerOptions = this.providerOptions;
120
+ const map = this.component.map;
119
121
  if (!this.builderMode) {
120
- if (this.component.provider) {
121
- const { provider, providerOptions, } = this.component;
122
+ if (provider) {
122
123
  if (lodash_1.default.get(providerOptions, 'params.subscriptionKey')) {
123
124
  lodash_1.default.set(providerOptions, "params['subscription-key']", lodash_1.default.get(providerOptions, 'params.subscriptionKey'));
124
125
  lodash_1.default.unset(providerOptions, 'params.subscriptionKey');
125
126
  }
126
127
  this.provider = this.initializeProvider(provider, providerOptions);
127
128
  }
128
- else if (this.component.map) {
129
+ else if (map) {
129
130
  // Fallback to legacy version where Google Maps was the only provider.
130
- this.component.provider = GoogleAddressProvider_1.GoogleAddressProvider.name;
131
- this.component.providerOptions = this.component.providerOptions || {};
132
- const { map, provider, providerOptions, } = this.component;
131
+ provider = this.component.provider = GoogleAddressProvider_1.GoogleAddressProvider.name;
133
132
  const { key, region, } = map;
134
133
  if (key) {
135
134
  lodash_1.default.set(providerOptions, 'params.key', key);
@@ -262,6 +261,16 @@ class AddressComponent extends Container_1.default {
262
261
  ? (this.refs[AddressComponent.modeSwitcherRef] || null)
263
262
  : null;
264
263
  }
264
+ get providerOptions() {
265
+ return {
266
+ params: Object.assign({ subscriptionKey: this.component.subscriptionKey, key: this.component.apiKey }, this.component.params),
267
+ url: this.component.url,
268
+ queryProperty: this.component.queryProperty,
269
+ responseProperty: this.component.responseProperty,
270
+ displayValueProperty: this.component.displayValueProperty,
271
+ autocompleteOptions: this.component.autocompleteOptions
272
+ };
273
+ }
265
274
  get removeValueIcon() {
266
275
  return this.refs
267
276
  ? (this.refs[AddressComponent.removeValueIconRef] || null)
@@ -375,7 +384,8 @@ class AddressComponent extends Container_1.default {
375
384
  const result = ((this.builderMode || this.manualMode) ? super.attach : Field_1.default.prototype.attach).call(this, element);
376
385
  if (!this.builderMode) {
377
386
  if (!this.provider && this.component.provider) {
378
- const { provider, providerOptions, } = this.component;
387
+ const provider = this.component.provider;
388
+ const providerOptions = this.providerOptions;
379
389
  this.provider = this.initializeProvider(provider, providerOptions);
380
390
  }
381
391
  }
@@ -31,7 +31,7 @@ exports.default = [
31
31
  {
32
32
  type: 'textfield',
33
33
  input: true,
34
- key: "providerOptions.params.subscriptionKey",
34
+ key: "subscriptionKey",
35
35
  label: 'Subscription Key',
36
36
  placeholder: 'Enter Subscription Key',
37
37
  weight: 10,
@@ -46,7 +46,7 @@ exports.default = [
46
46
  {
47
47
  type: 'textfield',
48
48
  input: true,
49
- key: 'providerOptions.url',
49
+ key: 'url',
50
50
  label: 'Url',
51
51
  placeholder: 'Enter Url',
52
52
  weight: 10,
@@ -61,7 +61,7 @@ exports.default = [
61
61
  {
62
62
  type: 'textfield',
63
63
  input: true,
64
- key: 'providerOptions.queryProperty',
64
+ key: 'queryProperty',
65
65
  label: 'Query Property',
66
66
  defaultValue: 'query',
67
67
  placeholder: 'Enter Query Property',
@@ -74,7 +74,7 @@ exports.default = [
74
74
  {
75
75
  type: 'textfield',
76
76
  input: true,
77
- key: 'providerOptions.responseProperty',
77
+ key: 'responseProperty',
78
78
  label: 'Response Property',
79
79
  placeholder: 'Enter Response Property',
80
80
  weight: 30,
@@ -86,7 +86,7 @@ exports.default = [
86
86
  {
87
87
  type: 'textfield',
88
88
  input: true,
89
- key: 'providerOptions.displayValueProperty',
89
+ key: 'displayValueProperty',
90
90
  label: 'Display Value Property',
91
91
  placeholder: 'Display Value Property',
92
92
  weight: 40,
@@ -98,7 +98,7 @@ exports.default = [
98
98
  {
99
99
  type: 'textarea',
100
100
  input: true,
101
- key: 'providerOptions.params',
101
+ key: 'params',
102
102
  label: 'Params',
103
103
  placeholder: '{ ... }',
104
104
  weight: 50,
@@ -113,7 +113,7 @@ exports.default = [
113
113
  {
114
114
  type: 'textfield',
115
115
  input: true,
116
- key: 'providerOptions.params.key',
116
+ key: 'apiKey',
117
117
  label: 'API Key',
118
118
  placeholder: 'Enter API Key',
119
119
  weight: 10,
@@ -128,7 +128,7 @@ exports.default = [
128
128
  {
129
129
  type: 'textarea',
130
130
  input: true,
131
- key: 'providerOptions.params.autocompleteOptions',
131
+ key: 'autocompleteOptions',
132
132
  label: 'Provider options',
133
133
  placeholder: 'Enter provider options as JSON object',
134
134
  defaultValue: {},
@@ -1459,7 +1459,7 @@ class SelectComponent extends ListComponent_1.default {
1459
1459
  asString(value, options = {}) {
1460
1460
  var _a;
1461
1461
  value = value !== null && value !== void 0 ? value : this.getValue();
1462
- if (options.modalPreview || this.inDataTable) {
1462
+ if (options.modalPreview || this.inDataTable || options.email) {
1463
1463
  if (this.inDataTable) {
1464
1464
  value = this.undoValueTyping(value);
1465
1465
  }
@@ -1626,6 +1626,10 @@ export default class WebformBuilder extends Component {
1626
1626
  info.type);
1627
1627
  }
1628
1628
  hasEditTabs(type) {
1629
+ // If the component type does not exist then it has no edit tabs
1630
+ if (!Components.components[type]) {
1631
+ return false;
1632
+ }
1629
1633
  const editTabs = getComponent(Components.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
1630
1634
  const hiddenEditTabs = _.filter(_.get(this.options, `editForm.${type}`, []), 'ignore');
1631
1635
  return _.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
@@ -106,6 +106,7 @@ declare class Wizard extends Webform {
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
108
  focusOnComponent(key: any): void | Promise<void>;
109
+ triggerButtonCaptcha(page: any): void;
109
110
  }
110
111
  declare namespace Wizard {
111
112
  let setBaseUrl: any;
package/lib/mjs/Wizard.js CHANGED
@@ -660,6 +660,7 @@ export default class Wizard extends Webform {
660
660
  beforeSubmit() {
661
661
  const pages = this.getPages({ all: true });
662
662
  return Promise.all(pages.map((page) => {
663
+ this.triggerButtonCaptcha(page);
663
664
  page.options.beforeSubmit = true;
664
665
  return page.beforeSubmit();
665
666
  }));
@@ -933,6 +934,22 @@ export default class Wizard extends Webform {
933
934
  }
934
935
  return super.focusOnComponent(key);
935
936
  }
937
+ triggerButtonCaptcha(page) {
938
+ if (!page.components) {
939
+ return;
940
+ }
941
+ let captchaComponent;
942
+ page.eachComponent((component) => {
943
+ if (/^(re)?captcha$/.test(component.component.type) &&
944
+ component.component.eventType === 'buttonClick' &&
945
+ component.component.buttonKey === 'submit') {
946
+ captchaComponent = component;
947
+ }
948
+ });
949
+ if (captchaComponent) {
950
+ captchaComponent.verify(`submitClick`);
951
+ }
952
+ }
936
953
  }
937
954
  Wizard.setBaseUrl = Formio.setBaseUrl;
938
955
  Wizard.setApiUrl = Formio.setApiUrl;
@@ -43,6 +43,14 @@ export default class AddressComponent extends ContainerComponent {
43
43
  isValueInLegacyFormat(value: any): any;
44
44
  normalizeValue(value: any): any;
45
45
  get modeSwitcher(): any;
46
+ get providerOptions(): {
47
+ params: any;
48
+ url: any;
49
+ queryProperty: any;
50
+ responseProperty: any;
51
+ displayValueProperty: any;
52
+ autocompleteOptions: any;
53
+ };
46
54
  get removeValueIcon(): any;
47
55
  get searchInput(): any;
48
56
  get addRowButton(): any;
@@ -20,7 +20,6 @@ export default class AddressComponent extends ContainerComponent {
20
20
  key: 'address',
21
21
  switchToManualModeLabel: 'Can\'t find address? Switch to manual mode.',
22
22
  provider: '',
23
- providerOptions: {},
24
23
  manualModeViewString: '',
25
24
  hideLabel: false,
26
25
  disableClearIcon: false,
@@ -113,20 +112,20 @@ export default class AddressComponent extends ContainerComponent {
113
112
  NestedComponent.prototype.addComponents.call(this, this.manualMode ? this.address : {});
114
113
  }
115
114
  Field.prototype.init.call(this);
115
+ let provider = this.component.provider;
116
+ const providerOptions = this.providerOptions;
117
+ const map = this.component.map;
116
118
  if (!this.builderMode) {
117
- if (this.component.provider) {
118
- const { provider, providerOptions, } = this.component;
119
+ if (provider) {
119
120
  if (_.get(providerOptions, 'params.subscriptionKey')) {
120
121
  _.set(providerOptions, "params['subscription-key']", _.get(providerOptions, 'params.subscriptionKey'));
121
122
  _.unset(providerOptions, 'params.subscriptionKey');
122
123
  }
123
124
  this.provider = this.initializeProvider(provider, providerOptions);
124
125
  }
125
- else if (this.component.map) {
126
+ else if (map) {
126
127
  // Fallback to legacy version where Google Maps was the only provider.
127
- this.component.provider = GoogleAddressProvider.name;
128
- this.component.providerOptions = this.component.providerOptions || {};
129
- const { map, provider, providerOptions, } = this.component;
128
+ provider = this.component.provider = GoogleAddressProvider.name;
130
129
  const { key, region, } = map;
131
130
  if (key) {
132
131
  _.set(providerOptions, 'params.key', key);
@@ -258,6 +257,16 @@ export default class AddressComponent extends ContainerComponent {
258
257
  ? (this.refs[AddressComponent.modeSwitcherRef] || null)
259
258
  : null;
260
259
  }
260
+ get providerOptions() {
261
+ return {
262
+ params: { subscriptionKey: this.component.subscriptionKey, key: this.component.apiKey, ...this.component.params },
263
+ url: this.component.url,
264
+ queryProperty: this.component.queryProperty,
265
+ responseProperty: this.component.responseProperty,
266
+ displayValueProperty: this.component.displayValueProperty,
267
+ autocompleteOptions: this.component.autocompleteOptions
268
+ };
269
+ }
261
270
  get removeValueIcon() {
262
271
  return this.refs
263
272
  ? (this.refs[AddressComponent.removeValueIconRef] || null)
@@ -371,7 +380,8 @@ export default class AddressComponent extends ContainerComponent {
371
380
  const result = ((this.builderMode || this.manualMode) ? super.attach : Field.prototype.attach).call(this, element);
372
381
  if (!this.builderMode) {
373
382
  if (!this.provider && this.component.provider) {
374
- const { provider, providerOptions, } = this.component;
383
+ const provider = this.component.provider;
384
+ const providerOptions = this.providerOptions;
375
385
  this.provider = this.initializeProvider(provider, providerOptions);
376
386
  }
377
387
  }
@@ -26,7 +26,7 @@ export default [
26
26
  {
27
27
  type: 'textfield',
28
28
  input: true,
29
- key: "providerOptions.params.subscriptionKey",
29
+ key: "subscriptionKey",
30
30
  label: 'Subscription Key',
31
31
  placeholder: 'Enter Subscription Key',
32
32
  weight: 10,
@@ -41,7 +41,7 @@ export default [
41
41
  {
42
42
  type: 'textfield',
43
43
  input: true,
44
- key: 'providerOptions.url',
44
+ key: 'url',
45
45
  label: 'Url',
46
46
  placeholder: 'Enter Url',
47
47
  weight: 10,
@@ -56,7 +56,7 @@ export default [
56
56
  {
57
57
  type: 'textfield',
58
58
  input: true,
59
- key: 'providerOptions.queryProperty',
59
+ key: 'queryProperty',
60
60
  label: 'Query Property',
61
61
  defaultValue: 'query',
62
62
  placeholder: 'Enter Query Property',
@@ -69,7 +69,7 @@ export default [
69
69
  {
70
70
  type: 'textfield',
71
71
  input: true,
72
- key: 'providerOptions.responseProperty',
72
+ key: 'responseProperty',
73
73
  label: 'Response Property',
74
74
  placeholder: 'Enter Response Property',
75
75
  weight: 30,
@@ -81,7 +81,7 @@ export default [
81
81
  {
82
82
  type: 'textfield',
83
83
  input: true,
84
- key: 'providerOptions.displayValueProperty',
84
+ key: 'displayValueProperty',
85
85
  label: 'Display Value Property',
86
86
  placeholder: 'Display Value Property',
87
87
  weight: 40,
@@ -93,7 +93,7 @@ export default [
93
93
  {
94
94
  type: 'textarea',
95
95
  input: true,
96
- key: 'providerOptions.params',
96
+ key: 'params',
97
97
  label: 'Params',
98
98
  placeholder: '{ ... }',
99
99
  weight: 50,
@@ -108,7 +108,7 @@ export default [
108
108
  {
109
109
  type: 'textfield',
110
110
  input: true,
111
- key: 'providerOptions.params.key',
111
+ key: 'apiKey',
112
112
  label: 'API Key',
113
113
  placeholder: 'Enter API Key',
114
114
  weight: 10,
@@ -123,7 +123,7 @@ export default [
123
123
  {
124
124
  type: 'textarea',
125
125
  input: true,
126
- key: 'providerOptions.params.autocompleteOptions',
126
+ key: 'autocompleteOptions',
127
127
  label: 'Provider options',
128
128
  placeholder: 'Enter provider options as JSON object',
129
129
  defaultValue: {},
@@ -1487,7 +1487,7 @@ export default class SelectComponent extends ListComponent {
1487
1487
  }
1488
1488
  asString(value, options = {}) {
1489
1489
  value = value ?? this.getValue();
1490
- if (options.modalPreview || this.inDataTable) {
1490
+ if (options.modalPreview || this.inDataTable || options.email) {
1491
1491
  if (this.inDataTable) {
1492
1492
  value = this.undoValueTyping(value);
1493
1493
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6048.c77fe06",
3
+ "version": "5.1.0-dev.6050.f1c0fbe",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {