@formio/js 5.1.0-dev.6040.debc859 → 5.1.0-dev.6042.6e62a7a

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 (150) hide show
  1. package/Changelog.md +140 -6
  2. package/dist/formio.form.js +591 -580
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +613 -602
  5. package/dist/formio.full.min.js +1 -1
  6. package/dist/formio.js +47 -14
  7. package/dist/formio.min.js +1 -1
  8. package/dist/formio.utils.js +48 -15
  9. package/dist/formio.utils.min.js +1 -1
  10. package/lib/cjs/Element.d.ts +2 -1
  11. package/lib/cjs/Element.js +6 -4
  12. package/lib/cjs/Webform.d.ts +2 -2
  13. package/lib/cjs/Webform.js +9 -9
  14. package/lib/cjs/WebformBuilder.js +5 -1
  15. package/lib/cjs/Wizard.d.ts +1 -0
  16. package/lib/cjs/Wizard.js +23 -3
  17. package/lib/cjs/components/_classes/component/Component.d.ts +50 -15
  18. package/lib/cjs/components/_classes/component/Component.js +153 -69
  19. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
  20. package/lib/cjs/components/_classes/component/editForm/utils.js +1 -1
  21. package/lib/cjs/components/_classes/list/ListComponent.js +2 -2
  22. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +0 -1
  23. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
  24. package/lib/cjs/components/_classes/nested/NestedComponent.js +10 -18
  25. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
  26. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +0 -11
  27. package/lib/cjs/components/address/Address.d.ts +9 -0
  28. package/lib/cjs/components/address/Address.js +31 -8
  29. package/lib/cjs/components/address/editForm/Address.edit.display.d.ts +4 -0
  30. package/lib/cjs/components/address/editForm/Address.edit.display.js +1 -0
  31. package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -8
  32. package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
  33. package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
  34. package/lib/cjs/components/datagrid/DataGrid.js +0 -3
  35. package/lib/cjs/components/datamap/DataMap.js +2 -6
  36. package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
  37. package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
  38. package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
  39. package/lib/cjs/components/editgrid/EditGrid.js +3 -13
  40. package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
  41. package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
  42. package/lib/cjs/components/file/File.js +7 -2
  43. package/lib/cjs/components/file/editForm/File.edit.file.d.ts +13 -0
  44. package/lib/cjs/components/file/editForm/File.edit.file.js +1 -0
  45. package/lib/cjs/components/form/Form.d.ts +0 -1
  46. package/lib/cjs/components/form/Form.js +18 -22
  47. package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
  48. package/lib/cjs/components/html/HTML.js +1 -2
  49. package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
  50. package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
  51. package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
  52. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
  53. package/lib/cjs/components/radio/Radio.js +1 -1
  54. package/lib/cjs/components/select/Select.js +1 -1
  55. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +68 -110
  56. package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -37
  57. package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -0
  58. package/lib/cjs/components/survey/Survey.js +1 -1
  59. package/lib/cjs/components/tabs/Tabs.js +1 -0
  60. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
  61. package/lib/cjs/components/textarea/TextArea.js +9 -1
  62. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
  63. package/lib/cjs/components/textfield/TextField.js +2 -2
  64. package/lib/cjs/components/unknown/Unknown.form.d.ts +2 -1
  65. package/lib/cjs/components/unknown/Unknown.form.js +13 -9
  66. package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
  67. package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
  68. package/lib/cjs/formio.form.js +2 -2
  69. package/lib/cjs/providers/storage/uploadAdapter.js +5 -3
  70. package/lib/cjs/translations/en.d.ts +1 -234
  71. package/lib/cjs/translations/en.js +4 -2
  72. package/lib/cjs/utils/formUtils.d.ts +2 -2
  73. package/lib/cjs/utils/utils.d.ts +9 -8
  74. package/lib/cjs/utils/utils.js +18 -23
  75. package/lib/cjs/widgets/CalendarWidget.js +6 -1
  76. package/lib/mjs/Element.d.ts +2 -1
  77. package/lib/mjs/Element.js +6 -4
  78. package/lib/mjs/Webform.d.ts +2 -2
  79. package/lib/mjs/Webform.js +9 -9
  80. package/lib/mjs/WebformBuilder.js +5 -1
  81. package/lib/mjs/Wizard.d.ts +1 -0
  82. package/lib/mjs/Wizard.js +22 -2
  83. package/lib/mjs/components/_classes/component/Component.d.ts +50 -15
  84. package/lib/mjs/components/_classes/component/Component.js +154 -70
  85. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
  86. package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
  87. package/lib/mjs/components/_classes/list/ListComponent.js +2 -2
  88. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +0 -1
  89. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
  90. package/lib/mjs/components/_classes/nested/NestedComponent.js +10 -18
  91. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
  92. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +0 -11
  93. package/lib/mjs/components/address/Address.d.ts +9 -0
  94. package/lib/mjs/components/address/Address.js +31 -8
  95. package/lib/mjs/components/address/editForm/Address.edit.display.d.ts +4 -0
  96. package/lib/mjs/components/address/editForm/Address.edit.display.js +1 -0
  97. package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -8
  98. package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
  99. package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
  100. package/lib/mjs/components/datagrid/DataGrid.js +0 -3
  101. package/lib/mjs/components/datamap/DataMap.js +2 -6
  102. package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
  103. package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
  104. package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
  105. package/lib/mjs/components/editgrid/EditGrid.js +3 -12
  106. package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
  107. package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
  108. package/lib/mjs/components/file/File.js +7 -2
  109. package/lib/mjs/components/file/editForm/File.edit.file.d.ts +13 -0
  110. package/lib/mjs/components/file/editForm/File.edit.file.js +1 -0
  111. package/lib/mjs/components/form/Form.d.ts +0 -1
  112. package/lib/mjs/components/form/Form.js +18 -22
  113. package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
  114. package/lib/mjs/components/html/HTML.js +1 -2
  115. package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
  116. package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
  117. package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
  118. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
  119. package/lib/mjs/components/radio/Radio.js +1 -1
  120. package/lib/mjs/components/select/Select.js +1 -1
  121. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +68 -110
  122. package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -37
  123. package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -0
  124. package/lib/mjs/components/survey/Survey.js +1 -1
  125. package/lib/mjs/components/tabs/Tabs.js +1 -0
  126. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
  127. package/lib/mjs/components/textarea/TextArea.js +9 -1
  128. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
  129. package/lib/mjs/components/textfield/TextField.js +2 -2
  130. package/lib/mjs/components/unknown/Unknown.form.d.ts +2 -1
  131. package/lib/mjs/components/unknown/Unknown.form.js +13 -9
  132. package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
  133. package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
  134. package/lib/mjs/formio.form.js +1 -1
  135. package/lib/mjs/providers/storage/uploadAdapter.js +5 -3
  136. package/lib/mjs/translations/en.d.ts +1 -234
  137. package/lib/mjs/translations/en.js +5 -47
  138. package/lib/mjs/utils/formUtils.d.ts +2 -2
  139. package/lib/mjs/utils/utils.d.ts +9 -8
  140. package/lib/mjs/utils/utils.js +16 -21
  141. package/lib/mjs/widgets/CalendarWidget.js +7 -2
  142. package/package.json +2 -2
  143. package/lib/cjs/i18n.d.ts +0 -13
  144. package/lib/cjs/i18n.js +0 -19
  145. package/lib/cjs/utils/i18n.d.ts +0 -19
  146. package/lib/cjs/utils/i18n.js +0 -120
  147. package/lib/mjs/i18n.d.ts +0 -13
  148. package/lib/mjs/i18n.js +0 -14
  149. package/lib/mjs/utils/i18n.d.ts +0 -19
  150. package/lib/mjs/utils/i18n.js +0 -112
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  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;
22
- 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;
22
+ exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = 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;
23
23
  const lodash_1 = __importDefault(require("lodash"));
