@formio/js 5.0.0-rc.57 → 5.0.0-rc.59
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/formio.builder.css +0 -4
- package/dist/formio.builder.min.css +1 -1
- 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.css +0 -4
- package/dist/formio.form.js +27 -38
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +11 -3
- package/dist/formio.full.css +0 -4
- package/dist/formio.full.js +31 -42
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +11 -3
- package/dist/formio.js +4 -4
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +15 -36
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -4
- package/lib/cjs/CDN.d.ts +1 -0
- package/lib/cjs/CDN.js +6 -3
- package/lib/cjs/Embed.d.ts +1 -1
- package/lib/cjs/Embed.js +41 -7
- package/lib/cjs/Formio.js +11 -0
- package/lib/cjs/InlineEmbed.js +3 -1
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +11 -9
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +12 -17
- package/lib/cjs/components/_classes/component/Component.js +2 -2
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/button/Button.js +7 -7
- package/lib/cjs/components/radio/Radio.d.ts +1 -1
- package/lib/cjs/components/radio/Radio.js +5 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -8
- package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +2 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +3 -2
- package/lib/cjs/components/recaptcha/ReCaptcha.js +1 -8
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +33 -2
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +13 -2
- package/lib/cjs/components/select/Select.js +6 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +16 -2
- package/lib/cjs/components/select/fixtures/comp22.js +1 -1
- package/lib/cjs/components/select/fixtures/comp23.d.ts +58 -0
- package/lib/cjs/components/select/fixtures/comp23.js +49 -0
- package/lib/cjs/components/select/fixtures/comp24.d.ts +47 -0
- package/lib/cjs/components/select/fixtures/comp24.js +40 -0
- package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/select/fixtures/index.js +5 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +4 -1
- package/lib/cjs/translations/en.d.ts +1 -0
- package/lib/cjs/translations/en.js +1 -0
- package/lib/cjs/utils/utils.d.ts +6 -0
- package/lib/cjs/utils/utils.js +16 -2
- package/lib/mjs/CDN.d.ts +1 -0
- package/lib/mjs/CDN.js +6 -3
- package/lib/mjs/Embed.d.ts +1 -1
- package/lib/mjs/Embed.js +41 -7
- package/lib/mjs/Formio.js +11 -0
- package/lib/mjs/InlineEmbed.js +3 -1
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +12 -10
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +12 -16
- package/lib/mjs/components/_classes/component/Component.js +3 -3
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/button/Button.js +7 -7
- package/lib/mjs/components/radio/Radio.d.ts +1 -1
- package/lib/mjs/components/radio/Radio.js +5 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -8
- package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +2 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +3 -2
- package/lib/mjs/components/recaptcha/ReCaptcha.js +1 -8
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +33 -2
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +13 -2
- package/lib/mjs/components/select/Select.js +6 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +16 -2
- package/lib/mjs/components/select/fixtures/comp22.js +1 -1
- package/lib/mjs/components/select/fixtures/comp23.d.ts +58 -0
- package/lib/mjs/components/select/fixtures/comp23.js +47 -0
- package/lib/mjs/components/select/fixtures/comp24.d.ts +47 -0
- package/lib/mjs/components/select/fixtures/comp24.js +38 -0
- package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/select/fixtures/index.js +3 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -1
- package/lib/mjs/translations/en.d.ts +1 -0
- package/lib/mjs/translations/en.js +1 -0
- package/lib/mjs/utils/utils.d.ts +6 -0
- package/lib/mjs/utils/utils.js +13 -0
- package/package.json +4 -4
@@ -18,11 +18,9 @@
|
|
18
18
|
* MIT licensed
|
19
19
|
*/
|
20
20
|
|
21
|
-
/*! @license DOMPurify 3.1.
|
21
|
+
/*! @license DOMPurify 3.1.5 | (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.5/LICENSE */
|
22
22
|
|
23
|
-
/*!
|
24
|
-
|
25
|
-
/*! formiojs v5.0.0-rc.57 | https://unpkg.com/formiojs@5.0.0-rc.57/LICENSE.txt */
|
23
|
+
/*! formiojs v5.0.0-rc.59 | https://unpkg.com/formiojs@5.0.0-rc.59/LICENSE.txt */
|
26
24
|
|
27
25
|
/**
|
28
26
|
* @license
|
package/lib/cjs/CDN.d.ts
CHANGED
package/lib/cjs/CDN.js
CHANGED
@@ -11,9 +11,10 @@ class CDN {
|
|
11
11
|
this.libs = {
|
12
12
|
'js': '',
|
13
13
|
'ace': '1.4.12',
|
14
|
-
'bootstrap': '5.3.
|
14
|
+
'bootstrap': '5.3.3',
|
15
15
|
'bootstrap4': '4.6.2',
|
16
|
-
'bootstrap5': '5.3.
|
16
|
+
'bootstrap5': '5.3.3',
|
17
|
+
'bootswatch': '5.3.3',
|
17
18
|
'bootstrap-icons': '1.11.1',
|
18
19
|
'ckeditor': '19.0.0',
|
19
20
|
'flatpickr': '4.6.8',
|
@@ -61,7 +62,9 @@ class CDN {
|
|
61
62
|
if (lib) {
|
62
63
|
url += `/${lib}`;
|
63
64
|
}
|
64
|
-
|
65
|
+
// Only attach the version if this is the hosted cdn.
|
66
|
+
if (cdnUrl.includes('form.io') &&
|
67
|
+
version && version !== 'latest') {
|
65
68
|
url += `/${version}`;
|
66
69
|
}
|
67
70
|
return url;
|
package/lib/cjs/Embed.d.ts
CHANGED
@@ -26,7 +26,7 @@ export class Formio {
|
|
26
26
|
static addStyles(wrapper: any, href: any): Promise<void>;
|
27
27
|
static submitDone(instance: any, submission: any): Promise<void>;
|
28
28
|
static formioScript(script: any, builder: any): any;
|
29
|
-
static addLibrary(
|
29
|
+
static addLibrary(libWrapper: any, lib: any, name: any): Promise<void>;
|
30
30
|
static addLoader(wrapper: any): Promise<void>;
|
31
31
|
static init(element: any, options?: {}, builder?: boolean): Promise<any>;
|
32
32
|
static afterCreate(instance: any, wrapper: any, readyEvent: any): Promise<any>;
|
package/lib/cjs/Embed.js
CHANGED
@@ -80,6 +80,9 @@ class Formio {
|
|
80
80
|
}
|
81
81
|
static createElement(type, attrs, children) {
|
82
82
|
const element = document.createElement(type);
|
83
|
+
if (!attrs) {
|
84
|
+
return element;
|
85
|
+
}
|
83
86
|
Object.keys(attrs).forEach(key => {
|
84
87
|
element.setAttribute(key, attrs[key]);
|
85
88
|
});
|
@@ -187,21 +190,22 @@ class Formio {
|
|
187
190
|
}
|
188
191
|
return script;
|
189
192
|
}
|
190
|
-
static addLibrary(
|
193
|
+
static addLibrary(libWrapper, lib, name) {
|
191
194
|
return __awaiter(this, void 0, void 0, function* () {
|
192
195
|
if (!lib) {
|
193
196
|
return;
|
194
197
|
}
|
195
198
|
if (lib.dependencies) {
|
196
199
|
for (let i = 0; i < lib.dependencies.length; i++) {
|
197
|
-
|
200
|
+
const libName = lib.dependencies[i];
|
201
|
+
yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);
|
198
202
|
}
|
199
203
|
}
|
200
204
|
if (lib.css) {
|
201
|
-
yield _a.addStyles(
|
205
|
+
yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);
|
202
206
|
}
|
203
207
|
if (lib.js) {
|
204
|
-
const module = yield _a.addScript(
|
208
|
+
const module = yield _a.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);
|
205
209
|
if (lib.use) {
|
206
210
|
_a.debug(`Using ${name}`);
|
207
211
|
const options = lib.options || {};
|
@@ -211,6 +215,12 @@ class Formio {
|
|
211
215
|
_a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);
|
212
216
|
}
|
213
217
|
}
|
218
|
+
if (lib.globalStyle) {
|
219
|
+
const style = _a.createElement('style');
|
220
|
+
style.type = 'text/css';
|
221
|
+
style.innerHTML = lib.globalStyle;
|
222
|
+
document.body.appendChild(style);
|
223
|
+
}
|
214
224
|
});
|
215
225
|
}
|
216
226
|
static addLoader(wrapper) {
|
@@ -243,7 +253,16 @@ class Formio {
|
|
243
253
|
use: true
|
244
254
|
},
|
245
255
|
fontawesome: {
|
246
|
-
|
256
|
+
// Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need
|
257
|
+
// to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.
|
258
|
+
css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,
|
259
|
+
globalStyle: `@font-face {
|
260
|
+
font-family: 'FontAwesome';
|
261
|
+
src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');
|
262
|
+
src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
|
263
|
+
font-weight: normal;
|
264
|
+
font-style: normal;
|
265
|
+
}`
|
247
266
|
},
|
248
267
|
bootstrap4: {
|
249
268
|
dependencies: ['fontawesome'],
|
@@ -254,9 +273,24 @@ class Formio {
|
|
254
273
|
css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`
|
255
274
|
},
|
256
275
|
'bootstrap-icons': {
|
257
|
-
|
276
|
+
// Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need
|
277
|
+
// to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.
|
278
|
+
css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',
|
279
|
+
globalStyle: `@font-face {
|
280
|
+
font-display: block;
|
281
|
+
font-family: "bootstrap-icons";
|
282
|
+
src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),
|
283
|
+
url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");
|
284
|
+
}`
|
258
285
|
}
|
259
286
|
};
|
287
|
+
// Add all bootswatch templates.
|
288
|
+
['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {
|
289
|
+
_a.config.libs[template] = {
|
290
|
+
dependencies: ['bootstrap-icons'],
|
291
|
+
css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`
|
292
|
+
};
|
293
|
+
});
|
260
294
|
const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;
|
261
295
|
// Create a new wrapper and add the element inside of a new wrapper.
|
262
296
|
let wrapper = _a.createElement('div', {
|
@@ -264,7 +298,7 @@ class Formio {
|
|
264
298
|
});
|
265
299
|
element.parentNode.insertBefore(wrapper, element);
|
266
300
|
// If we include the libraries, then we will attempt to run this in shadow dom.
|
267
|
-
const useShadowDom = _a.config.includeLibs && (typeof wrapper.attachShadow === 'function');
|
301
|
+
const useShadowDom = _a.config.includeLibs && !_a.config.noshadow && (typeof wrapper.attachShadow === 'function');
|
268
302
|
if (useShadowDom) {
|
269
303
|
wrapper = wrapper.attachShadow({
|
270
304
|
mode: 'open'
|
package/lib/cjs/Formio.js
CHANGED
@@ -114,3 +114,14 @@ sdk_1.Formio.createForm = Embed_1.Formio.createForm;
|
|
114
114
|
sdk_1.Formio.submitDone = Embed_1.Formio.submitDone;
|
115
115
|
sdk_1.Formio.addLibrary = Embed_1.Formio.addLibrary;
|
116
116
|
sdk_1.Formio.addLoader = Embed_1.Formio.addLoader;
|
117
|
+
sdk_1.Formio.addToGlobal = (global) => {
|
118
|
+
if (typeof global === 'object' && !global.Formio) {
|
119
|
+
global.Formio = sdk_1.Formio;
|
120
|
+
}
|
121
|
+
};
|
122
|
+
if (typeof global !== 'undefined') {
|
123
|
+
sdk_1.Formio.addToGlobal(global);
|
124
|
+
}
|
125
|
+
if (typeof window !== 'undefined') {
|
126
|
+
sdk_1.Formio.addToGlobal(window);
|
127
|
+
}
|
package/lib/cjs/InlineEmbed.js
CHANGED
@@ -28,9 +28,10 @@ function embed(config = {}) {
|
|
28
28
|
let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
|
29
29
|
scriptSrc.pop();
|
30
30
|
let cdnSrc = '';
|
31
|
-
if (scriptSrc[scriptSrc.length - 1]
|
31
|
+
if (['js', 'offline'].includes(scriptSrc[scriptSrc.length - 1])) {
|
32
32
|
scriptSrc.pop();
|
33
33
|
scriptSrc = cdnSrc = scriptSrc.join('/');
|
34
|
+
scriptSrc += '/js';
|
34
35
|
}
|
35
36
|
else {
|
36
37
|
scriptSrc = scriptSrc.join('/');
|
@@ -49,6 +50,7 @@ function embed(config = {}) {
|
|
49
50
|
base: query.base || 'https://api.form.io',
|
50
51
|
submit: query.submit,
|
51
52
|
includeLibs: (query.libs === 'true' || query.libs === '1'),
|
53
|
+
noshadow: (query.shadow === 'false' || query.shadow === '0'),
|
52
54
|
template: query.template || 'bootstrap',
|
53
55
|
debug: debug,
|
54
56
|
config: {},
|
package/lib/cjs/Webform.d.ts
CHANGED
@@ -445,7 +445,7 @@ declare class Webform extends NestedDataComponent {
|
|
445
445
|
*/
|
446
446
|
submit(before?: boolean, options?: any): Promise<any>;
|
447
447
|
submitUrl(URL: any, headers: any): void;
|
448
|
-
|
448
|
+
triggerCaptcha(): void;
|
449
449
|
_nosubmit: any;
|
450
450
|
get conditions(): any;
|
451
451
|
get variables(): any;
|
package/lib/cjs/Webform.js
CHANGED
@@ -646,7 +646,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
646
646
|
const rebuild = this.rebuild() || Promise.resolve();
|
647
647
|
return rebuild.then(() => {
|
648
648
|
this.emit("formLoad", form);
|
649
|
-
this.
|
649
|
+
this.triggerCaptcha();
|
650
650
|
// Make sure to trigger onChange after a render event occurs to speed up form rendering.
|
651
651
|
setTimeout(() => {
|
652
652
|
this.onChange(flags);
|
@@ -738,7 +738,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
738
738
|
}
|
739
739
|
const draft = (0, utils_1.fastCloneDeep)(this.submission);
|
740
740
|
draft.state = "draft";
|
741
|
-
if (!this.savingDraft) {
|
741
|
+
if (!this.savingDraft && !this.submitting) {
|
742
742
|
this.emit("saveDraftBegin");
|
743
743
|
this.savingDraft = true;
|
744
744
|
this.formio
|
@@ -816,7 +816,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
816
816
|
};
|
817
817
|
}
|
818
818
|
// Metadata needs to be available before setValue
|
819
|
-
this._submission.metadata = submission.metadata
|
819
|
+
this._submission.metadata = submission.metadata ? lodash_1.default.cloneDeep(submission.metadata) : {};
|
820
820
|
this.editing = !!submission._id;
|
821
821
|
// Set the timezone in the options if available.
|
822
822
|
if (!this.options.submissionTimezone &&
|
@@ -1504,16 +1504,18 @@ class Webform extends NestedDataComponent_1.default {
|
|
1504
1504
|
return console.warn("You should add a URL to this button.");
|
1505
1505
|
}
|
1506
1506
|
}
|
1507
|
-
|
1507
|
+
triggerCaptcha() {
|
1508
1508
|
if (!this || !this.components) {
|
1509
1509
|
return;
|
1510
1510
|
}
|
1511
|
-
const
|
1512
|
-
|
1513
|
-
|
1511
|
+
const captchaComponent = [];
|
1512
|
+
(0, formUtils_1.eachComponent)(this.components, (component) => {
|
1513
|
+
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
1514
|
+
captchaComponent.push(component);
|
1515
|
+
}
|
1514
1516
|
});
|
1515
|
-
if (
|
1516
|
-
|
1517
|
+
if (captchaComponent.length > 0) {
|
1518
|
+
captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
|
1517
1519
|
}
|
1518
1520
|
}
|
1519
1521
|
set nosubmit(value) {
|
@@ -73,7 +73,7 @@ export default class WebformBuilder extends Component {
|
|
73
73
|
onDrop(element: any, target: any, source: any, sibling: any): any;
|
74
74
|
setForm(form: any): any;
|
75
75
|
keyboardActionsEnabled: any;
|
76
|
-
|
76
|
+
populateCaptchaSettings(form: any): void;
|
77
77
|
removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
79
79
|
updateComponent(component: any, changed: any): void;
|
@@ -486,7 +486,7 @@ class WebformBuilder extends Component_1.default {
|
|
486
486
|
}
|
487
487
|
attach(element) {
|
488
488
|
this.on('change', (form) => {
|
489
|
-
this.
|
489
|
+
this.populateCaptchaSettings(form);
|
490
490
|
this.webform.setAlert(false);
|
491
491
|
});
|
492
492
|
return super.attach(element).then(() => {
|
@@ -939,24 +939,24 @@ class WebformBuilder extends Component_1.default {
|
|
939
939
|
}
|
940
940
|
return Promise.resolve(form);
|
941
941
|
}
|
942
|
-
|
943
|
-
//populate isEnabled for
|
944
|
-
let
|
942
|
+
populateCaptchaSettings(form) {
|
943
|
+
//populate isEnabled for captcha form settings
|
944
|
+
let isCaptchaEnabled = false;
|
945
945
|
if (this.form.components) {
|
946
946
|
(0, formUtils_1.eachComponent)(form.components, component => {
|
947
|
-
if (
|
947
|
+
if (isCaptchaEnabled) {
|
948
948
|
return;
|
949
949
|
}
|
950
|
-
if (component.type === '
|
951
|
-
|
950
|
+
if (component.type === 'captcha') {
|
951
|
+
isCaptchaEnabled = true;
|
952
952
|
return false;
|
953
953
|
}
|
954
954
|
});
|
955
|
-
if (
|
956
|
-
lodash_1.default.set(form, 'settings.
|
955
|
+
if (isCaptchaEnabled) {
|
956
|
+
lodash_1.default.set(form, 'settings.captcha.isEnabled', true);
|
957
957
|
}
|
958
|
-
else if (lodash_1.default.get(form, 'settings.
|
959
|
-
lodash_1.default.set(form, 'settings.
|
958
|
+
else if (lodash_1.default.get(form, 'settings.captcha.isEnabled')) {
|
959
|
+
lodash_1.default.set(form, 'settings.captcha.isEnabled', false);
|
960
960
|
}
|
961
961
|
}
|
962
962
|
}
|
@@ -1119,16 +1119,11 @@ class WebformBuilder extends Component_1.default {
|
|
1119
1119
|
const repeatablePaths = this.findRepeatablePaths();
|
1120
1120
|
let hasInvalidComponents = false;
|
1121
1121
|
this.webform.everyComponent((comp) => {
|
1122
|
-
var _a;
|
1123
1122
|
const path = comp.path;
|
1124
|
-
const errors = comp.visibleErrors || [];
|
1125
1123
|
if (repeatablePaths.includes(path)) {
|
1126
|
-
comp.setCustomValidity(
|
1124
|
+
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1127
1125
|
hasInvalidComponents = true;
|
1128
1126
|
}
|
1129
|
-
else if (errors.length && ((_a = errors[0].message) === null || _a === void 0 ? void 0 : _a.startsWith('API Key is not unique'))) {
|
1130
|
-
comp.setCustomValidity('');
|
1131
|
-
}
|
1132
1127
|
});
|
1133
1128
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
1134
1129
|
}
|
@@ -3500,7 +3500,7 @@ Component.requireLibrary = function (name, property, src, polling) {
|
|
3500
3500
|
}.bind(Component.externalLibraries[name]);
|
3501
3501
|
}
|
3502
3502
|
// See if the plugin already exists.
|
3503
|
-
const plugin =
|
3503
|
+
const plugin = (0, utils_1.getScriptPlugin)(property);
|
3504
3504
|
if (plugin) {
|
3505
3505
|
Component.externalLibraries[name].resolve(plugin);
|
3506
3506
|
}
|
@@ -3543,7 +3543,7 @@ Component.requireLibrary = function (name, property, src, polling) {
|
|
3543
3543
|
// if no callback is provided, then check periodically for the script.
|
3544
3544
|
if (polling) {
|
3545
3545
|
setTimeout(function checkLibrary() {
|
3546
|
-
const plugin =
|
3546
|
+
const plugin = (0, utils_1.getScriptPlugin)(property);
|
3547
3547
|
if (plugin) {
|
3548
3548
|
Component.externalLibraries[name].resolve(plugin);
|
3549
3549
|
}
|
@@ -273,7 +273,7 @@ class ButtonComponent extends Field_1.default {
|
|
273
273
|
super.detach();
|
274
274
|
}
|
275
275
|
onClick(event) {
|
276
|
-
this.
|
276
|
+
this.triggerCaptcha();
|
277
277
|
// Don't click if disabled or in builder mode.
|
278
278
|
if (this.disabled || this.options.attachMode === 'builder') {
|
279
279
|
return;
|
@@ -459,20 +459,20 @@ class ButtonComponent extends Field_1.default {
|
|
459
459
|
this.refs.button.focus();
|
460
460
|
}
|
461
461
|
}
|
462
|
-
|
462
|
+
triggerCaptcha() {
|
463
463
|
if (!this.root) {
|
464
464
|
return;
|
465
465
|
}
|
466
|
-
let
|
466
|
+
let captchaComponent;
|
467
467
|
this.root.everyComponent((component) => {
|
468
|
-
if (component.component.type
|
468
|
+
if (/^(re)?captcha$/.test(component.component.type) &&
|
469
469
|
component.component.eventType === 'buttonClick' &&
|
470
470
|
component.component.buttonKey === this.component.key) {
|
471
|
-
|
471
|
+
captchaComponent = component;
|
472
472
|
}
|
473
473
|
});
|
474
|
-
if (
|
475
|
-
|
474
|
+
if (captchaComponent) {
|
475
|
+
captchaComponent.verify(`${this.component.key}Click`);
|
476
476
|
}
|
477
477
|
}
|
478
478
|
}
|
@@ -48,7 +48,7 @@ export default class RadioComponent extends ListComponent {
|
|
48
48
|
detach(element: any): void;
|
49
49
|
validateValueProperty(): boolean;
|
50
50
|
validateValueAvailability(setting: any, value: any): boolean;
|
51
|
-
getValueAsString(value: any): any;
|
51
|
+
getValueAsString(value: any, options?: {}): any;
|
52
52
|
setValueAt(index: any, value: any): void;
|
53
53
|
loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
|
54
54
|
loadItemsFromMetadata(): void;
|
@@ -226,17 +226,19 @@ class RadioComponent extends ListComponent_1.default {
|
|
226
226
|
}
|
227
227
|
return false;
|
228
228
|
}
|
229
|
-
getValueAsString(value) {
|
229
|
+
getValueAsString(value, options = {}) {
|
230
230
|
if (lodash_1.default.isObject(value)) {
|
231
231
|
value = JSON.stringify(value);
|
232
232
|
}
|
233
233
|
else if (!lodash_1.default.isString(value)) {
|
234
234
|
value = lodash_1.default.toString(value);
|
235
235
|
}
|
236
|
-
|
236
|
+
const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
|
237
|
+
if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
|
237
238
|
return value;
|
238
239
|
}
|
239
|
-
const
|
240
|
+
const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
|
241
|
+
const option = lodash_1.default.find(values, (v) => v.value === value);
|
240
242
|
if (!value) {
|
241
243
|
return lodash_1.default.get(option, 'label', '');
|
242
244
|
}
|
@@ -1,12 +1,5 @@
|
|
1
1
|
export default class ReCaptchaComponent extends Component {
|
2
|
-
static get builderInfo(): {
|
3
|
-
title: string;
|
4
|
-
group: string;
|
5
|
-
icon: string;
|
6
|
-
documentation: string;
|
7
|
-
weight: number;
|
8
|
-
schema: any;
|
9
|
-
};
|
2
|
+
static get builderInfo(): {};
|
10
3
|
static savedValueTypes(): never[];
|
11
4
|
render(): string;
|
12
5
|
recaptchaResult: any;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* The Edit Form function.
|
3
|
+
* @param {...any} extend - The components that extend the edit form.
|
3
4
|
* @returns {import('@formio/core').Component[]} - The edit form components.
|
4
5
|
*/
|
5
|
-
export default function _default(): import('@formio/core').Component[];
|
6
|
+
export default function _default(...extend: any[]): import('@formio/core').Component[];
|
@@ -7,9 +7,10 @@ const Components_1 = __importDefault(require("../Components"));
|
|
7
7
|
const ReCaptcha_edit_display_1 = __importDefault(require("./editForm/ReCaptcha.edit.display"));
|
8
8
|
/**
|
9
9
|
* The Edit Form function.
|
10
|
+
* @param {...any} extend - The components that extend the edit form.
|
10
11
|
* @returns {import('@formio/core').Component[]} - The edit form components.
|
11
12
|
*/
|
12
|
-
function default_1() {
|
13
|
+
function default_1(...extend) {
|
13
14
|
return Components_1.default.baseEditForm([
|
14
15
|
{
|
15
16
|
key: 'display',
|
@@ -31,6 +32,6 @@ function default_1() {
|
|
31
32
|
key: 'logic',
|
32
33
|
ignore: true
|
33
34
|
},
|
34
|
-
]);
|
35
|
+
], ...extend);
|
35
36
|
}
|
36
37
|
exports.default = default_1;
|
@@ -26,14 +26,7 @@ class ReCaptchaComponent extends Component_1.default {
|
|
26
26
|
}, ...extend);
|
27
27
|
}
|
28
28
|
static get builderInfo() {
|
29
|
-
return {
|
30
|
-
title: 'reCAPTCHA',
|
31
|
-
group: 'premium',
|
32
|
-
icon: 'refresh',
|
33
|
-
documentation: '/userguide/form-building/premium-components#recaptcha',
|
34
|
-
weight: 40,
|
35
|
-
schema: ReCaptchaComponent.schema()
|
36
|
-
};
|
29
|
+
return {};
|
37
30
|
}
|
38
31
|
static savedValueTypes() {
|
39
32
|
return [];
|
@@ -1,4 +1,21 @@
|
|
1
1
|
declare const _default: ({
|
2
|
+
key: string;
|
3
|
+
weight: number;
|
4
|
+
type: string;
|
5
|
+
tag: string;
|
6
|
+
className: string;
|
7
|
+
content: string;
|
8
|
+
label?: undefined;
|
9
|
+
tooltip?: undefined;
|
10
|
+
values?: undefined;
|
11
|
+
validate?: undefined;
|
12
|
+
input?: undefined;
|
13
|
+
dataSrc?: undefined;
|
14
|
+
valueProperty?: undefined;
|
15
|
+
customConditional?: undefined;
|
16
|
+
data?: undefined;
|
17
|
+
ignore?: undefined;
|
18
|
+
} | {
|
2
19
|
key: string;
|
3
20
|
label: string;
|
4
21
|
tooltip: string;
|
@@ -7,7 +24,13 @@ declare const _default: ({
|
|
7
24
|
label: string;
|
8
25
|
value: string;
|
9
26
|
}[];
|
27
|
+
validate: {
|
28
|
+
required: boolean;
|
29
|
+
};
|
10
30
|
weight: number;
|
31
|
+
tag?: undefined;
|
32
|
+
className?: undefined;
|
33
|
+
content?: undefined;
|
11
34
|
input?: undefined;
|
12
35
|
dataSrc?: undefined;
|
13
36
|
valueProperty?: undefined;
|
@@ -27,16 +50,24 @@ declare const _default: ({
|
|
27
50
|
data: {
|
28
51
|
custom(context: any): any[];
|
29
52
|
};
|
53
|
+
tag?: undefined;
|
54
|
+
className?: undefined;
|
55
|
+
content?: undefined;
|
30
56
|
values?: undefined;
|
57
|
+
validate?: undefined;
|
31
58
|
ignore?: undefined;
|
32
59
|
} | {
|
33
60
|
key: string;
|
34
61
|
ignore: boolean;
|
62
|
+
weight?: undefined;
|
63
|
+
type?: undefined;
|
64
|
+
tag?: undefined;
|
65
|
+
className?: undefined;
|
66
|
+
content?: undefined;
|
35
67
|
label?: undefined;
|
36
68
|
tooltip?: undefined;
|
37
|
-
type?: undefined;
|
38
69
|
values?: undefined;
|
39
|
-
|
70
|
+
validate?: undefined;
|
40
71
|
input?: undefined;
|
41
72
|
dataSrc?: undefined;
|
42
73
|
valueProperty?: undefined;
|
@@ -2,10 +2,18 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("../../../utils/utils");
|
4
4
|
exports.default = [
|
5
|
+
{
|
6
|
+
key: 'recaptchaInfo',
|
7
|
+
weight: -10,
|
8
|
+
type: 'htmlelement',
|
9
|
+
tag: 'div',
|
10
|
+
className: 'alert alert-danger',
|
11
|
+
content: 'This component has been deprecated and will be removed. Use the CAPTCHA component instead.',
|
12
|
+
},
|
5
13
|
{
|
6
14
|
key: 'eventType',
|
7
15
|
label: 'Type of event',
|
8
|
-
tooltip: 'Specify type of event that this
|
16
|
+
tooltip: 'Specify type of event that this CAPTCHA would react to. If Button Click is selected, then the CAPTCHA widget will be displayed and verification will occur after clicking on the button.',
|
9
17
|
type: 'radio',
|
10
18
|
values: [
|
11
19
|
{
|
@@ -17,6 +25,9 @@ exports.default = [
|
|
17
25
|
value: 'buttonClick'
|
18
26
|
}
|
19
27
|
],
|
28
|
+
validate: {
|
29
|
+
required: true
|
30
|
+
},
|
20
31
|
weight: 650
|
21
32
|
},
|
22
33
|
{
|
@@ -26,7 +37,7 @@ exports.default = [
|
|
26
37
|
key: 'buttonKey',
|
27
38
|
dataSrc: 'custom',
|
28
39
|
valueProperty: 'value',
|
29
|
-
tooltip: 'Specify key of button on this form that this
|
40
|
+
tooltip: 'Specify key of button on this form that this CAPTCHA should react to',
|
30
41
|
weight: 660,
|
31
42
|
customConditional(context) {
|
32
43
|
return context.data.eventType === 'buttonClick';
|
@@ -228,9 +228,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
228
228
|
}
|
229
229
|
selectValueAndLabel(data) {
|
230
230
|
const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
|
231
|
+
const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
|
231
232
|
return {
|
232
233
|
value,
|
233
|
-
label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)
|
234
|
+
label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : readOnlyResourceLabelData || data, value)
|
234
235
|
};
|
235
236
|
}
|
236
237
|
itemTemplate(data, value) {
|
@@ -1467,6 +1468,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
1467
1468
|
asString(value, options = {}) {
|
1468
1469
|
var _a;
|
1469
1470
|
value = value !== null && value !== void 0 ? value : this.getValue();
|
1471
|
+
if (options.modalPreview && this.selectData) {
|
1472
|
+
const { label } = this.selectValueAndLabel(value);
|
1473
|
+
return label;
|
1474
|
+
}
|
1470
1475
|
//need to convert values to strings to be able to compare values with available options that are strings
|
1471
1476
|
const convertToString = (data, valueProperty) => {
|
1472
1477
|
if (valueProperty) {
|
@@ -5,15 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const utils_1 = require("../../../utils/utils");
|
8
|
-
const
|
8
|
+
const calculateSingleSelectData = (context, defaultValue) => {
|
9
9
|
const { instance, data } = context;
|
10
|
-
const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) ===
|
10
|
+
const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);
|
11
11
|
const options = { data: {}, noeval: true };
|
12
12
|
instance.interpolate(data.template, {
|
13
13
|
item: rawDefaultValue,
|
14
14
|
}, options);
|
15
15
|
return options.data.item;
|
16
16
|
};
|
17
|
+
const calculateSelectData = (context) => {
|
18
|
+
const { instance } = context;
|
19
|
+
const defaultValue = instance.getValue();
|
20
|
+
if (instance.component.multiple) {
|
21
|
+
const multiSelectData = {};
|
22
|
+
(defaultValue !== null && defaultValue !== void 0 ? defaultValue : []).forEach((defaultValueItem) => {
|
23
|
+
multiSelectData[defaultValueItem] = calculateSingleSelectData(context, defaultValueItem);
|
24
|
+
});
|
25
|
+
return multiSelectData;
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
return calculateSingleSelectData(context, defaultValue);
|
29
|
+
}
|
30
|
+
};
|
17
31
|
const setSelectData = (context) => {
|
18
32
|
// Wait before downloadedResources will be set
|
19
33
|
setTimeout(() => {
|