@formio/js 5.0.0-dev.5686.783670c → 5.0.0-dev.5687.07dacac

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.
@@ -190,5 +190,13 @@ exports.default = [
190
190
  key: 'tableView',
191
191
  input: true
192
192
  },
193
+ {
194
+ weight: 1600,
195
+ type: 'checkbox',
196
+ label: 'Modal Edit',
197
+ tooltip: 'Opens up a modal to edit the value of this component.',
198
+ key: 'modalEdit',
199
+ input: true
200
+ }
193
201
  ];
194
202
  /* eslint-enable max-len */
@@ -0,0 +1,41 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ hideInputLabels: boolean;
5
+ inputsLabelPosition: string;
6
+ useLocaleSettings: boolean;
7
+ alwaysEnabled: boolean;
8
+ tableView: boolean;
9
+ fields: {
10
+ day: {
11
+ hide: boolean;
12
+ required: boolean;
13
+ };
14
+ month: {
15
+ hide: boolean;
16
+ required: boolean;
17
+ };
18
+ year: {
19
+ hide: boolean;
20
+ required: boolean;
21
+ };
22
+ };
23
+ key: string;
24
+ type: string;
25
+ input: boolean;
26
+ showValidations?: undefined;
27
+ } | {
28
+ label: string;
29
+ showValidations: boolean;
30
+ alwaysEnabled: boolean;
31
+ tableView: boolean;
32
+ key: string;
33
+ type: string;
34
+ input: boolean;
35
+ hideInputLabels?: undefined;
36
+ inputsLabelPosition?: undefined;
37
+ useLocaleSettings?: undefined;
38
+ fields?: undefined;
39
+ })[];
40
+ }
41
+ export default _default;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "components": [
5
+ {
6
+ "label": "Day - Table",
7
+ "hideInputLabels": false,
8
+ "inputsLabelPosition": "top",
9
+ "useLocaleSettings": false,
10
+ "alwaysEnabled": false,
11
+ "tableView": false,
12
+ "fields": {
13
+ "day": {
14
+ "hide": false,
15
+ "required": true
16
+ },
17
+ "month": {
18
+ "hide": false,
19
+ "required": true
20
+ },
21
+ "year": {
22
+ "hide": false,
23
+ "required": true
24
+ }
25
+ },
26
+ "key": "dayTable",
27
+ "type": "day",
28
+ "input": true
29
+ },
30
+ {
31
+ "label": "Submit",
32
+ "showValidations": false,
33
+ "alwaysEnabled": false,
34
+ "tableView": false,
35
+ "key": "submit",
36
+ "type": "button",
37
+ "input": true
38
+ }
39
+ ]
40
+ };
@@ -5,4 +5,5 @@ import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
8
+ import comp8 from './comp8';
9
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -18,3 +18,5 @@ const comp6_1 = __importDefault(require("./comp6"));
18
18
  exports.comp6 = comp6_1.default;
19
19
  const comp7_1 = __importDefault(require("./comp7"));
20
20
  exports.comp7 = comp7_1.default;
21
+ const comp8_1 = __importDefault(require("./comp8"));
22
+ exports.comp8 = comp8_1.default;
@@ -82,6 +82,11 @@ export class GoogleAddressProvider extends AddressProvider {
82
82
  search(): Promise<void>;
83
83
  makeRequest(): Promise<void>;
84
84
  getDisplayValue(address: any): any;
85
+ /**
86
+ * Tries to remove the library if api key for loaded script is different.
87
+ * @param {ProviderOptions} options - The options for the provider.
88
+ */
89
+ tryRemoveLibrary(options?: ProviderOptions): void;
85
90
  }
