@formio/js 5.0.0-dev.5620.dedc19b → 5.0.0-dev.5625.779293f

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 (74) hide show
  1. package/Changelog.md +5 -0
  2. package/dist/formio.builder.css +0 -4
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.form.css +0 -4
  5. package/dist/formio.form.js +54 -42
  6. package/dist/formio.form.min.css +1 -1
  7. package/dist/formio.form.min.js +1 -1
  8. package/dist/formio.full.css +0 -4
  9. package/dist/formio.full.js +58 -46
  10. package/dist/formio.full.min.css +1 -1
  11. package/dist/formio.full.min.js +1 -1
  12. package/dist/formio.js +2 -2
  13. package/dist/formio.min.js +1 -1
  14. package/dist/formio.utils.js +2 -2
  15. package/dist/formio.utils.min.js +1 -1
  16. package/lib/cjs/Formio.js +11 -0
  17. package/lib/cjs/Webform.d.ts +1 -1
  18. package/lib/cjs/Webform.js +14 -9
  19. package/lib/cjs/WebformBuilder.d.ts +1 -1
  20. package/lib/cjs/WebformBuilder.js +20 -19
  21. package/lib/cjs/components/_classes/component/Component.d.ts +5 -3
  22. package/lib/cjs/components/_classes/component/Component.js +2 -6
  23. package/lib/cjs/components/button/Button.d.ts +1 -1
  24. package/lib/cjs/components/button/Button.js +7 -7
  25. package/lib/cjs/components/form/Form.js +3 -2
  26. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -8
  27. package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +1 -1
  28. package/lib/cjs/components/recaptcha/ReCaptcha.form.js +2 -2
  29. package/lib/cjs/components/recaptcha/ReCaptcha.js +1 -8
  30. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +28 -2
  31. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +10 -2
  32. package/lib/cjs/components/select/Select.js +1 -1
  33. package/lib/cjs/components/select/editForm/Select.edit.data.js +16 -2
  34. package/lib/cjs/components/select/fixtures/comp22.js +1 -1
  35. package/lib/cjs/components/select/fixtures/comp23.d.ts +26 -15
  36. package/lib/cjs/components/select/fixtures/comp23.js +28 -19
  37. package/lib/cjs/components/select/fixtures/comp24.d.ts +47 -0
  38. package/lib/cjs/components/select/fixtures/comp24.js +40 -0
  39. package/lib/cjs/components/select/fixtures/index.d.ts +2 -1
  40. package/lib/cjs/components/select/fixtures/index.js +3 -1
  41. package/lib/cjs/translations/en.d.ts +1 -0
  42. package/lib/cjs/translations/en.js +1 -0
  43. package/lib/cjs/utils/utils.d.ts +6 -0
  44. package/lib/cjs/utils/utils.js +15 -4
  45. package/lib/mjs/Formio.js +11 -0
  46. package/lib/mjs/Webform.d.ts +1 -1
  47. package/lib/mjs/Webform.js +15 -10
  48. package/lib/mjs/WebformBuilder.d.ts +1 -1
  49. package/lib/mjs/WebformBuilder.js +20 -18
  50. package/lib/mjs/components/_classes/component/Component.d.ts +5 -3
  51. package/lib/mjs/components/_classes/component/Component.js +2 -6
  52. package/lib/mjs/components/button/Button.d.ts +1 -1
  53. package/lib/mjs/components/button/Button.js +7 -7
  54. package/lib/mjs/components/form/Form.js +3 -2
  55. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -8
  56. package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +1 -1
  57. package/lib/mjs/components/recaptcha/ReCaptcha.form.js +2 -2
  58. package/lib/mjs/components/recaptcha/ReCaptcha.js +1 -8
  59. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +28 -2
  60. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +10 -2
  61. package/lib/mjs/components/select/Select.js +2 -2
  62. package/lib/mjs/components/select/editForm/Select.edit.data.js +16 -2
  63. package/lib/mjs/components/select/fixtures/comp22.js +1 -1
  64. package/lib/mjs/components/select/fixtures/comp23.d.ts +26 -15
  65. package/lib/mjs/components/select/fixtures/comp23.js +28 -19
  66. package/lib/mjs/components/select/fixtures/comp24.d.ts +47 -0
  67. package/lib/mjs/components/select/fixtures/comp24.js +38 -0
  68. package/lib/mjs/components/select/fixtures/index.d.ts +2 -1
  69. package/lib/mjs/components/select/fixtures/index.js +2 -1
  70. package/lib/mjs/translations/en.d.ts +1 -0
  71. package/lib/mjs/translations/en.js +1 -0
  72. package/lib/mjs/utils/utils.d.ts +6 -0
  73. package/lib/mjs/utils/utils.js +12 -2
  74. package/package.json +2 -2
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ title: 'FIO-8234',
5
+ name: 'fio8234',
6
+ path: 'fio8234',
7
+ type: 'form',
8
+ display: 'form',
9
+ components: [
10
+ {
11
+ label: 'Select',
12
+ widget: 'choicesjs',
13
+ tableView: true,
14
+ dataSrc: 'resource',
15
+ data: {
16
+ resource: '665446284c9b0163c3e0c7e6',
17
+ },
18
+ template: '<span>{{ item.data.textField1 }}</span>',
19
+ validate: {
20
+ select: false,
21
+ },
22
+ key: 'select',
23
+ type: 'select',
24
+ searchField: 'data.textField2__regex',
25
+ input: true,
26
+ noRefreshOnScroll: false,
27
+ addResource: false,
28
+ reference: false,
29
+ valueProperty: 'data.textField2',
30
+ },
31
+ {
32
+ type: 'button',
33
+ label: 'Submit',
34
+ key: 'submit',
35
+ disableOnInvalid: true,
36
+ input: true,
37
+ tableView: false,
38
+ },
39
+ ],
40
+ };
@@ -20,5 +20,6 @@ import comp20 from './comp20';
20
20
  import comp21 from './comp21';
