@formio/js 5.0.0-dev.5680.d459cf5 → 5.0.0-dev.5683.61b6c22
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.
- package/dist/formio.form.js +99 -3
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +3 -3
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/lib/cjs/Webform.js +2 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.js +44 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
- package/lib/cjs/components/editgrid/EditGrid.js +2 -2
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
- package/lib/mjs/Webform.js +2 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.js +42 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
- package/lib/mjs/components/editgrid/EditGrid.js +2 -2
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
- package/package.json +1 -1
package/lib/cjs/Webform.js
CHANGED
|
@@ -13,6 +13,7 @@ const Components_1 = __importDefault(require("./components/Components"));
|
|
|
13
13
|
const NestedDataComponent_1 = __importDefault(require("./components/_classes/nesteddata/NestedDataComponent"));
|
|
14
14
|
const utils_1 = require("./utils/utils");
|
|
15
15
|
const formUtils_1 = require("./utils/formUtils");
|
|
16
|
+
const dragula_1 = __importDefault(require("dragula"));
|
|
16
17
|
// Initialize the available forms.
|
|
17
18
|
Formio_1.Formio.forms = {};
|
|
18
19
|
// Allow people to register components.
|
|
@@ -309,6 +310,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
309
310
|
// Ensure the root is set to this component.
|
|
310
311
|
this.root = this;
|
|
311
312
|
this.localRoot = this;
|
|
313
|
+
this.root.dragulaLib = dragula_1.default;
|
|
312
314
|
}
|
|
313
315
|
/* eslint-enable max-statements */
|
|
314
316
|
get language() {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let components: {
|
|
3
|
+
label: string;
|
|
4
|
+
reorder: boolean;
|
|
5
|
+
addAnotherPosition: string;
|
|
6
|
+
layoutFixed: boolean;
|
|
7
|
+
enableRowGroups: boolean;
|
|
8
|
+
initEmpty: boolean;
|
|
9
|
+
tableView: boolean;
|
|
10
|
+
defaultValue: {}[];
|
|
11
|
+
key: string;
|
|
12
|
+
type: string;
|
|
13
|
+
input: boolean;
|
|
14
|
+
components: ({
|
|
15
|
+
label: string;
|
|
16
|
+
applyMaskOn: string;
|
|
17
|
+
tableView: boolean;
|
|
18
|
+
key: string;
|
|
19
|
+
type: string;
|
|
20
|
+
input: boolean;
|
|
21
|
+
mask?: undefined;
|
|
22
|
+
delimiter?: undefined;
|
|
23
|
+
requireDecimal?: undefined;
|
|
24
|
+
inputFormat?: undefined;
|
|
25
|
+
truncateMultipleSpaces?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
label: string;
|
|
28
|
+
applyMaskOn: string;
|
|
29
|
+
mask: boolean;
|
|
30
|
+
tableView: boolean;
|
|
31
|
+
delimiter: boolean;
|
|
32
|
+
requireDecimal: boolean;
|
|
33
|
+
inputFormat: string;
|
|
34
|
+
truncateMultipleSpaces: boolean;
|
|
35
|
+
key: string;
|
|
36
|
+
type: string;
|
|
37
|
+
input: boolean;
|
|
38
|
+
})[];
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
"components": [
|
|
5
|
+
{
|
|
6
|
+
"label": "Data Grid",
|
|
7
|
+
"reorder": true,
|
|
8
|
+
"addAnotherPosition": "bottom",
|
|
9
|
+
"layoutFixed": false,
|
|
10
|
+
"enableRowGroups": false,
|
|
11
|
+
"initEmpty": false,
|
|
12
|
+
"tableView": false,
|
|
13
|
+
"defaultValue": [
|
|
14
|
+
{}
|
|
15
|
+
],
|
|
16
|
+
"key": "dataGrid",
|
|
17
|
+
"type": "datagrid",
|
|
18
|
+
"input": true,
|
|
19
|
+
"components": [
|
|
20
|
+
{
|
|
21
|
+
"label": "Text Field",
|
|
22
|
+
"applyMaskOn": "change",
|
|
23
|
+
"tableView": true,
|
|
24
|
+
"key": "textField",
|
|
25
|
+
"type": "textfield",
|
|
26
|
+
"input": true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "Number",
|
|
30
|
+
"applyMaskOn": "change",
|
|
31
|
+
"mask": false,
|
|
32
|
+
"tableView": false,
|
|
33
|
+
"delimiter": false,
|
|
34
|
+
"requireDecimal": false,
|
|
35
|
+
"inputFormat": "plain",
|
|
36
|
+
"truncateMultipleSpaces": false,
|
|
37
|
+
"key": "number",
|
|
38
|
+
"type": "number",
|
|
39
|
+
"input": true
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
};
|
|
@@ -6,6 +6,7 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
+
import comp9 from './comp9';
|
|
9
10
|
import withCollapsibleRowGroups from './comp-with-collapsible-groups';
|
|
10
11
|
import withConditionalFieldsAndValidations from './comp-with-conditional-components-and-validations';
|
|
11
12
|
import withDefValue from './comp-with-def-value';
|
|
@@ -15,4 +16,4 @@ import modalWithRequiredFields from './comp-modal-with-required-fields';
|
|
|
15
16
|
import withAllowCalculateOverride from './comp-with-allow-calculate-override';
|
|
16
17
|
import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
|
|
17
18
|
import withCheckboxes from './comp-with-checkboxes';
|
|
18
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
19
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
@@ -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.withCheckboxes = exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
|
6
|
+
exports.withCheckboxes = exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp9 = 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"));
|
|
@@ -20,6 +20,8 @@ const comp7_1 = __importDefault(require("./comp7"));
|
|
|
20
20
|
exports.comp7 = comp7_1.default;
|
|
21
21
|
const comp8_1 = __importDefault(require("./comp8"));
|
|
22
22
|
exports.comp8 = comp8_1.default;
|
|
23
|
+
const comp9_1 = __importDefault(require("./comp9"));
|
|
24
|
+
exports.comp9 = comp9_1.default;
|
|
23
25
|
const comp_with_def_value_1 = __importDefault(require("./comp-with-def-value"));
|
|
24
26
|
exports.withDefValue = comp_with_def_value_1.default;
|
|
25
27
|
const comp_row_groups_with_def_value_1 = __importDefault(require("./comp-row-groups-with-def-value"));
|
|
@@ -88,7 +88,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
88
88
|
{% if (!instance.options.readOnly && !instance.disabled) { %}
|
|
89
89
|
<div class="col-sm-2">
|
|
90
90
|
<div class="btn-group pull-right">
|
|
91
|
-
<button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('
|
|
91
|
+
<button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('pen-fill') }}"></i></button>
|
|
92
92
|
{% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
|
|
93
93
|
<button class="btn btn-danger btn-sm removeRow"><i class="{{ iconClass('trash') }}"></i></button>
|
|
94
94
|
{% } %}
|
|
@@ -109,7 +109,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
109
109
|
{% if (!instance.options.readOnly && !instance.disabled) { %}
|
|
110
110
|
<td class="editgrid-table-column">
|
|
111
111
|
<div class="btn-group">
|
|
112
|
-
<button class="btn btn-default btn-light btn-sm editRow" aria-label="{{ t('Edit row') }}"><i class="{{ iconClass('
|
|
112
|
+
<button class="btn btn-default btn-light btn-sm editRow" aria-label="{{ t('Edit row') }}"><i class="{{ iconClass('pen-fill') }}"></i></button>
|
|
113
113
|
{% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
|
|
114
114
|
<button class="btn btn-danger btn-sm removeRow" aria-label="{{ t('Remove row') }}"><i class="{{ iconClass('trash') }}"></i></button>
|
|
115
115
|
{% } %}
|
|
@@ -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 =
|
|
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;
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -8,6 +8,7 @@ import Components from "./components/Components";
|
|
|
8
8
|
import NestedDataComponent from "./components/_classes/nesteddata/NestedDataComponent";
|
|
9
9
|
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from "./utils/utils";
|
|
10
10
|
import { eachComponent } from "./utils/formUtils";
|
|
11
|
+
import dragula from "dragula";
|
|
11
12
|
// Initialize the available forms.
|
|
12
13
|
Formio.forms = {};
|
|
13
14
|
// Allow people to register components.
|
|
@@ -281,6 +282,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
281
282
|
// Ensure the root is set to this component.
|
|
282
283
|
this.root = this;
|
|
283
284
|
this.localRoot = this;
|
|
285
|
+
this.root.dragulaLib = dragula;
|
|
284
286
|
}
|
|
285
287
|
/* eslint-enable max-statements */
|
|
286
288
|
get language() {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let components: {
|
|
3
|
+
label: string;
|
|
4
|
+
reorder: boolean;
|
|
5
|
+
addAnotherPosition: string;
|
|
6
|
+
layoutFixed: boolean;
|
|
7
|
+
enableRowGroups: boolean;
|
|
8
|
+
initEmpty: boolean;
|
|
9
|
+
tableView: boolean;
|
|
10
|
+
defaultValue: {}[];
|
|
11
|
+
key: string;
|
|
12
|
+
type: string;
|
|
13
|
+
input: boolean;
|
|
14
|
+
components: ({
|
|
15
|
+
label: string;
|
|
16
|
+
applyMaskOn: string;
|
|
17
|
+
tableView: boolean;
|
|
18
|
+
key: string;
|
|
19
|
+
type: string;
|
|
20
|
+
input: boolean;
|
|
21
|
+
mask?: undefined;
|
|
22
|
+
delimiter?: undefined;
|
|
23
|
+
requireDecimal?: undefined;
|
|
24
|
+
inputFormat?: undefined;
|
|
25
|
+
truncateMultipleSpaces?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
label: string;
|
|
28
|
+
applyMaskOn: string;
|
|
29
|
+
mask: boolean;
|
|
30
|
+
tableView: boolean;
|
|
31
|
+
delimiter: boolean;
|
|
32
|
+
requireDecimal: boolean;
|
|
33
|
+
inputFormat: string;
|
|
34
|
+
truncateMultipleSpaces: boolean;
|
|
35
|
+
key: string;
|
|
36
|
+
type: string;
|
|
37
|
+
input: boolean;
|
|
38
|
+
})[];
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"components": [
|
|
3
|
+
{
|
|
4
|
+
"label": "Data Grid",
|
|
5
|
+
"reorder": true,
|
|
6
|
+
"addAnotherPosition": "bottom",
|
|
7
|
+
"layoutFixed": false,
|
|
8
|
+
"enableRowGroups": false,
|
|
9
|
+
"initEmpty": false,
|
|
10
|
+
"tableView": false,
|
|
11
|
+
"defaultValue": [
|
|
12
|
+
{}
|
|
13
|
+
],
|
|
14
|
+
"key": "dataGrid",
|
|
15
|
+
"type": "datagrid",
|
|
16
|
+
"input": true,
|
|
17
|
+
"components": [
|
|
18
|
+
{
|
|
19
|
+
"label": "Text Field",
|
|
20
|
+
"applyMaskOn": "change",
|
|
21
|
+
"tableView": true,
|
|
22
|
+
"key": "textField",
|
|
23
|
+
"type": "textfield",
|
|
24
|
+
"input": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"label": "Number",
|
|
28
|
+
"applyMaskOn": "change",
|
|
29
|
+
"mask": false,
|
|
30
|
+
"tableView": false,
|
|
31
|
+
"delimiter": false,
|
|
32
|
+
"requireDecimal": false,
|
|
33
|
+
"inputFormat": "plain",
|
|
34
|
+
"truncateMultipleSpaces": false,
|
|
35
|
+
"key": "number",
|
|
36
|
+
"type": "number",
|
|
37
|
+
"input": true
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
};
|
|
@@ -6,6 +6,7 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
+
import comp9 from './comp9';
|
|
9
10
|
import withCollapsibleRowGroups from './comp-with-collapsible-groups';
|
|
10
11
|
import withConditionalFieldsAndValidations from './comp-with-conditional-components-and-validations';
|
|
11
12
|
import withDefValue from './comp-with-def-value';
|
|
@@ -15,4 +16,4 @@ import modalWithRequiredFields from './comp-modal-with-required-fields';
|
|
|
15
16
|
import withAllowCalculateOverride from './comp-with-allow-calculate-override';
|
|
16
17
|
import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
|
|
17
18
|
import withCheckboxes from './comp-with-checkboxes';
|
|
18
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
19
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
@@ -6,6 +6,7 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
+
import comp9 from './comp9';
|
|
9
10
|
import withDefValue from './comp-with-def-value';
|
|
10
11
|
import withRowGroupsAndDefValue from './comp-row-groups-with-def-value';
|
|
11
12
|
import modalWithRequiredFields from './comp-modal-with-required-fields';
|
|
@@ -15,4 +16,4 @@ import withCollapsibleRowGroups from './comp-with-collapsible-groups';
|
|
|
15
16
|
import withAllowCalculateOverride from './comp-with-allow-calculate-override';
|
|
16
17
|
import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
|
|
17
18
|
import withCheckboxes from './comp-with-checkboxes';
|
|
18
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
19
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
|
|
@@ -83,7 +83,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
83
83
|
{% if (!instance.options.readOnly && !instance.disabled) { %}
|
|
84
84
|
<div class="col-sm-2">
|
|
85
85
|
<div class="btn-group pull-right">
|
|
86
|
-
<button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('
|
|
86
|
+
<button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('pen-fill') }}"></i></button>
|
|
87
87
|
{% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
|
|
88
88
|
<button class="btn btn-danger btn-sm removeRow"><i class="{{ iconClass('trash') }}"></i></button>
|
|
89
89
|
{% } %}
|
|
@@ -104,7 +104,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
104
104
|
{% if (!instance.options.readOnly && !instance.disabled) { %}
|
|
105
105
|
<td class="editgrid-table-column">
|
|
106
106
|
<div class="btn-group">
|
|
107
|
-
<button class="btn btn-default btn-light btn-sm editRow" aria-label="{{ t('Edit row') }}"><i class="{{ iconClass('
|
|
107
|
+
<button class="btn btn-default btn-light btn-sm editRow" aria-label="{{ t('Edit row') }}"><i class="{{ iconClass('pen-fill') }}"></i></button>
|
|
108
108
|
{% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
|
|
109
109
|
<button class="btn btn-danger btn-sm removeRow" aria-label="{{ t('Remove row') }}"><i class="{{ iconClass('trash') }}"></i></button>
|
|
110
110
|
{% } %}
|
|
@@ -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 =
|
|
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
|
}
|