24
24
  exports._ = lodash_1.default;
25
25
  const json_logic_js_1 = __importDefault(require("json-logic-js"));
@@ -34,6 +34,7 @@ const Evaluator_1 = require("./Evaluator");
34
34
  Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
35
35
  const conditionOperators_1 = __importDefault(require("./conditionOperators"));
36
36
  exports.ConditionOperators = conditionOperators_1.default;
37
+ const core_1 = require("@formio/core");
37
38
  const interpolate = Evaluator_1.Evaluator.interpolate;
38
39
  exports.interpolate = interpolate;
39
40
  __exportStar(require("./formUtils"), exports);
@@ -271,7 +272,7 @@ function checkSimpleConditional(component, condition, row, data, instance) {
271
272
  default:
272
273
  result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
273
274
  }
274
- return show ? result : !result;
275
+ return (0, core_1.convertShowToBoolean)(show) ? result : !result;
275
276
  }
276
277
  }
277
278
  exports.checkSimpleConditional = checkSimpleConditional;
@@ -1593,27 +1594,6 @@ function isPromise(value) {
1593
1594
  && Object.prototype.toString.call(value) === '[object Promise]';
1594
1595
  }
1595
1596
  exports.isPromise = isPromise;
1596
- /**
1597
- * Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
1598
- * changes by itself, e.g. EditGrid)
1599
- * @param {Component} componentInstance - The component to check for the scoping parent.
1600
- * @param {boolean} firstPass - Whether it is the first pass of the function
1601
- * @returns {boolean|*} - TRUE if the component has a scoping parent; FALSE otherwise
1602
- */
1603
- function isInsideScopingComponent(componentInstance, firstPass = true) {
1604
- if (!firstPass && (componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.hasScopedChildren)) {
1605
- return true;
1606
- }
1607
- const dataParent = getDataParentComponent(componentInstance);
1608
- if (dataParent === null || dataParent === void 0 ? void 0 : dataParent.hasScopedChildren) {
1609
- return true;
1610
- }
1611
- else if (dataParent === null || dataParent === void 0 ? void 0 : dataParent.parent) {
1612
- return isInsideScopingComponent(dataParent.parent, false);
1613
- }
1614
- return false;
1615
- }
1616
- exports.isInsideScopingComponent = isInsideScopingComponent;
1617
1597
  /**
1618
1598
  * Returns all the focusable elements within the provided dom element.
1619
1599
  * @param {HTMLElement} element - The element to get the focusable elements from.
@@ -1666,3 +1646,18 @@ const interpolateErrors = (component, errors, interpolateFn) => {
1666
1646
  });
1667
1647
  };
1668
1648
  exports.interpolateErrors = interpolateErrors;
1649
+ /**
1650
+ * Checks if a string has timezone information encoded in it
1651
+ * Example: 2024-01-01T00:00:00Z -> true
1652
+ * Example: 2024-01-01T00:00:00+03:00 -> true
1653
+ * Example: 2011-05-03T00:00:00 -> false
1654
+ * @param {string} value the string value to check
1655
+ * @returns {boolean} if value has encoded timezone
1656
+ */
1657
+ function hasEncodedTimezone(value) {
1658
+ if (typeof value !== 'string') {
1659
+ return false;
1660
+ }
1661
+ return (value.substring(value.length - 1) === 'z' || value.substring(value.length - 1) === 'Z' || value.match(/[+|-][0-9]{2}:[0-9]{2}$/));
1662
+ }
1663
+ exports.hasEncodedTimezone = hasEncodedTimezone;
@@ -286,6 +286,11 @@ class CalendarWidget extends InputWidget_1.default {
286
286
  value = value ? (0, utils_1.formatDate)(this.timezonesUrl, value, (0, utils_1.convertFormatToMoment)(this.settings.format), this.timezone, (0, utils_1.convertFormatToMoment)(this.valueMomentFormat)) : value;
287
287
  return super.setValue(value);
288
288
  }