21
21
  import comp22 from './comp22';
22
22
  import comp23 from './comp23';
23
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23 };
23
+ import comp24 from './comp24';
24
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23, comp24 };
24
25
  export { multiSelect, multiSelectOptions } from "./comp3";
@@ -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.comp23 = exports.comp22 = exports.comp21 = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp2 = exports.comp1 = exports.multiSelectOptions = exports.multiSelect = void 0;
6
+ exports.comp24 = exports.comp23 = exports.comp22 = exports.comp21 = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp2 = exports.comp1 = exports.multiSelectOptions = exports.multiSelect = 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"));
@@ -51,3 +51,5 @@ const comp22_1 = __importDefault(require("./comp22"));
51
51
  exports.comp22 = comp22_1.default;
52
52
  const comp23_1 = __importDefault(require("./comp23"));
53
53
  exports.comp23 = comp23_1.default;
54
+ const comp24_1 = __importDefault(require("./comp24"));
55
+ exports.comp24 = comp24_1.default;
@@ -71,5 +71,6 @@ declare namespace _default {
71
71
  let submitButtonAriaLabel: string;
72
72
  let reCaptchaTokenValidationError: string;
73
73
  let reCaptchaTokenNotSpecifiedError: string;
74
+ let apiKey: string;
74
75
  }
75
76
  export default _default;
@@ -73,4 +73,5 @@ exports.default = {
73
73
  submitButtonAriaLabel: 'Submit Form button. Click to submit the form',
74
74
  reCaptchaTokenValidationError: 'ReCAPTCHA: Token validation error',
75
75
  reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
76
+ apiKey: 'API Key is not unique: {{key}}'
76
77
  };