86
91
  export type AutocompleteOptions = {
87
92
  /**
@@ -8,6 +8,9 @@ exports.GoogleAddressProvider = void 0;
8
8
  const Formio_1 = require("../../Formio");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const AddressProvider_1 = require("./AddressProvider");
11
+ const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
12
+ const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
13
+ const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
11
14
  /**
12
15
  * @typedef {object} AutocompleteOptions
13
16
  * @property {string[]} fields - The fields to include in the autocomplete response.
@@ -55,10 +58,11 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
55
58
  var _a;
56
59
  super(options);
57
60
  this.setAutocompleteOptions();
58
- let src = 'https://maps.googleapis.com/maps/api/js?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback';
61
+ let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
59
62
  if ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) {
60
63
  src += `&key=${options.params.key}`;
61
64
  }
65
+ this.tryRemoveLibrary(options);
62
66
  Formio_1.Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
63
67
  }
64
68
  /**
@@ -185,5 +189,23 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
185
189
  : this.alternativeDisplayValueProperty;
186
190
  return lodash_1.default.get(address, displayedProperty, '');
187
191
  }
192
+ /**
193
+ * Tries to remove the library if api key for loaded script is different.
194
+ * @param {ProviderOptions} options - The options for the provider.
195
+ */
196
+ tryRemoveLibrary(options = {}) {
197
+ var _a, _b, _c;
198
+ if (!Formio_1.Formio.libraries[this.getLibraryName()]) {
199
+ return;
200
+ }
201
+ const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
202
+ if (existingScript && ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) && !existingScript.attributes.src.value.endsWith(options.params.key)) {
203
+ const googleMapsScripts = (_b = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`)) !== null && _b !== void 0 ? _b : [];
204
+ googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
205
+ delete Formio_1.Formio.libraries[this.getLibraryName()];
206
+ (_c = global === null || global === void 0 ? void 0 : global.google) === null || _c === void 0 ? true : delete _c.maps;
207
+ delete global[`${this.getLibraryName()}Callback`];
208
+ }
209
+ }
188
210
  }
189
211
  exports.GoogleAddressProvider = GoogleAddressProvider;
@@ -74,5 +74,8 @@ declare namespace _default {
74
74
  let apiKey: string;
75
75
  let typeRemaining: string;
76
76
  let typeCount: string;
77
+ let requiredDayField: string;
78
+ let requiredMonthField: string;
79
+ let requiredYearField: string;
77
80
  }
78
81
  export default _default;
@@ -75,5 +75,8 @@ exports.default = {
75
75
  reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
76
76
  apiKey: 'API Key is not unique: {{key}}',
77
77
  typeRemaining: '{{ remaining }} {{ type }} remaining.',
78
- typeCount: '{{ count }} {{ type }}'
78
+ typeCount: '{{ count }} {{ type }}',
79
+ requiredDayField: '{{ field }} is required',
80
+ requiredMonthField: '{{ field }} is required',
81
+ requiredYearField: '{{ field }} is required'
79
82
  };
@@ -187,5 +187,13 @@ export default [
187
187
  key: 'tableView',
188
188
  input: true
189
189
  },
190
+ {
191
+ weight: 1600,
192
+ type: 'checkbox',
193
+ label: 'Modal Edit',
194
+ tooltip: 'Opens up a modal to edit the value of this component.',
195
+ key: 'modalEdit',
196
+ input: true
197
+ }
190
198
  ];
191
199
  /* eslint-enable max-len */
@@ -0,0 +1,41 @@
1
+ declare namespace _default {
2
+ let components: ({
3
+ label: string;
4
+ hideInputLabels: boolean;
5
+ inputsLabelPosition: string;
6
+ useLocaleSettings: boolean;
7
+ alwaysEnabled: boolean;
8
+ tableView: boolean;
9
+ fields: {
10
+ day: {
11
+ hide: boolean;
12
+ required: boolean;
13
+ };
14
+ month: {
15
+ hide: boolean;
16
+ required: boolean;
17
+ };
18
+ year: {
19
+ hide: boolean;
20
+ required: boolean;
21
+ };
22
+ };
23
+ key: string;
24
+ type: string;
25
+ input: boolean;
26
+ showValidations?: undefined;
27
+ } | {
28
+ label: string;
29
+ showValidations: boolean;
30
+ alwaysEnabled: boolean;
31
+ tableView: boolean;
32
+ key: string;
33
+ type: string;
34
+ input: boolean;
35
+ hideInputLabels?: undefined;
36
+ inputsLabelPosition?: undefined;
37
+ useLocaleSettings?: undefined;
38
+ fields?: undefined;
39
+ })[];
40
+ }
41
+ export default _default;
@@ -0,0 +1,38 @@
1
+ export default {
2
+ "components": [
3
+ {
4
+ "label": "Day - Table",
5
+ "hideInputLabels": false,
6
+ "inputsLabelPosition": "top",
7
+ "useLocaleSettings": false,
8
+ "alwaysEnabled": false,
9
+ "tableView": false,
10
+ "fields": {
11
+ "day": {
12
+ "hide": false,
13
+ "required": true
14
+ },
15
+ "month": {
16
+ "hide": false,
17
+ "required": true
18
+ },
19
+ "year": {
20
+ "hide": false,
21
+ "required": true
22
+ }
23
+ },
24
+ "key": "dayTable",
25
+ "type": "day",
26
+ "input": true
27
+ },
28
+ {
29
+ "label": "Submit",
30
+ "showValidations": false,
31
+ "alwaysEnabled": false,
32
+ "tableView": false,
33
+ "key": "submit",
34
+ "type": "button",
35
+ "input": true
36
+ }
37
+ ]
38
+ };
@@ -5,4 +5,5 @@ import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
8
+ import comp8 from './comp8';
9
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 };
@@ -5,4 +5,5 @@ import comp4 from './comp4';
5
5
  import comp5 from './comp5';
6
6
  import comp6 from './comp6';
7
7
  import comp7 from './comp7';
8
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
8
+ import comp8 from './comp8';
9
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 };
@@ -82,6 +82,11 @@ export class GoogleAddressProvider extends AddressProvider {
82
82
  search(): Promise<void>;
83
83
  makeRequest(): Promise<void>;
84
84
  getDisplayValue(address: any): any;
85
+ /**
86
+ * Tries to remove the library if api key for loaded script is different.
87
+ * @param {ProviderOptions} options - The options for the provider.
88
+ */
89
+ tryRemoveLibrary(options?: ProviderOptions): void;
85
90
  }
86
91
  export type AutocompleteOptions = {
87
92
  /**
@@ -2,6 +2,9 @@
2
2
  import { Formio } from '../../Formio';
3
3
  import _ from 'lodash';
4
4
  import { AddressProvider } from './AddressProvider';
5
+ const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
6
+ const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
7
+ const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
5
8
  /**
6
9
  * @typedef {object} AutocompleteOptions
7
10
  * @property {string[]} fields - The fields to include in the autocomplete response.
@@ -48,10 +51,11 @@ export class GoogleAddressProvider extends AddressProvider {
48
51
  constructor(options = {}) {
49
52
  super(options);
50
53
  this.setAutocompleteOptions();
51
- let src = 'https://maps.googleapis.com/maps/api/js?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback';
54
+ let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
52
55
  if (options.params?.key) {
53
56
  src += `&key=${options.params.key}`;
54
57
  }
58
+ this.tryRemoveLibrary(options);
55
59
  Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
56
60
  }
57
61
  /**
@@ -178,4 +182,21 @@ export class GoogleAddressProvider extends AddressProvider {
178
182
  : this.alternativeDisplayValueProperty;
179
183
  return _.get(address, displayedProperty, '');
180
184
  }
185
+ /**
186
+ * Tries to remove the library if api key for loaded script is different.
187
+ * @param {ProviderOptions} options - The options for the provider.
188
+ */
189
+ tryRemoveLibrary(options = {}) {
190
+ if (!Formio.libraries[this.getLibraryName()]) {
191
+ return;
192
+ }
193
+ const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
194
+ if (existingScript && options.params?.key && !existingScript.attributes.src.value.endsWith(options.params.key)) {
195
+ const googleMapsScripts = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`) ?? [];
196
+ googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
197
+ delete Formio.libraries[this.getLibraryName()];
198
+ delete global?.google?.maps;
199
+ delete global[`${this.getLibraryName()}Callback`];
200
+ }
201
+ }
181
202
  }
@@ -74,5 +74,8 @@ declare namespace _default {
74
74
  let apiKey: string;
75
75
  let typeRemaining: string;
76
76
  let typeCount: string;
77
+ let requiredDayField: string;
78
+ let requiredMonthField: string;
79
+ let requiredYearField: string;
77
80
  }
78
81
  export default _default;
@@ -73,5 +73,8 @@ export default {
73
73
  reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
74
74
  apiKey: 'API Key is not unique: {{key}}',
75
75
  typeRemaining: '{{ remaining }} {{ type }} remaining.',
76
- typeCount: '{{ count }} {{ type }}'
76
+ typeCount: '{{ count }} {{ type }}',
77
+ requiredDayField: '{{ field }} is required',
78
+ requiredMonthField: '{{ field }} is required',
79
+ requiredYearField: '{{ field }} is required'
77
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5686.783670c",
3
+ "version": "5.0.0-dev.5687.07dacac",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {