@formio/js 5.0.0-dev.5684.206e5cd → 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.
Files changed (31) hide show
  1. package/dist/formio.form.js +5 -5
  2. package/dist/formio.form.min.js +1 -1
  3. package/dist/formio.full.js +5 -5
  4. package/dist/formio.full.min.js +1 -1
  5. package/dist/formio.js +1 -1
  6. package/dist/formio.min.js +1 -1
  7. package/dist/formio.utils.js +1 -1
  8. package/dist/formio.utils.min.js +1 -1
  9. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
  10. package/lib/cjs/components/datagrid/DataGrid.js +0 -3
  11. package/lib/cjs/components/day/fixtures/comp8.d.ts +41 -0
  12. package/lib/cjs/components/day/fixtures/comp8.js +40 -0
  13. package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
  14. package/lib/cjs/components/day/fixtures/index.js +3 -1
  15. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  16. package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
  17. package/lib/cjs/translations/en.d.ts +3 -0
  18. package/lib/cjs/translations/en.js +4 -1
  19. package/lib/cjs/utils/utils.js +0 -4
  20. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
  21. package/lib/mjs/components/datagrid/DataGrid.js +0 -3
  22. package/lib/mjs/components/day/fixtures/comp8.d.ts +41 -0
  23. package/lib/mjs/components/day/fixtures/comp8.js +38 -0
  24. package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
  25. package/lib/mjs/components/day/fixtures/index.js +2 -1
  26. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  27. package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
  28. package/lib/mjs/translations/en.d.ts +3 -0
  29. package/lib/mjs/translations/en.js +4 -1
  30. package/lib/mjs/utils/utils.js +0 -4
  31. package/package.json +1 -2
@@ -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 */
@@ -351,9 +351,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
351
351
  dataValue.splice(newPosition, 0, draggedRowData);
352
352
  //remove element from old position (if was moved above, after insertion it's at +1 index)
353
353
  dataValue.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
354
- // When components are reordered we need to set the dataGrid and form pristine properties to false
355
- this.root.pristine = false;
356
- this.pristine = false;
357
354
  //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
358
355
  this.setValue(dataValue, { isReordered: true });
359
356
  this.rebuild();
@@ -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
  };
@@ -34,7 +34,6 @@ exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.unique
34
34
  exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
35
35
  const lodash_1 = __importDefault(require("lodash"));
36
36
  exports._ = lodash_1.default;
37
- const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
38
37
  const json_logic_js_1 = __importDefault(require("json-logic-js"));
39
38
  exports.jsonLogic = json_logic_js_1.default;
40
39
  const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
@@ -48,9 +47,6 @@ const conditionOperators_1 = __importDefault(require("./conditionOperators"));
48
47
  exports.ConditionOperators = conditionOperators_1.default;
49
48
  const interpolate = Evaluator_1.Evaluator.interpolate;
50
49
  exports.interpolate = interpolate;
51
- const { fetch } = (0, fetch_ponyfill_1.default)({
52
- Promise: Promise
53
- });
54
50
  __exportStar(require("./formUtils"), exports);
55
51
  // Configure JsonLogic
56
52
  operators_1.lodashOperators.forEach((name) => json_logic_js_1.default.add_operation(`_${name}`, lodash_1.default[name]));
@@ -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 */
@@ -348,9 +348,6 @@ export default class DataGridComponent extends NestedArrayComponent {
348
348
  dataValue.splice(newPosition, 0, draggedRowData);
349
349
  //remove element from old position (if was moved above, after insertion it's at +1 index)
350
350
  dataValue.splice(movedBelow ? oldPosition : oldPosition + 1, 1);
351
- // When components are reordered we need to set the dataGrid and form pristine properties to false
352
- this.root.pristine = false;
353
- this.pristine = false;
354
351
  //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
355
352
  this.setValue(dataValue, { isReordered: true });
356
353
  this.rebuild();
@@ -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
  };
@@ -1,6 +1,5 @@
1
1
  /* global jQuery */
2
2
  import _ from 'lodash';
3
- import fetchPonyfill from 'fetch-ponyfill';
4
3
  import jsonLogic from 'json-logic-js';
5
4
  import moment from 'moment-timezone/moment-timezone';
6
5
  import jtz from 'jstimezonedetect';
@@ -10,9 +9,6 @@ import { getValue } from './formUtils';
10
9
  import { Evaluator } from './Evaluator';
11
10
  import ConditionOperators from './conditionOperators';
12
11
  const interpolate = Evaluator.interpolate;
13
- const { fetch } = fetchPonyfill({
14
- Promise: Promise
15
- });
16
12
  export * from './formUtils';
17
13
  // Configure JsonLogic
18
14
  lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5684.206e5cd",
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": {
@@ -99,7 +99,6 @@
99
99
  "eventemitter3": "^5.0.1",
100
100
  "fast-deep-equal": "^3.1.3",
101
101
  "fast-json-patch": "^3.1.1",
102
- "fetch-ponyfill": "^7.1.0",
103
102
  "idb": "^7.1.1",
104
103
  "inputmask": "^5.0.8",
105
104
  "ismobilejs": "^1.1.1",