@@ -107,6 +107,12 @@ export function checkCondition(component: any, row: any, data: any, form: any, i
107
107
  */
108
108
  export function checkTrigger(component: any, trigger: any, row: any, data: any, form: any, instance: any): mixed;
109
109
  export function setActionProperty(component: any, action: any, result: any, row: any, data: any, instance: any): any;
110
+ /**
111
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
112
+ * @param {string} str
113
+ * @returns {string}
114
+ */
115
+ export function removeHTML(str: string): string;
110
116
  /**
111
117
  * Unescape HTML characters like &lt, &gt, &amp and etc.
112
118
  * @param str
@@ -30,8 +30,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
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 = void 0;
33
+ exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
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
37
  const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
@@ -448,6 +448,16 @@ function setActionProperty(component, action, result, row, data, instance) {
448
448
  return component;
449
449
  }
450
450
  exports.setActionProperty = setActionProperty;
451
+ /**
452
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
453
+ * @param {string} str
454
+ * @returns {string}
455
+ */
456
+ function removeHTML(str) {
457
+ const doc = new window.DOMParser().parseFromString(str, 'text/html');
458
+ return (doc.body.textContent || '').trim();
459
+ }
460
+ exports.removeHTML = removeHTML;
451
461
  /**
452
462
  * Unescape HTML characters like &lt, &gt, &amp and etc.
453
463
  * @param str
@@ -457,8 +467,9 @@ function unescapeHTML(str) {
457
467
  if (typeof window === 'undefined' || !('DOMParser' in window)) {
458
468
  return str;
459
469
  }
460
- const doc = new window.DOMParser().parseFromString(str, 'text/html');
461
- return doc.documentElement.textContent;
470
+ const elem = document.createElement('textarea');
471
+ elem.innerHTML = str;
472
+ return elem.value;
462
473
  }
463
474
  exports.unescapeHTML = unescapeHTML;
464
475
  /**
package/lib/mjs/Formio.js CHANGED
@@ -107,4 +107,15 @@ FormioCore.createForm = FormioEmbed.createForm;
107
107
  FormioCore.submitDone = FormioEmbed.submitDone;
108
108
  FormioCore.addLibrary = FormioEmbed.addLibrary;
109
109
  FormioCore.addLoader = FormioEmbed.addLoader;
110
+ FormioCore.addToGlobal = (global) => {
111
+ if (typeof global === 'object' && !global.Formio) {
112
+ global.Formio = FormioCore;
113
+ }
114
+ };
115
+ if (typeof global !== 'undefined') {
116
+ FormioCore.addToGlobal(global);
117
+ }
118
+ if (typeof window !== 'undefined') {
119
+ FormioCore.addToGlobal(window);
120
+ }
110
121
  export { FormioCore as Formio };
@@ -471,7 +471,7 @@ declare class Webform extends NestedDataComponent {
471
471
  */
472
472
  submit(before: boolean, options?: {}): Promise<any>;
473
473
  submitUrl(URL: any, headers: any): void;
474
- triggerRecaptcha(): void;
474
+ triggerCaptcha(): void;
475
475
  _nosubmit: any;
476
476
  get conditions(): any;
477
477
  get variables(): any;
@@ -7,7 +7,7 @@ import i18nDefaults from './i18n';
7
7
  import { Formio } from './Formio';
8
8
  import Components from './components/Components';
9
9
  import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
10
- import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, searchComponents, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils/utils';
10
+ import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils/utils';
11
11
  import { eachComponent } from './utils/formUtils';
12
12
  // Initialize the available forms.
13
13
  Formio.forms = {};
@@ -657,7 +657,7 @@ export default class Webform extends NestedDataComponent {
657
657
  const rebuild = this.rebuild() || Promise.resolve();
658
658
  return rebuild.then(() => {
659
659
  this.emit('formLoad', form);
660
- this.triggerRecaptcha();
660
+ this.triggerCaptcha();
661
661
  // Make sure to trigger onChange after a render event occurs to speed up form rendering.
662
662
  setTimeout(() => {
663
663
  this.onChange(flags);
@@ -791,7 +791,8 @@ export default class Webform extends NestedDataComponent {
791
791
  formio.loadSubmissions({
792
792
  params: {
793
793
  state: 'draft',
794
- owner: userId
794
+ owner: userId,
795
+ sort: '-created'
795
796
  }
796
797
  }).then(submissions => {
797
798
  if (submissions.length > 0 && !this.options.skipDraftRestore) {
@@ -834,7 +835,9 @@ export default class Webform extends NestedDataComponent {
834
835
  };
835
836
  }
836
837
  // Metadata needs to be available before setValue
837
- this._submission.metadata = submission.metadata || {};
838
+ this._submission.metadata = submission.metadata
839
+ ? _.cloneDeep(submission.metadata)
840
+ : {};
838
841
  this.editing = !!submission._id;
839
842
  // Set the timezone in the options if available.
840
843
  if (!this.options.submissionTimezone &&
@@ -1489,16 +1492,18 @@ export default class Webform extends NestedDataComponent {
1489
1492
  return console.warn('You should add a URL to this button.');
1490
1493
  }
1491
1494
  }
1492
- triggerRecaptcha() {
1495
+ triggerCaptcha() {
1493
1496
  if (!this || !this.components) {
1494
1497
  return;
1495
1498
  }
1496
- const recaptchaComponent = searchComponents(this.components, {
1497
- 'component.type': 'recaptcha',
1498
- 'component.eventType': 'formLoad'
1499
+ const captchaComponent = [];
1500
+ eachComponent(this.components, (component) => {
1501
+ if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1502
+ captchaComponent.push(component);
1503
+ }
1499
1504
  });
1500
- if (recaptchaComponent.length > 0) {
1501
- recaptchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1505
+ if (captchaComponent.length > 0) {
1506
+ captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1502
1507
  }
1503
1508
  }
1504
1509
  set nosubmit(value) {
@@ -72,7 +72,7 @@ export default class WebformBuilder extends Component {
72
72
  onDrop(element: any, target: any, source: any, sibling: any): any;
73
73
  setForm(form: any): any;
74
74
  keyboardActionsEnabled: any;
75
- populateRecaptchaSettings(form: any): void;
75
+ populateCaptchaSettings(form: any): void;
76
76
  removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
77
77
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
78
78
  updateComponent(component: any, changed: any): void;
@@ -472,7 +472,7 @@ export default class WebformBuilder extends Component {
472
472
  }
473
473
  attach(element) {
474
474
  this.on('change', (form) => {
475
- this.populateRecaptchaSettings(form);
475
+ this.populateCaptchaSettings(form);
476
476
  this.webform.setAlert(false);
477
477
  });
478
478
  return super.attach(element).then(() => {
@@ -923,24 +923,24 @@ export default class WebformBuilder extends Component {
923
923
  }
924
924
  return Promise.resolve(form);
925
925
  }
926
- populateRecaptchaSettings(form) {
927
- //populate isEnabled for recaptcha form settings
928
- let isRecaptchaEnabled = false;
926
+ populateCaptchaSettings(form) {
927
+ //populate isEnabled for captcha form settings
928
+ let isCaptchaEnabled = false;
929
929
  if (this.form.components) {
930
930
  eachComponent(form.components, component => {
931
- if (isRecaptchaEnabled) {
931
+ if (isCaptchaEnabled) {
932
932
  return;
933
933
  }
934
- if (component.type === 'recaptcha') {
935
- isRecaptchaEnabled = true;
934
+ if (component.type === 'captcha') {
935
+ isCaptchaEnabled = true;
936
936
  return false;
937
937
  }
938
938
  });
939
- if (isRecaptchaEnabled) {
940
- _.set(form, 'settings.recaptcha.isEnabled', true);
939
+ if (isCaptchaEnabled) {
940
+ _.set(form, 'settings.captcha.isEnabled', true);
941
941
  }
942
- else if (_.get(form, 'settings.recaptcha.isEnabled')) {
943
- _.set(form, 'settings.recaptcha.isEnabled', false);
942
+ else if (_.get(form, 'settings.captcha.isEnabled')) {
943
+ _.set(form, 'settings.captcha.isEnabled', false);
944
944
  }
945
945
  }
946
946
  }
@@ -970,8 +970,14 @@ export default class WebformBuilder extends Component {
970
970
  else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
971
971
  parent.formioComponent.removeChildComponent(component);
972
972
  }
973
- if (component.input && componentInstance && componentInstance.parent) {
974
- _.unset(componentInstance._data, componentInstance.key);
973
+ if (component.input && componentInstance && parent.formioComponent) {
974
+ const parentDefaultValue = _.get(parent.formioComponent, 'component.defaultValue', null);
975
+ if (Array.isArray(parentDefaultValue)) {
976
+ parentDefaultValue.forEach(v => _.unset(v, componentInstance.key));
977
+ }
978
+ else if (typeof parentDefaultValue === 'object') {
979
+ _.unset(parentDefaultValue, componentInstance.key);
980
+ }
975
981
  }
976
982
  const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
977
983
  rebuild.then(() => {
@@ -1104,14 +1110,10 @@ export default class WebformBuilder extends Component {
1104
1110
  let hasInvalidComponents = false;
1105
1111
  this.webform.everyComponent((comp) => {
1106
1112
  const path = comp.path;
1107
- const errors = comp.visibleErrors || [];
1108
1113
  if (repeatablePaths.includes(path)) {
1109
- comp.setCustomValidity(`API Key is not unique: ${comp.key}`);
1114
+ comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1110
1115
  hasInvalidComponents = true;
1111
1116
  }
1112
- else if (errors.length && errors[0].message?.startsWith('API Key is not unique')) {
1113
- comp.setCustomValidity('');
1114
- }
1115
1117
  });
1116
1118
  this.emit('builderFormValidityChange', hasInvalidComponents);
1117
1119
  }
@@ -492,10 +492,12 @@ declare class Component extends Element {
492
492
  /**
493
493
  * Add a new input error to this element.
494
494
  *
495
- * @param message
496
- * @param dirty
495
+ * @param {{level: string, message: string}[]} messages
497
496
  */
498
- addMessages(messages: any): void;
497
+ addMessages(messages: {
498
+ level: string;
499
+ message: string;
500
+ }[]): void;
499
501
  setErrorClasses(elements: any, dirty: any, hasErrors: any, hasMessages: any, element?: any): void;
500
502
  setElementInvalid(element: any, invalid: any): void;
501
503
  clearOnHide(): void;
@@ -1795,8 +1795,7 @@ export default class Component extends Element {
1795
1795
  /**
1796
1796
  * Add a new input error to this element.
1797
1797
  *
1798
- * @param message
1799
- * @param dirty
1798
+ * @param {{level: string, message: string}[]} messages
1800
1799
  */
1801
1800
  addMessages(messages) {
1802
1801
  if (!messages) {
@@ -1815,9 +1814,6 @@ export default class Component extends Element {
1815
1814
  messages = _.uniqBy(messages, message => message.message);
1816
1815
  if (this.refs.messageContainer) {
1817
1816
  this.setContent(this.refs.messageContainer, messages.map((message) => {
1818
- if (message.message && typeof message.message === 'string') {
1819
- message.message = message.message.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
1820
- }
1821
1817
  return this.renderTemplate('message', { ...message });
1822
1818
  }).join(''));
1823
1819
  }
@@ -2531,7 +2527,7 @@ export default class Component extends Element {
2531
2527
  }
2532
2528
  this.calculatedValue = fastCloneDeep(calculatedValue);
2533
2529
  if (changed) {
2534
- if (!flags.noPristineChangeOnModified) {
2530
+ if (!flags.noPristineChangeOnModified && this.root.initialized) {
2535
2531
  this.pristine = false;
2536
2532
  }
2537
2533
  flags.triggeredComponentId = this.id;
@@ -40,6 +40,6 @@ export default class ButtonComponent extends Field {
40
40
  openOauth(settings: any): void;
41
41
  get oauthComponentPath(): any;
42
42
  focus(): void;
43
- triggerReCaptcha(): void;
43
+ triggerCaptcha(): void;
44
44
  }
45
45
  import Field from '../_classes/field/Field';
@@ -262,7 +262,7 @@ export default class ButtonComponent extends Field {
262
262
  super.detach();
263
263
  }
264
264
  onClick(event) {
265
- this.triggerReCaptcha();
265
+ this.triggerCaptcha();
266
266
  // Don't click if disabled or in builder mode.
267
267
  if (this.disabled || this.options.attachMode === 'builder') {
268
268
  return;
@@ -448,20 +448,20 @@ export default class ButtonComponent extends Field {
448
448
  this.refs.button.focus();
449
449
  }
450
450
  }
451
- triggerReCaptcha() {
451
+ triggerCaptcha() {
452
452
  if (!this.root) {
453
453
  return;
454
454
  }
455
- let recaptchaComponent;
455
+ let captchaComponent;
456
456
  this.root.everyComponent((component) => {
457
- if (component.component.type === 'recaptcha' &&
457
+ if (/^(re)?captcha$/.test(component.component.type) &&
458
458
  component.component.eventType === 'buttonClick' &&
459
459
  component.component.buttonKey === this.component.key) {
460
- recaptchaComponent = component;
460
+ captchaComponent = component;
461
461
  }
462
462
  });
463
- if (recaptchaComponent) {
464
- recaptchaComponent.verify(`${this.component.key}Click`);
463
+ if (captchaComponent) {
464
+ captchaComponent.verify(`${this.component.key}Click`);
465
465
  }
466
466
  }
467
467
  }
@@ -620,9 +620,10 @@ export default class FormComponent extends Component {
620
620
  && submission._id
621
621
  && this.subForm.formio
622
622
  && _.isEmpty(submission.data);
623
- if (shouldLoadSubmissionById) {
623
+ const shouldLoadDraftById = this.options.saveDraft && _.isEmpty(submission.data) && _.get(this.subForm, 'submission._id');
624
+ if (shouldLoadSubmissionById || shouldLoadDraftById) {
624
625
  const formId = submission.form || this.formObj.form || this.component.form;
625
- const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
626
+ const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
626
627
  const options = this.root.formio?.base && this.root.formio?.projectUrl
627
628
  ? {
628
629
  base: this.root.formio.base,
@@ -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(): any;
12
5
  recaptchaResult: any;
@@ -1,3 +1,3 @@
1
- export default function _default(): {
1
+ export default function _default(...extend: any[]): {
2
2
  components: any;
3
3
  };
@@ -1,6 +1,6 @@
1
1
  import Components from '../Components';
2
2
  import ReCaptchaEditDisplay from './editForm/ReCaptcha.edit.display';
3
- export default function () {
3
+ export default function (...extend) {
4
4
  return Components.baseEditForm([
5
5
  {
6
6
  key: 'display',
@@ -22,5 +22,5 @@ export default function () {
22
22
  key: 'logic',
23
23
  ignore: true
24
24
  },
25
- ]);
25
+ ], ...extend);
26
26
  }
@@ -12,14 +12,7 @@ export default class ReCaptchaComponent extends Component {
12
12
  }, ...extend);
13
13
  }
14
14
  static get builderInfo() {
15
- return {
16
- title: 'reCAPTCHA',
17
- group: 'premium',
18
- icon: 'refresh',
19
- documentation: '/userguide/form-building/premium-components#recaptcha',
20
- weight: 40,
21
- schema: ReCaptchaComponent.schema()
22
- };
15
+ return {};
23
16
  }
24
17
  static savedValueTypes() {
25
18
  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;
@@ -11,6 +28,9 @@ declare const _default: ({
11
28
  required: boolean;
12
29
  };
13
30
  weight: number;
31
+ tag?: undefined;
32
+ className?: undefined;
33
+ content?: undefined;
14
34
  input?: undefined;
15
35
  dataSrc?: undefined;
16
36
  valueProperty?: undefined;
@@ -30,18 +50,24 @@ declare const _default: ({
30
50
  data: {
31
51
  custom(context: any): any[];
32
52
  };
53
+ tag?: undefined;
54
+ className?: undefined;
55
+ content?: undefined;
33
56
  values?: undefined;
34
57
  validate?: undefined;
35
58
  ignore?: undefined;
36
59
  } | {
37
60
  key: string;
38
61
  ignore: boolean;
62
+ weight?: undefined;
63
+ type?: undefined;
64
+ tag?: undefined;
65
+ className?: undefined;
66
+ content?: undefined;
39
67
  label?: undefined;
40
68
  tooltip?: undefined;
41
- type?: undefined;
42
69
  values?: undefined;
43
70
  validate?: undefined;
44
- weight?: undefined;
45
71
  input?: undefined;
46
72
  dataSrc?: undefined;
47
73
  valueProperty?: undefined;
@@ -1,9 +1,17 @@
1
1
  import { getContextButtons } from '../../../utils/utils';
2
2
  export default [
3
+ {
4
+ key: 'recaptchaInfo',
5
+ weight: -10,
6
+ type: 'htmlelement',
7
+ tag: 'div',
8
+ className: 'alert alert-danger',
9
+ content: 'This component has been deprecated and will be removed. Use the CAPTCHA component instead.',
10
+ },
3
11
  {
4
12
  key: 'eventType',
5
13
  label: 'Type of event',
6
- tooltip: 'Specify type of event that this reCAPTCHA would react to',
14
+ 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.',
7
15
  type: 'radio',
8
16
  values: [
9
17
  {
@@ -27,7 +35,7 @@ export default [
27
35
  key: 'buttonKey',
28
36
  dataSrc: 'custom',
29
37
  valueProperty: 'value',
30
- tooltip: 'Specify key of button on this form that this reCAPTCHA should react to',
38
+ tooltip: 'Specify key of button on this form that this CAPTCHA should react to',
31
39
  weight: 660,
32
40
  customConditional(context) {
33
41
  return context.data.eventType === 'buttonClick';
@@ -3,7 +3,7 @@ import { Formio } from '../../Formio';
3
3
  import ListComponent from '../_classes/list/ListComponent';
4
4
  import Input from '../_classes/input/Input';
5
5
  import Form from '../../Form';
6
- import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, unescapeHTML, isSelectResourceWithObjectValue } from '../../utils/utils';
6
+ import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, unescapeHTML, isSelectResourceWithObjectValue, removeHTML } from '../../utils/utils';
7
7
  import Choices from '../../utils/ChoicesWrapper';
8
8
  export default class SelectComponent extends ListComponent {
9
9
  static schema(...extend) {
@@ -1551,7 +1551,7 @@ export default class SelectComponent extends ListComponent {
1551
1551
  const getTemplateValue = (v) => {
1552
1552
  const itemTemplate = this.itemTemplate(v);
1553
1553
  return options.csv && itemTemplate
1554
- ? unescapeHTML(itemTemplate)
1554
+ ? removeHTML(itemTemplate)
1555
1555
  : itemTemplate;
1556
1556
  };
1557
1557
  if (Array.isArray(value)) {
@@ -1,14 +1,28 @@
1
1
  import _ from 'lodash';
2
2
  import { eachComponent } from '../../../utils/utils';
3
- const calculateSelectData = (context) => {
3
+ const calculateSingleSelectData = (context, defaultValue) => {
4
4
  const { instance, data } = context;
5
- const rawDefaultValue = instance.downloadedResources.find(resource => _.get(resource, data.valueProperty) === instance.getValue());
5
+ const rawDefaultValue = instance.downloadedResources.find(resource => _.get(resource, data.valueProperty) === defaultValue);
6
6
  const options = { data: {}, noeval: true };
7
7
  instance.interpolate(data.template, {
8
8
  item: rawDefaultValue,
9
9
  }, options);
10
10
  return options.data.item;
11
11
  };
12
+ const calculateSelectData = (context) => {
13
+ const { instance } = context;
14
+ const defaultValue = instance.getValue();
15
+ if (instance.component.multiple) {
16
+ const multiSelectData = {};
17
+ (defaultValue ?? []).forEach((defaultValueItem) => {
18
+ multiSelectData[defaultValueItem] = calculateSingleSelectData(context, defaultValueItem);
19
+ });
20
+ return multiSelectData;
21
+ }
22
+ else {
23
+ return calculateSingleSelectData(context, defaultValue);
24
+ }
25
+ };
12
26
  const setSelectData = (context) => {
13
27
  // Wait before downloadedResources will be set
14
28
  setTimeout(() => {
@@ -6,7 +6,7 @@ export default {
6
6
  display: 'form',
7
7
  components: [{
8
8
  label: 'Select',
9
- widget: 'choicesjs',
9
+ widget: 'html5',
10
10
  tableView: true,
11
11
  dataSrc: 'url',
12
12
  data: {