289
+ // If the component is a textfield that does not have timezone information included in the string value then skip
290
+ // the timezone offset
291
+ if (this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value)) {
292
+ this.settings.skipOffset = true;
293
+ }
289
294
  const zonesLoading = this.loadZones();
290
295
  if (value) {
291
296
  if (!saveAsText && this.settings.readOnly && !zonesLoading) {
@@ -453,7 +458,7 @@ class CalendarWidget extends InputWidget_1.default {
453
458
  return (date, format) => {
454
459
  // Only format this if this is the altFormat and the form is readOnly.
455
460
  if (this.settings.readOnly && (format === this.settings.altFormat)) {
456
- if (!this.settings.enableTime || this.loadZones()) {
461
+ if (!this.settings.enableTime || this.loadZones() || this.settings.skipOffset) {
457
462
  return Flatpickr.formatDate(date, format);
458
463
  }
459
464
  const currentValue = new Date(this.getValue());
@@ -170,10 +170,11 @@ export default class Element {
170
170
  /**
171
171
  * Translate a text using the i18n system.
172
172
  * @param {string|Array<string>} text - The i18n identifier.
173
+ * @param {any} data - contextual data object containing data, component, row, etc.
173
174
  * @param {...any} args - The arguments to pass to the i18n translation.
174
175
  * @returns {string} - The translated text.
175
176
  */
176
- t(text: string | Array<string>, ...args: any[]): string;
177
+ t(text: string | Array<string>, data: any, ...args: any[]): string;
177
178
  /**
178
179
  * Alias to create a text node.
179
180
  * @param {string} text - The text to create.
@@ -1,10 +1,11 @@
1
1
  import EventEmitter from './EventEmitter';
2
2
  import { Formio } from './Formio';
3
3
  import * as FormioUtils from './utils/utils';
4
- import { I18n } from './utils/i18n';
4
+ import { I18n } from '@formio/core';
5
5
  import _ from 'lodash';
6
6
  import moment from 'moment';
7
7
  import maskInput from '@formio/vanilla-text-mask';
8
+ import enTranslation from './translations/en';
8
9
  /**
9
10
  * The root component for all elements within the Form.io renderer.
10
11
  */
@@ -38,7 +39,7 @@ export default class Element {
38
39
  if (this.options?.language) {
39
40
  this.options.i18n.language = this.options.language;
40
41
  }
41
- this.options.i18next = this.i18next = this.options.i18next || I18n.init(this.options.i18n);
42
+ this.options.i18next = this.i18next = this.options.i18next || I18n.init({ en: enTranslation, ...this.options.i18n });
42
43
  /**
43
44
  * An instance of the EventEmitter class to handle the emitting and registration of events.
44
45
  * @type {EventEmitter}
@@ -385,11 +386,12 @@ export default class Element {
385
386
  /**
386
387
  * Translate a text using the i18n system.
387
388
  * @param {string|Array<string>} text - The i18n identifier.
389
+ * @param {any} data - contextual data object containing data, component, row, etc.
388
390
  * @param {...any} args - The arguments to pass to the i18n translation.
389
391
  * @returns {string} - The translated text.
390
392
  */
391
- t(text, ...args) {
392
- return this.i18next ? this.i18next.t(text, ...args) : text;
393
+ t(text, data, ...args) {
394
+ return this.i18next ? this.i18next.t(text, data, ...args) : text;
393
395
  }
394
396
  /**
395
397
  * Alias to create a text node.
@@ -45,7 +45,7 @@
45
45
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
46
46
  * @property {boolean} [readOnly] - Set this form to readOnly.
47
47
  * @property {boolean} [noAlerts] - Disable the alerts dialog.
48
- * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
48
+ * @property {{[key: string]: string}} [enTranslation] - The translation file for this rendering.
49
49
  * @property {string} [template] - Custom logic for creation of elements.
50
50
  * @property {boolean} [noDefaults] - Exclude default values from the settings.
51
51
  * @property {any} [fileService] - The file service for this form.
@@ -586,7 +586,7 @@ export type FormOptions = {
586
586
  /**
587
587
  * - The translation file for this rendering.
588
588
  */
589
- i18n?: {
589
+ enTranslation?: {
590
590
  [key: string]: string;
591
591
  } | undefined;
592
592
  /**
@@ -2,7 +2,7 @@ import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import { compareVersions } from 'compare-versions';
4
4
  import EventEmitter from './EventEmitter';
5
- import i18nDefaults from './i18n';
5
+ import enTranslation from './translations/en';
6
6
  import { Formio } from './Formio';
7
7
  import Components from './components/Components';
8
8
  import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
@@ -95,7 +95,7 @@ function getOptions(options) {
95
95
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
96
96
  * @property {boolean} [readOnly] - Set this form to readOnly.
97
97
  * @property {boolean} [noAlerts] - Disable the alerts dialog.
98
- * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
98
+ * @property {{[key: string]: string}} [enTranslation] - The translation file for this rendering.
99
99
  * @property {string} [template] - Custom logic for creation of elements.
100
100
  * @property {boolean} [noDefaults] - Exclude default values from the settings.
101
101
  * @property {any} [fileService] - The file service for this form.
@@ -342,7 +342,7 @@ export default class Webform extends NestedDataComponent {
342
342
  */
343
343
  addLanguage(code, lang, active = false) {
344
344
  if (this.i18next) {
345
- var translations = _.assign(fastCloneDeep(i18nDefaults.resources.en.translation), lang);
345
+ var translations = _.assign(fastCloneDeep(enTranslation), lang);
346
346
  this.i18next.addResourceBundle(code, 'translation', translations, true, true);
347
347
  if (active) {
348
348
  this.language = code;
@@ -659,7 +659,9 @@ export default class Webform extends NestedDataComponent {
659
659
  const rebuild = this.rebuild() || Promise.resolve();
660
660
  return rebuild.then(() => {
661
661
  this.emit('formLoad', form);
662
- this.triggerCaptcha();
662
+ if (!this.options.server) {
663
+ this.triggerCaptcha();
664
+ }
663
665
  // Make sure to trigger onChange after a render event occurs to speed up form rendering.
664
666
  setTimeout(() => {
665
667
  this.onChange(flags);
@@ -1158,11 +1160,8 @@ export default class Webform extends NestedDataComponent {
1158
1160
  };
1159
1161
  errors.forEach(({ message, context, fromServer, component }, index) => {
1160
1162
  const text = !component?.label || context?.hasLabel || fromServer
1161
- ? this.t('alertMessage', { message: this.t(message) })
1162
- : this.t('alertMessageWithLabel', {
1163
- label: this.t(component?.label),
1164
- message: this.t(message),
1165
- });
1163
+ ? this.t(message)
1164
+ : `${this.t(component?.label)}: ${this.t(message)}`;
1166
1165
  displayedErrors.push(createListItem(text, index));
1167
1166
  });
1168
1167
  }
@@ -1325,6 +1324,7 @@ export default class Webform extends NestedDataComponent {
1325
1324
  userAgent: navigator.userAgent,
1326
1325
  pathName: window.location.pathname,
1327
1326
  onLine: navigator.onLine,
1327
+ language: this.language,
1328
1328
  });
1329
1329
  }
1330
1330
  submitForm(options = {}, local = false) {
@@ -1626,7 +1626,11 @@ export default class WebformBuilder extends Component {
1626
1626
  info.type);
1627
1627
  }
1628
1628
  hasEditTabs(type) {
1629
- const editTabs = getComponent(Components.components[type].editForm().components, 'tabs', true).components;
1629
+ // If the component type does not exist then it has no edit tabs
1630
+ if (!Components.components[type === 'custom' ? 'unknown' : type]) {
1631
+ return false;
1632
+ }
1633
+ const editTabs = getComponent(Components.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
1630
1634
  const hiddenEditTabs = _.filter(_.get(this.options, `editForm.${type}`, []), 'ignore');
1631
1635
  return _.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1632
1636
  }
@@ -106,6 +106,7 @@ declare class Wizard extends Webform {
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
108
  focusOnComponent(key: any): void | Promise<void>;
109
+ triggerButtonCaptcha(page: any): void;
109
110
  }
110
111
  declare namespace Wizard {
111
112
  let setBaseUrl: any;
package/lib/mjs/Wizard.js CHANGED
@@ -594,7 +594,7 @@ export default class Wizard extends Webform {
594
594
  }
595
595
  this.redraw().then(() => {
596
596
  this.checkData(this.submission.data);
597
- this.triggerCaptcha(this.currentPanel.components);
597
+ this.triggerCaptcha(this.currentPage.components);
598
598
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
599
599
  if (this.alert) {
600
600
  this.showErrors(errors, true, true);
@@ -660,6 +660,7 @@ export default class Wizard extends Webform {
660
660
  beforeSubmit() {
661
661
  const pages = this.getPages({ all: true });
662
662
  return Promise.all(pages.map((page) => {
663
+ this.triggerButtonCaptcha(page);
663
664
  page.options.beforeSubmit = true;
664
665
  return page.beforeSubmit();
665
666
  }));
@@ -718,7 +719,10 @@ export default class Wizard extends Webform {
718
719
  validateCurrentPage(flags = {}) {
719
720
  const components = this.currentPage?.components.map((component) => component.component);
720
721
  // Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
721
- return this.currentPage?.parent.validateComponents(components, this.root.data, flags);
722
+ if (this.currentPage?.parent) {
723
+ return this.currentPage?.parent.validateComponents(components, this.root.data, flags);
724
+ }
725
+ return this.currentPage?.validateComponents(components, this.root ? this.root.data : this.data, flags);
722
726
  }
723
727
  emitPrevPage() {
724
728
  this.emit('prevPage', { page: this.page, submission: this.submission });
@@ -930,6 +934,22 @@ export default class Wizard extends Webform {
930
934
  }
931
935
  return super.focusOnComponent(key);
932
936
  }
937
+ triggerButtonCaptcha(page) {
938
+ if (!page.components) {
939
+ return;
940
+ }
941
+ let captchaComponent;
942
+ page.eachComponent((component) => {
943
+ if (/^(re)?captcha$/.test(component.component.type) &&
944
+ component.component.eventType === 'buttonClick' &&
945
+ component.component.buttonKey === 'submit') {
946
+ captchaComponent = component;
947
+ }
948
+ });
949
+ if (captchaComponent) {
950
+ captchaComponent.verify(`submitClick`);
951
+ }
952
+ }
933
953
  }
934
954
  Wizard.setBaseUrl = Formio.setBaseUrl;
935
955
  Wizard.setApiUrl = Formio.setApiUrl;
@@ -119,13 +119,6 @@ declare class Component extends Element {
119
119
  */
120
120
  paths: import('@formio/core').ComponentPaths;
121
121
  _path: string;
122
- /**
123
- * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
124
- * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
125
- * conditionallyHidden separately from "regular" visibility.
126
- */
127
- _parentConditionallyHidden: any;
128
- _conditionallyHidden: any;
129
122
  /**
130
123
  * Determines if this component is visible, or not.
131
124
  */
@@ -170,6 +163,18 @@ declare class Component extends Element {
170
163
  */
171
164
  info: any;
172
165
  get componentsMap(): object;
166
+ /**
167
+ * Returns if the parent should conditionally clear.
168
+ *
169
+ * @returns {boolean} - If the parent should conditionally clear.
170
+ */
171
+ parentShouldConditionallyClear(): boolean;
172
+ parentConditionallyHidden(): boolean;
173
+ /**
174
+ * Returns true if any of the parents default their component "hidden" property to true.
175
+ * @returns {boolean} - If any parent defaults the hidden property to true.
176
+ */
177
+ anyParentDefaultsHidden(): boolean;
173
178
  set data(value: any);
174
179
  get data(): any;
175
180
  mergeSchema(component?: {}): any;
@@ -231,14 +236,25 @@ declare class Component extends Element {
231
236
  * @returns {boolean} - Whether the component is visible or not.
232
237
  */
233
238
  get visible(): boolean;
234
- get conditionallyHidden(): any;
239
+ get logicallyHidden(): any;
240
+ _logicallyHidden: any;
235
241
  /**
236
- * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
237
- * @param {object} data - The data object to evaluate the condition against.
238
- * @param {object} row - The row object to evaluate the condition against.
239
- * @returns {boolean} - Whether the component is conditionally hidden.
242
+ * Determines if the component should clear its value when the root form is pristine.
243
+ * @returns {boolean} - If the component should clear its value when the root form is pristine.
240
244
  */
241
- checkConditionallyHidden(data?: object, row?: object): boolean;
245
+ shouldConditionallyClearOnPristine(): boolean;
246
+ /**
247
+ * Returns if the component should clear its value when conditionally hidden.
248
+ * @returns {boolean} - If the component should clear its value when conditionally hidden.
249
+ */
250
+ shouldConditionallyClear(): boolean;
251
+ _conditionallyClear: boolean | undefined;
252
+ /**
253
+ * Returns if the component is conditionally hidden.
254
+ * @returns {boolean} - If the component is conditionally hidden.
255
+ */
256
+ conditionallyHidden(): boolean;
257
+ _conditionallyHidden: boolean | undefined;
242
258
  set currentForm(instance: any);
243
259
  get currentForm(): any;
244
260
  _currentForm: any;
@@ -789,6 +805,10 @@ declare class Component extends Element {
789
805
  * @returns {void}
790
806
  */
791
807
  setElementInvalid(element: HTMLElement, invalid: boolean): void;
808
+ /**
809
+ * Clear any conditionally hidden components for this component only.
810
+ */
811
+ clearComponentOnHide(): void;
792
812
  /**
793
813
  * Clears the components data if it is conditionally hidden AND clearOnHide is set to true for this component.
794
814
  */
@@ -893,7 +913,20 @@ declare class Component extends Element {
893
913
  */
894
914
  deleteValue(): void;
895
915
  getCustomDefaultValue(defaultValue: any): any;
896
- get shouldAddDefaultValue(): any;
916
+ /**
917
+ * Returns if a component has a default value set.
918
+ * @returns {boolean} - TRUE if a default value is set.
919
+ */
920
+ get hasDefaultValue(): boolean;
921
+ /**
922
+ * Determine if we should add a default value for this component.
923
+ * @returns {boolean} - TRUE if a default value should be set
924
+ */
925
+ get shouldAddDefaultValue(): boolean;
926
+ /**
927
+ * Get the default value of this component.
928
+ * @returns {*} - The default value for this component.
929
+ */
897
930
  get defaultValue(): any;
898
931
  /**
899
932
  * Get the input value of this component.
@@ -1003,9 +1036,10 @@ declare class Component extends Element {
1003
1036
  * @param {boolean} dirty - If the component is dirty.
1004
1037
  * @param {boolean} ignoreCondition - If conditions for the component should be ignored when checking validity.
1005
1038
  * @param {*} row - Contextual row data for this component.
1039
+ * @param {*} options - Additional options for validation.
1006
1040
  * @returns {string} - The message to show when the component is invalid.
1007
1041
  */
1008
- invalidMessage(data: any, dirty: boolean, ignoreCondition: boolean, row: any): string;
1042
+ invalidMessage(data: any, dirty: boolean, ignoreCondition: boolean, row: any, options?: any): string;
1009
1043
  /**
1010
1044
  * Returns if the component is valid or not.
1011
1045
  * @param {*} data - The data to check if the component is valid.
@@ -1067,6 +1101,7 @@ declare class Component extends Element {
1067
1101
  * @returns {void|boolean} - TRUE if no check should be performed on the component.
1068
1102
  */
1069
1103
  checkData(data?: any, flags?: any, row?: any): void | boolean;
1104
+ checkingData: boolean | undefined;
1070
1105
  checkModal(errors?: any[], dirty?: boolean): void;
1071
1106
  get validationValue(): any;
1072
1107
  isEmpty(value?: any): any;