@formio/js 5.1.0-dev.6054.7ae1465 → 5.1.0-dev.6055.13dee3b

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.
@@ -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,33 @@ 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
+ // Added for backwards compatibility
119
+ if (this.component.providerOptions) {
120
+ const { params, url, queryProperty, responseProperty, displayValueProperty } = this.component.providerOptions;
121
+ const key = params === null || params === void 0 ? void 0 : params.key;
122
+ const autocompleteOptions = params === null || params === void 0 ? void 0 : params.autocompleteOptions;
123
+ delete this.component.providerOptions;
124
+ this.component.url = url;
125
+ this.component.queryProperty = queryProperty;
126
+ this.component.responseProperty = responseProperty;
127
+ this.component.displayValueProperty = displayValueProperty;
128
+ this.component.apiKey = key;
129
+ this.component.autocompleteOptions = autocompleteOptions;
130
+ }
131
+ let provider = this.component.provider;
132
+ const providerOptions = this.providerOptions;
133
+ const map = this.component.map;
119
134
  if (!this.builderMode) {
120
- if (this.component.provider) {
121
- const { provider, providerOptions, } = this.component;
135
+ if (provider) {
122
136
  if (lodash_1.default.get(providerOptions, 'params.subscriptionKey')) {
123
137
  lodash_1.default.set(providerOptions, "params['subscription-key']", lodash_1.default.get(providerOptions, 'params.subscriptionKey'));
124
138
  lodash_1.default.unset(providerOptions, 'params.subscriptionKey');
125
139
  }
126
140
  this.provider = this.initializeProvider(provider, providerOptions);
127
141
  }
128
- else if (this.component.map) {
142
+ else if (map) {
129
143
  // 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;
144
+ provider = this.component.provider = GoogleAddressProvider_1.GoogleAddressProvider.name;
133
145
  const { key, region, } = map;
134
146
  if (key) {
135
147
  lodash_1.default.set(providerOptions, 'params.key', key);
@@ -262,6 +274,16 @@ class AddressComponent extends Container_1.default {
262
274
  ? (this.refs[AddressComponent.modeSwitcherRef] || null)
263
275
  : null;
264
276
  }
277
+ get providerOptions() {
278
+ return {
279
+ params: Object.assign({ subscriptionKey: this.component.subscriptionKey, key: this.component.apiKey }, this.component.params),
280
+ url: this.component.url,
281
+ queryProperty: this.component.queryProperty,
282
+ responseProperty: this.component.responseProperty,
283
+ displayValueProperty: this.component.displayValueProperty,
284
+ autocompleteOptions: this.component.autocompleteOptions
285
+ };
286
+ }
265
287
  get removeValueIcon() {
266
288
  return this.refs
267
289
  ? (this.refs[AddressComponent.removeValueIconRef] || null)
@@ -375,7 +397,8 @@ class AddressComponent extends Container_1.default {
375
397
  const result = ((this.builderMode || this.manualMode) ? super.attach : Field_1.default.prototype.attach).call(this, element);
376
398
  if (!this.builderMode) {
377
399
  if (!this.provider && this.component.provider) {
378
- const { provider, providerOptions, } = this.component;
400
+ const provider = this.component.provider;
401
+ const providerOptions = this.providerOptions;
379
402
  this.provider = this.initializeProvider(provider, providerOptions);
380
403
  }
381
404
  }
@@ -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: {},
@@ -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,33 @@ 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
+ // Added for backwards compatibility
116
+ if (this.component.providerOptions) {
117
+ const { params, url, queryProperty, responseProperty, displayValueProperty } = this.component.providerOptions;
118
+ const key = params?.key;
119
+ const autocompleteOptions = params?.autocompleteOptions;
120
+ delete this.component.providerOptions;
121
+ this.component.url = url;
122
+ this.component.queryProperty = queryProperty;
123
+ this.component.responseProperty = responseProperty;
124
+ this.component.displayValueProperty = displayValueProperty;
125
+ this.component.apiKey = key;
126
+ this.component.autocompleteOptions = autocompleteOptions;
127
+ }
128
+ let provider = this.component.provider;
129
+ const providerOptions = this.providerOptions;
130
+ const map = this.component.map;
116
131
  if (!this.builderMode) {
117
- if (this.component.provider) {
118
- const { provider, providerOptions, } = this.component;
132
+ if (provider) {
119
133
  if (_.get(providerOptions, 'params.subscriptionKey')) {
120
134
  _.set(providerOptions, "params['subscription-key']", _.get(providerOptions, 'params.subscriptionKey'));
121
135
  _.unset(providerOptions, 'params.subscriptionKey');
122
136
  }
123
137
  this.provider = this.initializeProvider(provider, providerOptions);
124
138
  }
125
- else if (this.component.map) {
139
+ else if (map) {
126
140
  // 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;
141
+ provider = this.component.provider = GoogleAddressProvider.name;
130
142
  const { key, region, } = map;
131
143
  if (key) {
132
144
  _.set(providerOptions, 'params.key', key);
@@ -258,6 +270,16 @@ export default class AddressComponent extends ContainerComponent {
258
270
  ? (this.refs[AddressComponent.modeSwitcherRef] || null)
259
271
  : null;
260
272
  }
273
+ get providerOptions() {
274
+ return {
275
+ params: { subscriptionKey: this.component.subscriptionKey, key: this.component.apiKey, ...this.component.params },
276
+ url: this.component.url,
277
+ queryProperty: this.component.queryProperty,
278
+ responseProperty: this.component.responseProperty,
279
+ displayValueProperty: this.component.displayValueProperty,
280
+ autocompleteOptions: this.component.autocompleteOptions
281
+ };
282
+ }
261
283
  get removeValueIcon() {
262
284
  return this.refs
263
285
  ? (this.refs[AddressComponent.removeValueIconRef] || null)
@@ -371,7 +393,8 @@ export default class AddressComponent extends ContainerComponent {
371
393
  const result = ((this.builderMode || this.manualMode) ? super.attach : Field.prototype.attach).call(this, element);
372
394
  if (!this.builderMode) {
373
395
  if (!this.provider && this.component.provider) {
374
- const { provider, providerOptions, } = this.component;
396
+ const provider = this.component.provider;
397
+ const providerOptions = this.providerOptions;
375
398
  this.provider = this.initializeProvider(provider, providerOptions);
376
399
  }
377
400
  }
@@ -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: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6054.7ae1465",
3
+ "version": "5.1.0-dev.6055.13dee3b",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {