@formio/js 5.0.0 → 5.0.1-rc.2
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.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +17 -17
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +17 -17
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +6 -6
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +5 -5
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/components/day/Day.js +2 -18
- package/lib/cjs/components/form/Form.js +3 -2
- package/lib/cjs/components/number/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/number/fixtures/index.js +2 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/cjs/formio.embed.d.ts +1 -1
- package/lib/cjs/formio.embed.js +3 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
- package/lib/cjs/translations/en.js +2 -2
- package/lib/mjs/components/day/Day.js +2 -18
- package/lib/mjs/components/form/Form.js +3 -2
- package/lib/mjs/components/number/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/number/fixtures/index.js +1 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/mjs/formio.embed.d.ts +1 -1
- package/lib/mjs/formio.embed.js +1 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
- package/lib/mjs/translations/en.js +2 -2
- package/package.json +4 -4
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
/*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
|
22
22
|
|
23
|
-
/*! formiojs v5.0.
|
23
|
+
/*! formiojs v5.0.1-rc.2 | https://unpkg.com/formiojs@5.0.1-rc.2/LICENSE.txt */
|
24
24
|
|
25
25
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
26
26
|
|
@@ -7,6 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
8
8
|
const Field_1 = __importDefault(require("../_classes/field/Field"));
|
9
9
|
const utils_1 = require("../../utils/utils");
|
10
|
+
const core_1 = require("@formio/core");
|
10
11
|
class DayComponent extends Field_1.default {
|
11
12
|
static schema(...extend) {
|
12
13
|
return Field_1.default.schema({
|
@@ -474,24 +475,7 @@ class DayComponent extends Field_1.default {
|
|
474
475
|
* @returns {string} - the format for the value string.
|
475
476
|
*/
|
476
477
|
get format() {
|
477
|
-
|
478
|
-
if (this.component.dayFirst && this.showDay) {
|
479
|
-
format += 'D/';
|
480
|
-
}
|
481
|
-
if (this.showMonth) {
|
482
|
-
format += 'M/';
|
483
|
-
}
|
484
|
-
if (!this.component.dayFirst && this.showDay) {
|
485
|
-
format += 'D/';
|
486
|
-
}
|
487
|
-
if (this.showYear) {
|
488
|
-
format += 'YYYY';
|
489
|
-
return format;
|
490
|
-
}
|
491
|
-
else {
|
492
|
-
// Trim off the "/" from the end of the format string.
|
493
|
-
return format.length ? format.substring(0, format.length - 1) : format;
|
494
|
-
}
|
478
|
+
return (0, core_1.getDayFormat)(this.component);
|
495
479
|
}
|
496
480
|
/**
|
497
481
|
* Return the date for this component.
|
@@ -148,6 +148,9 @@ class FormComponent extends Component_1.default {
|
|
148
148
|
options.events = this.createEmitter();
|
149
149
|
// Make sure to not show the submit button in wizards in the nested forms.
|
150
150
|
lodash_1.default.set(options, 'buttonSettings.showSubmit', false);
|
151
|
+
// Set the parent options to the subform so those references are stable when the subform is created
|
152
|
+
options.parent = this;
|
153
|
+
options.parentVisible = this.visible;
|
151
154
|
if (!this.options) {
|
152
155
|
return options;
|
153
156
|
}
|
@@ -395,8 +398,6 @@ class FormComponent extends Component_1.default {
|
|
395
398
|
return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
|
396
399
|
this.subForm = instance;
|
397
400
|
this.subForm.currentForm = this;
|
398
|
-
this.subForm.parent = this;
|
399
|
-
this.subForm.parentVisible = this.visible;
|
400
401
|
this.subForm.on('change', () => {
|
401
402
|
if (this.subForm) {
|
402
403
|
this.dataValue = this.subForm.getValue();
|
@@ -9,4 +9,5 @@ import comp8 from './comp8';
|
|
9
9
|
import comp9 from './comp9';
|
10
10
|
import comp10 from './comp10';
|
11
11
|
import comp11 from './comp11';
|
12
|
-
|
12
|
+
import scientificNotation from './scientificNotation';
|
13
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, scientificNotation };
|
@@ -26,3 +26,5 @@ const comp10_1 = __importDefault(require("./comp10"));
|
|
26
26
|
exports.comp10 = comp10_1.default;
|
27
27
|
const comp11_1 = __importDefault(require("./comp11"));
|
28
28
|
exports.comp11 = comp11_1.default;
|
29
|
+
const scientificNotation_1 = __importDefault(require("./scientificNotation"));
|
30
|
+
exports.scientificNotation = scientificNotation_1.default;
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export { Formio } from "./InlineEmbed";
|
package/lib/cjs/formio.embed.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Formio = void 0;
|
3
4
|
const InlineEmbed_1 = require("./InlineEmbed");
|
4
5
|
(0, InlineEmbed_1.embed)();
|
6
|
+
var InlineEmbed_2 = require("./InlineEmbed");
|
7
|
+
Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return InlineEmbed_2.Formio; } });
|
@@ -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;
|
@@ -26,8 +26,8 @@ exports.default = {
|
|
26
26
|
maxWords: '{{field}} must have no more than {{length}} words.',
|
27
27
|
min: '{{field}} cannot be less than {{min}}.',
|
28
28
|
max: '{{field}} cannot be greater than {{max}}.',
|
29
|
-
maxDate: '{{field}} should not contain date after {{
|
30
|
-
minDate: '{{field}} should not contain date before {{
|
29
|
+
maxDate: '{{field}} should not contain date after {{maxDate}}',
|
30
|
+
minDate: '{{field}} should not contain date before {{minDate}}',
|
31
31
|
maxYear: '{{field}} should not contain year greater than {{maxYear}}',
|
32
32
|
minYear: '{{field}} should not contain year less than {{minYear}}',
|
33
33
|
minSelectedCount: 'You must select at least {{minCount}} items',
|
@@ -2,6 +2,7 @@ import _ from 'lodash';
|
|
2
2
|
import moment from 'moment';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
4
|
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
|
5
|
+
import { getDayFormat } from '@formio/core';
|
5
6
|
export default class DayComponent extends Field {
|
6
7
|
static schema(...extend) {
|
7
8
|
return Field.schema({
|
@@ -474,24 +475,7 @@ export default class DayComponent extends Field {
|
|
474
475
|
* @returns {string} - the format for the value string.
|
475
476
|
*/
|
476
477
|
get format() {
|
477
|
-
|
478
|
-
if (this.component.dayFirst && this.showDay) {
|
479
|
-
format += 'D/';
|
480
|
-
}
|
481
|
-
if (this.showMonth) {
|
482
|
-
format += 'M/';
|
483
|
-
}
|
484
|
-
if (!this.component.dayFirst && this.showDay) {
|
485
|
-
format += 'D/';
|
486
|
-
}
|
487
|
-
if (this.showYear) {
|
488
|
-
format += 'YYYY';
|
489
|
-
return format;
|
490
|
-
}
|
491
|
-
else {
|
492
|
-
// Trim off the "/" from the end of the format string.
|
493
|
-
return format.length ? format.substring(0, format.length - 1) : format;
|
494
|
-
}
|
478
|
+
return getDayFormat(this.component);
|
495
479
|
}
|
496
480
|
/**
|
497
481
|
* Return the date for this component.
|
@@ -142,6 +142,9 @@ export default class FormComponent extends Component {
|
|
142
142
|
options.events = this.createEmitter();
|
143
143
|
// Make sure to not show the submit button in wizards in the nested forms.
|
144
144
|
_.set(options, 'buttonSettings.showSubmit', false);
|
145
|
+
// Set the parent options to the subform so those references are stable when the subform is created
|
146
|
+
options.parent = this;
|
147
|
+
options.parentVisible = this.visible;
|
145
148
|
if (!this.options) {
|
146
149
|
return options;
|
147
150
|
}
|
@@ -391,8 +394,6 @@ export default class FormComponent extends Component {
|
|
391
394
|
return (new Form(form, this.getSubOptions())).ready.then((instance) => {
|
392
395
|
this.subForm = instance;
|
393
396
|
this.subForm.currentForm = this;
|
394
|
-
this.subForm.parent = this;
|
395
|
-
this.subForm.parentVisible = this.visible;
|
396
397
|
this.subForm.on('change', () => {
|
397
398
|
if (this.subForm) {
|
398
399
|
this.dataValue = this.subForm.getValue();
|
@@ -9,4 +9,5 @@ import comp8 from './comp8';
|
|
9
9
|
import comp9 from './comp9';
|
10
10
|
import comp10 from './comp10';
|
11
11
|
import comp11 from './comp11';
|
12
|
-
|
12
|
+
import scientificNotation from './scientificNotation';
|
13
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, scientificNotation };
|
@@ -9,4 +9,5 @@ import comp8 from './comp8';
|
|
9
9
|
import comp9 from './comp9';
|
10
10
|
import comp10 from './comp10';
|
11
11
|
import comp11 from './comp11';
|
12
|
+
import scientificNotation from './scientificNotation';
|
12
13
|
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, scientificNotation };
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export { Formio } from "./InlineEmbed";
|
package/lib/mjs/formio.embed.js
CHANGED
@@ -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
|
}
|
@@ -24,8 +24,8 @@ export default {
|
|
24
24
|
maxWords: '{{field}} must have no more than {{length}} words.',
|
25
25
|
min: '{{field}} cannot be less than {{min}}.',
|
26
26
|
max: '{{field}} cannot be greater than {{max}}.',
|
27
|
-
maxDate: '{{field}} should not contain date after {{
|
28
|
-
minDate: '{{field}} should not contain date before {{
|
27
|
+
maxDate: '{{field}} should not contain date after {{maxDate}}',
|
28
|
+
minDate: '{{field}} should not contain date before {{minDate}}',
|
29
29
|
maxYear: '{{field}} should not contain year greater than {{maxYear}}',
|
30
30
|
minYear: '{{field}} should not contain year less than {{minYear}}',
|
31
31
|
minSelectedCount: 'You must select at least {{minCount}} items',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.0.
|
3
|
+
"version": "5.0.1-rc.2",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -79,10 +79,10 @@
|
|
79
79
|
},
|
80
80
|
"homepage": "https://github.com/formio/formio.js#readme",
|
81
81
|
"dependencies": {
|
82
|
-
"@formio/bootstrap": "3.0.
|
82
|
+
"@formio/bootstrap": "3.0.1-rc.1",
|
83
83
|
"@formio/choices.js": "^10.2.1",
|
84
|
-
"@formio/core": "2.3.
|
85
|
-
"@formio/text-mask-addons": "
|
84
|
+
"@formio/core": "2.3.2-rc.1",
|
85
|
+
"@formio/text-mask-addons": "3.8.0-formio.4",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|
88
88
|
"autocompleter": "^8.0.4",
|