@formio/js 5.1.0-dev.6109.79f22ad → 5.1.0-dev.6112.1314654

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 (180) hide show
  1. package/README.md +7 -0
  2. package/dist/formio.builder.css +1 -0
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.form.css +1 -0
  5. package/dist/formio.form.js +119 -152
  6. package/dist/formio.form.min.css +1 -1
  7. package/dist/formio.form.min.js +1 -1
  8. package/dist/formio.full.css +1 -0
  9. package/dist/formio.full.js +126 -159
  10. package/dist/formio.full.min.css +1 -1
  11. package/dist/formio.full.min.js +1 -1
  12. package/dist/formio.js +66 -55
  13. package/dist/formio.min.js +1 -1
  14. package/dist/formio.utils.js +76 -76
  15. package/dist/formio.utils.min.js +1 -1
  16. package/lib/cjs/Element.d.ts +2 -1
  17. package/lib/cjs/Element.js +18 -39
  18. package/lib/cjs/EventEmitter.js +2 -25
  19. package/lib/cjs/Form.js +2 -25
  20. package/lib/cjs/PDF.js +1 -1
  21. package/lib/cjs/PDFBuilder.d.ts +1 -0
  22. package/lib/cjs/PDFBuilder.js +10 -11
  23. package/lib/cjs/Webform.d.ts +2 -2
  24. package/lib/cjs/Webform.js +10 -10
  25. package/lib/cjs/WebformBuilder.d.ts +1 -1
  26. package/lib/cjs/WebformBuilder.js +45 -21
  27. package/lib/cjs/Wizard.d.ts +1 -2
  28. package/lib/cjs/Wizard.js +18 -24
  29. package/lib/cjs/WizardBuilder.js +1 -1
  30. package/lib/cjs/components/Components.js +7 -1
  31. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  32. package/lib/cjs/components/_classes/component/Component.js +70 -64
  33. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  34. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
  35. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
  36. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  37. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  38. package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
  39. package/lib/cjs/components/_classes/input/Input.js +3 -3
  40. package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
  41. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
  42. package/lib/cjs/components/_classes/nested/NestedComponent.js +19 -9
  43. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  44. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  45. package/lib/cjs/components/address/Address.js +2 -2
  46. package/lib/cjs/components/alert/Alert.js +1 -1
  47. package/lib/cjs/components/button/Button.js +1 -1
  48. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  49. package/lib/cjs/components/container/Container.js +1 -1
  50. package/lib/cjs/components/currency/Currency.js +1 -1
  51. package/lib/cjs/components/datagrid/DataGrid.js +5 -1
  52. package/lib/cjs/components/datamap/DataMap.js +7 -2
  53. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  54. package/lib/cjs/components/datetime/DateTime.js +15 -13
  55. package/lib/cjs/components/day/Day.js +2 -2
  56. package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
  57. package/lib/cjs/components/editgrid/EditGrid.js +1 -9
  58. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  59. package/lib/cjs/components/fieldset/Fieldset.js +1 -0
  60. package/lib/cjs/components/file/File.js +1 -1
  61. package/lib/cjs/components/form/Form.js +14 -2
  62. package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
  63. package/lib/cjs/components/number/Number.js +1 -1
  64. package/lib/cjs/components/panel/Panel.js +1 -1
  65. package/lib/cjs/components/radio/Radio.d.ts +9 -0
  66. package/lib/cjs/components/radio/Radio.js +20 -10
  67. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  68. package/lib/cjs/components/select/Select.js +7 -3
  69. package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
  70. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  71. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  72. package/lib/cjs/components/signature/Signature.js +1 -1
  73. package/lib/cjs/components/survey/Survey.js +1 -1
  74. package/lib/cjs/components/tags/Tags.js +1 -1
  75. package/lib/cjs/components/textarea/TextArea.js +9 -4
  76. package/lib/cjs/components/textfield/TextField.js +13 -31
  77. package/lib/cjs/components/time/Time.js +1 -1
  78. package/lib/cjs/formio.form.js +5 -5
  79. package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
  80. package/lib/cjs/providers/storage/url.js +7 -3
  81. package/lib/cjs/translations/en.d.ts +1 -232
  82. package/lib/cjs/translations/en.js +4 -2
  83. package/lib/cjs/utils/Evaluator.d.ts +20 -6
  84. package/lib/cjs/utils/Evaluator.js +38 -15
  85. package/lib/cjs/utils/builder.js +5 -5
  86. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  87. package/lib/cjs/utils/formUtils.d.ts +2 -2
  88. package/lib/cjs/utils/index.d.ts +169 -2
  89. package/lib/cjs/utils/index.js +22 -2
  90. package/lib/cjs/utils/utils.d.ts +22 -37
  91. package/lib/cjs/utils/utils.js +63 -138
  92. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
  93. package/lib/cjs/widgets/CalendarWidget.js +17 -43
  94. package/lib/mjs/Element.d.ts +2 -1
  95. package/lib/mjs/Element.js +11 -9
  96. package/lib/mjs/EventEmitter.js +2 -2
  97. package/lib/mjs/Form.js +1 -1
  98. package/lib/mjs/PDF.js +1 -1
  99. package/lib/mjs/PDFBuilder.d.ts +1 -0
  100. package/lib/mjs/PDFBuilder.js +9 -10
  101. package/lib/mjs/Webform.d.ts +2 -2
  102. package/lib/mjs/Webform.js +8 -8
  103. package/lib/mjs/WebformBuilder.d.ts +1 -1
  104. package/lib/mjs/WebformBuilder.js +36 -13
  105. package/lib/mjs/Wizard.d.ts +1 -2
  106. package/lib/mjs/Wizard.js +17 -23
  107. package/lib/mjs/WizardBuilder.js +1 -1
  108. package/lib/mjs/components/Components.js +7 -1
  109. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  110. package/lib/mjs/components/_classes/component/Component.js +42 -13
  111. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  112. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
  113. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
  114. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  115. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  116. package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
  117. package/lib/mjs/components/_classes/input/Input.js +3 -3
  118. package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
  119. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
  120. package/lib/mjs/components/_classes/nested/NestedComponent.js +19 -9
  121. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  122. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  123. package/lib/mjs/components/address/Address.js +2 -2
  124. package/lib/mjs/components/alert/Alert.js +1 -1
  125. package/lib/mjs/components/button/Button.js +1 -1
  126. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  127. package/lib/mjs/components/container/Container.js +1 -1
  128. package/lib/mjs/components/currency/Currency.js +1 -1
  129. package/lib/mjs/components/datagrid/DataGrid.js +5 -1
  130. package/lib/mjs/components/datamap/DataMap.js +7 -2
  131. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  132. package/lib/mjs/components/datetime/DateTime.js +15 -13
  133. package/lib/mjs/components/day/Day.js +2 -2
  134. package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
  135. package/lib/mjs/components/editgrid/EditGrid.js +1 -9
  136. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  137. package/lib/mjs/components/fieldset/Fieldset.js +1 -0
  138. package/lib/mjs/components/file/File.js +1 -1
  139. package/lib/mjs/components/form/Form.js +13 -2
  140. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
  141. package/lib/mjs/components/number/Number.js +1 -1
  142. package/lib/mjs/components/panel/Panel.js +1 -1
  143. package/lib/mjs/components/radio/Radio.d.ts +9 -0
  144. package/lib/mjs/components/radio/Radio.js +20 -10
  145. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  146. package/lib/mjs/components/select/Select.js +7 -3
  147. package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
  148. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  149. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  150. package/lib/mjs/components/signature/Signature.js +1 -1
  151. package/lib/mjs/components/survey/Survey.js +1 -1
  152. package/lib/mjs/components/tags/Tags.js +1 -1
  153. package/lib/mjs/components/textarea/TextArea.js +9 -4
  154. package/lib/mjs/components/textfield/TextField.js +7 -2
  155. package/lib/mjs/components/time/Time.js +1 -1
  156. package/lib/mjs/formio.form.js +3 -3
  157. package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
  158. package/lib/mjs/providers/storage/url.js +7 -3
  159. package/lib/mjs/translations/en.d.ts +1 -232
  160. package/lib/mjs/translations/en.js +8 -47
  161. package/lib/mjs/utils/Evaluator.d.ts +20 -6
  162. package/lib/mjs/utils/Evaluator.js +31 -13
  163. package/lib/mjs/utils/builder.js +1 -1
  164. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  165. package/lib/mjs/utils/formUtils.d.ts +2 -2
  166. package/lib/mjs/utils/index.d.ts +169 -2
  167. package/lib/mjs/utils/index.js +18 -1
  168. package/lib/mjs/utils/utils.d.ts +22 -37
  169. package/lib/mjs/utils/utils.js +57 -113
  170. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
  171. package/lib/mjs/widgets/CalendarWidget.js +17 -43
  172. package/package.json +5 -3
  173. package/lib/cjs/i18n.d.ts +0 -13
  174. package/lib/cjs/i18n.js +0 -19
  175. package/lib/cjs/utils/i18n.d.ts +0 -19
  176. package/lib/cjs/utils/i18n.js +0 -120
  177. package/lib/mjs/i18n.d.ts +0 -13
  178. package/lib/mjs/i18n.js +0 -14
  179. package/lib/mjs/utils/i18n.d.ts +0 -19
  180. package/lib/mjs/utils/i18n.js +0 -112
@@ -1,8 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import { Formio } from './Formio';
3
3
  import WebformBuilder from './WebformBuilder';
4
- import { fastCloneDeep, getElementRect, getBrowserInfo } from './utils/utils';
5
- import { eachComponent } from './utils/formUtils';
4
+ import { fastCloneDeep, getElementRect, getBrowserInfo, eachComponent } from './utils';
6
5
  import BuilderUtils from './utils/builder';
7
6
  import PDF from './PDF';
8
7
  export default class PDFBuilder extends WebformBuilder {
@@ -445,21 +444,21 @@ export default class PDFBuilder extends WebformBuilder {
445
444
  e.target.style.cursor = 'default';
446
445
  }
447
446
  highlightInvalidComponents() {
448
- const repeatablePaths = this.findRepeatablePaths();
447
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
449
448
  // update elements which path was duplicated if any pathes have been changed
450
- if (!_.isEqual(this.repeatablePaths, repeatablePaths)) {
451
- eachComponent(this.webform.getComponents(), (comp, path) => {
452
- if (this.repeatablePaths.includes(path)) {
449
+ if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
450
+ eachComponent(this.webform.getComponents(), (comp) => {
451
+ if (this.repeatablePathsComps.includes(comp.component)) {
453
452
  this.webform.postMessage({ name: 'updateElement', data: comp.component });
454
453
  }
455
454
  });
456
- this.repeatablePaths = repeatablePaths;
455
+ this.repeatablePathsComps = repeatablePathsComps;
457
456
  }
458
- if (!repeatablePaths.length) {
457
+ if (!repeatablePathsComps.length) {
459
458
  return;
460
459
  }
461
- eachComponent(this.webform.getComponents(), (comp, path) => {
462
- if (this.repeatablePaths.includes(path)) {
460
+ eachComponent(this.webform.getComponents(), (comp) => {
461
+ if (this.repeatablePathsComps.includes(comp)) {
463
462
  this.webform.postMessage({
464
463
  name: 'showBuilderErrors',
465
464
  data: {
@@ -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
  /**
@@ -1,13 +1,12 @@
1
1
  import _ from 'lodash';
2
- import moment from 'moment';
3
2
  import { compareVersions } from 'compare-versions';
4
3
  import EventEmitter from './EventEmitter';
5
- import i18nDefaults from './i18n';
4
+ import enTranslation from './translations/en';
6
5
  import { Formio } from './Formio';
7
6
  import Components from './components/Components';
8
7
  import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
9
- import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils/utils';
10
- import { eachComponent } from './utils/formUtils';
8
+ import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, eachComponent } from './utils';
9
+ import dayjs from "dayjs";
11
10
  // We need this here because dragula pulls in CustomEvent class that requires global to exist.
12
11
  if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
13
12
  window.global = window;
@@ -95,7 +94,7 @@ function getOptions(options) {
95
94
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
96
95
  * @property {boolean} [readOnly] - Set this form to readOnly.
97
96
  * @property {boolean} [noAlerts] - Disable the alerts dialog.
98
- * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
97
+ * @property {{[key: string]: string}} [enTranslation] - The translation file for this rendering.
99
98
  * @property {string} [template] - Custom logic for creation of elements.
100
99
  * @property {boolean} [noDefaults] - Exclude default values from the settings.
101
100
  * @property {any} [fileService] - The file service for this form.
@@ -342,7 +341,7 @@ export default class Webform extends NestedDataComponent {
342
341
  */
343
342
  addLanguage(code, lang, active = false) {
344
343
  if (this.i18next) {
345
- var translations = _.assign(fastCloneDeep(i18nDefaults.resources.en.translation), lang);
344
+ var translations = _.assign(fastCloneDeep(enTranslation), lang);
346
345
  this.i18next.addResourceBundle(code, 'translation', translations, true, true);
347
346
  if (active) {
348
347
  this.language = code;
@@ -1122,7 +1121,7 @@ export default class Webform extends NestedDataComponent {
1122
1121
  // Mark any components as invalid if in a custom message.
1123
1122
  const componentErrors = {};
1124
1123
  errors.forEach((err) => {
1125
- const path = err.path || err.context?.path || err.component?.key;
1124
+ const path = getStringFromComponentPath(err.path) || err.context?.path || err.component?.key;
1126
1125
  if (!componentErrors[path]) {
1127
1126
  componentErrors[path] = [];
1128
1127
  }
@@ -1317,13 +1316,14 @@ export default class Webform extends NestedDataComponent {
1317
1316
  submission.metadata = submission.metadata || {};
1318
1317
  _.defaults(submission.metadata, {
1319
1318
  timezone: _.get(this, '_submission.metadata.timezone', currentTimezone()),
1320
- offset: parseInt(_.get(this, '_submission.metadata.offset', moment().utcOffset()), 10),
1319
+ offset: parseInt(_.get(this, '_submission.metadata.offset', dayjs().utcOffset()), 10),
1321
1320
  origin: document.location.origin,
1322
1321
  referrer: document.referrer,
1323
1322
  browserName: navigator.appName,
1324
1323
  userAgent: navigator.userAgent,
1325
1324
  pathName: window.location.pathname,
1326
1325
  onLine: navigator.onLine,
1326
+ language: this.language,
1327
1327
  });
1328
1328
  }
1329
1329
  submitForm(options = {}, local = false) {
@@ -78,7 +78,7 @@ export default class WebformBuilder extends Component {
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
80
  originalDefaultValue: any;
81
- findRepeatablePaths(): any[];
81
+ findComponentsWithRepeatablePaths(): any[];
82
82
  highlightInvalidComponents(): void;
83
83
  /**
84
84
  * Called when a new component is saved.
@@ -3,8 +3,7 @@ import Component from './components/_classes/component/Component';
3
3
  import tippy from 'tippy.js';
4
4
  import Components from './components/Components';
5
5
  import { Formio } from './Formio';
6
- import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath } from './utils/utils';
7
- import { eachComponent, getComponent } from './utils/formUtils';
6
+ import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, componentInfo } from './utils';
8
7
  import BuilderUtils from './utils/builder';
9
8
  import _ from 'lodash';
10
9
  import autoScroll from 'dom-autoscroller';
@@ -1109,28 +1108,52 @@ export default class WebformBuilder extends Component {
1109
1108
  // Called when we update a component.
1110
1109
  this.emit('updateComponent', component);
1111
1110
  }
1112
- findRepeatablePaths() {
1113
- const repeatablePaths = [];
1111
+ findComponentsWithRepeatablePaths() {
1112
+ const repeatablePaths = {};
1114
1113
  const keys = new Map();
1115
1114
  eachComponent(this.form.components, (comp, path, components, parent, paths) => {
1116
- if (keys.has(paths.dataPath)) {
1117
- repeatablePaths.push(paths.dataPath);
1118
- }
1119
- else {
1120
- keys.set(paths.dataPath, true);
1115
+ const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1116
+ const isLayout = componentInfo(comp).layout;
1117
+ if (!isLayout) {
1118
+ if (keys.has(paths.dataPath)) {
1119
+ const onlyRadioCheckboxes = repeatablePaths[paths.dataPath]?.onlyRadioCheckboxes === false ? false : isRadioCheckbox;
1120
+ repeatablePaths[paths.dataPath] = {
1121
+ comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
1122
+ onlyRadioCheckboxes,
1123
+ };
1124
+ }
1125
+ else {
1126
+ keys.set(paths.dataPath, comp);
1127
+ }
1121
1128
  }
1122
1129
  }, true);
1123
- return repeatablePaths;
1130
+ const componentsWithRepeatablePaths = [];
1131
+ Object.keys(repeatablePaths).forEach((path) => {
1132
+ const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
1133
+ if (!onlyRadioCheckboxes) {
1134
+ componentsWithRepeatablePaths.push(...comps);
1135
+ }
1136
+ });
1137
+ return componentsWithRepeatablePaths;
1124
1138
  }
1125
1139
  highlightInvalidComponents() {
1126
- const repeatablePaths = this.findRepeatablePaths();
1140
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
1127
1141
  let hasInvalidComponents = false;
1142
+ // Matches anything expect letters and '_' at the beginning of the key and anything except of letters, numbers,
1143
+ // '-', '.' and '_' in the rest of the key
1144
+ const badCharacters = /^[^A-Za-z_]+|[^A-Za-z0-9\-._]+/g;
1128
1145
  this.webform.everyComponent((comp) => {
1129
- const path = comp.path;
1130
- if (repeatablePaths.includes(path)) {
1146
+ if (repeatablePathsComps.includes(comp.component)) {
1131
1147
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1132
1148
  hasInvalidComponents = true;
1133
1149
  }
1150
+ else if (comp.key.replace(badCharacters, '') === '') {
1151
+ comp.setCustomValidity(this.t('apiKeyNotValid', { key: comp.key }));
1152
+ hasInvalidComponents = true;
1153
+ }
1154
+ else {
1155
+ comp.setCustomValidity();
1156
+ }
1134
1157
  });
1135
1158
  this.emit('builderFormValidityChange', hasInvalidComponents);
1136
1159
  }
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
6
6
  originalComponents: any[];
7
7
  page: number;
8
8
  currentPanel: any;
9
- currentPanels: any[] | null;
10
9
  currentNextPage: number;
11
10
  _seenPages: number[];
12
11
  subWizards: any[];
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
17
16
  originalOptions: any;
18
17
  isLastPage(): any;
19
18
  getPages(args?: {}): any[];
20
- get hasExtraPages(): boolean;
19
+ get hasSubWizards(): boolean;
21
20
  get localData(): any;
22
21
  get wizardKey(): string;
23
22
  set wizard(form: object);
package/lib/mjs/Wizard.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import Webform from './Webform';
3
3
  import { Formio } from './Formio';
4
- import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils/utils';
4
+ import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils';
5
5
  export default class Wizard extends Webform {
6
6
  /**
7
7
  * Constructor for wizard-based forms.
@@ -29,7 +29,6 @@ export default class Wizard extends Webform {
29
29
  this.originalComponents = [];
30
30
  this.page = 0;
31
31
  this.currentPanel = null;
32
- this.currentPanels = null;
33
32
  this.currentNextPage = 0;
34
33
  this._seenPages = [0];
35
34
  this.subWizards = [];
@@ -48,12 +47,12 @@ export default class Wizard extends Webform {
48
47
  }
49
48
  getPages(args = {}) {
50
49
  const { all = false } = args;
51
- const pages = this.hasExtraPages ? this.components : this.pages;
50
+ const pages = this.hasSubWizards ? this.components : this.pages;
52
51
  const filteredPages = pages
53
52
  .filter(all ? _.identity : (p, index) => this._seenPages.includes(index));
54
53
  return filteredPages;
55
54
  }
56
- get hasExtraPages() {
55
+ get hasSubWizards() {
57
56
  return !_.isEmpty(this.subWizards);
58
57
  }
59
58
  get data() {
@@ -177,9 +176,9 @@ export default class Wizard extends Webform {
177
176
  }
178
177
  render() {
179
178
  const ctx = this.renderContext;
180
- if (this.component.key) {
181
- ctx.panels.map(panel => {
182
- if (panel.key === this.component.key) {
179
+ if (this.component.id) {
180
+ ctx.panels.forEach(panel => {
181
+ if (panel.id === this.component.id) {
183
182
  this.currentPanel = panel;
184
183
  ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
185
184
  }
@@ -580,7 +579,7 @@ export default class Wizard extends Webform {
580
579
  this.pageFieldLogic(num);
581
580
  this.getNextPage();
582
581
  let parentNum = num;
583
- if (this.hasExtraPages) {
582
+ if (this.hasSubWizards) {
584
583
  const pageFromPages = this.pages[num];
585
584
  const pageFromComponents = this.components[num];
586
585
  if (!pageFromComponents || pageFromPages?.id !== pageFromComponents.id) {
@@ -869,23 +868,18 @@ export default class Wizard extends Webform {
869
868
  this.showErrors(errors, true, true);
870
869
  }
871
870
  // If the pages change, need to redraw the header.
872
- let currentPanels;
873
- let panels;
871
+ const currentPanels = this.pages;
872
+ // calling this.establishPages() updates/mutates this.pages to be the current pages
873
+ this.establishPages();
874
+ const newPanels = this.pages;
874
875
  const currentNextPage = this.currentNextPage;
875
- if (this.hasExtraPages) {
876
- currentPanels = this.pages.map(page => page.component.key);
877
- this.establishPages();
878
- panels = this.pages.map(page => page.component.key);
879
- }
880
- else {
881
- currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
882
- panels = this.establishPages().map(panel => panel.key);
883
- this.currentPanels = panels;
884
- if (this.currentPanel?.key && this.currentPanels?.length) {
885
- this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
886
- }
876
+ const panelsUpdated = !_.isEqual(newPanels, currentPanels);
877
+ if (this.currentPanel?.id && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
878
+ const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
879
+ if (newIndex !== -1)
880
+ this.setPage(newIndex);
887
881
  }
888
- if (!_.isEqual(panels, currentPanels) || (flags && flags.fromSubmission)) {
882
+ if (panelsUpdated || (flags && flags.fromSubmission)) {
889
883
  this.redrawHeader();
890
884
  }
891
885
  // If the next page changes, then make sure to redraw navigation.
@@ -2,7 +2,7 @@ import WebformBuilder from './WebformBuilder';
2
2
  import Webform from './Webform';
3
3
  import BuilderUtils from './utils/builder';
4
4
  import _ from 'lodash';
5
- import { fastCloneDeep } from './utils/utils';
5
+ import { fastCloneDeep } from './utils';
6
6
  export default class WizardBuilder extends WebformBuilder {
7
7
  constructor() {
8
8
  let element, options;
@@ -54,7 +54,7 @@ export default class Components {
54
54
  // eslint-disable-next-line new-cap
55
55
  comp = new Components.components['datagrid'](component, options, data);
56
56
  }
57
- else if (component.tree) {
57
+ else if (component.tree || (component.input && Array.isArray(component.components))) {
58
58
  // eslint-disable-next-line new-cap
59
59
  comp = new Components.components['nesteddata'](component, options, data);
60
60
  }
@@ -72,6 +72,12 @@ export default class Components {
72
72
  if (comp.path) {
73
73
  comp.componentsMap[comp.path] = comp;
74
74
  }
75
+ // Reset the componentMatches on the root element if any new component is created.
76
+ let parent = comp.parent;
77
+ while (parent) {
78
+ parent.componentMatches = {};
79
+ parent = parent.parent;
80
+ }
75
81
  return comp;
76
82
  }
77
83
  }
@@ -165,7 +165,6 @@ declare class Component extends Element {
165
165
  get componentsMap(): object;
166
166
  /**
167
167
  * Returns if the parent should conditionally clear.
168
- *
169
168
  * @returns {boolean} - If the parent should conditionally clear.
170
169
  */
171
170
  parentShouldConditionallyClear(): boolean;
@@ -5,8 +5,8 @@ import _ from 'lodash';
5
5
  import isMobile from 'ismobilejs';
6
6
  import { processOne, processOneSync, validateProcessInfo } from '@formio/core/process';
7
7
  import { Formio } from '../../../Formio';
8
- import * as FormioUtils from '../../../utils/utils';
9
- import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils/utils';
8
+ import FormioUtils from '../../../utils';
9
+ import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils';
10
10
  import Element from '../../../Element';
11
11
  import ComponentModal from '../componentModal/ComponentModal';
12
12
  import Widgets from '../../../widgets';
@@ -424,7 +424,6 @@ export default class Component extends Element {
424
424
  }
425
425
  /**
426
426
  * Returns if the parent should conditionally clear.
427
- *
428
427
  * @returns {boolean} - If the parent should conditionally clear.
429
428
  */
430
429
  parentShouldConditionallyClear() {
@@ -1161,9 +1160,15 @@ export default class Component extends Element {
1161
1160
  if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
1162
1161
  modalLabel = { className: 'field-required' };
1163
1162
  }
1163
+ let messages = '';
1164
+ if (this.errors?.length) {
1165
+ messages = this.errors.map((err) => {
1166
+ return err.level === 'error' ? this.renderTemplate('message', { ...err }) : '';
1167
+ }).join('');
1168
+ }
1164
1169
  return this.renderModalPreview({
1165
1170
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('clickToSetValue'),
1166
- messages: '',
1171
+ messages,
1167
1172
  labelInfo: modalLabel,
1168
1173
  });
1169
1174
  }
@@ -2365,12 +2370,14 @@ export default class Component extends Element {
2365
2370
  ckeditor: {
2366
2371
  image: {
2367
2372
  toolbar: [
2373
+ 'toggleImageCaption',
2368
2374
  'imageTextAlternative',
2369
2375
  '|',
2370
- 'imageStyle:full',
2371
- 'imageStyle:alignLeft',
2372
- 'imageStyle:alignCenter',
2373
- 'imageStyle:alignRight'
2376
+ 'imageStyle:inline',
2377
+ 'imageStyle:wrapText',
2378
+ 'imageStyle:breakText',
2379
+ '|',
2380
+ 'resizeImage'
2374
2381
  ],
2375
2382
  styles: [
2376
2383
  'full',
@@ -2392,7 +2399,10 @@ export default class Component extends Element {
2392
2399
  if (this.component.isUploadEnabled) {
2393
2400
  settings.extraPlugins.push(getFormioUploadAdapterPlugin(this.fileService, this));
2394
2401
  }
2395
- return Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', _.get(this.options, 'editors.ckeditor.src', `${Formio.cdn.ckeditor}/ckeditor.js`), true)
2402
+ Formio.requireLibrary(`ckeditor-css`, isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', [
2403
+ { type: 'styles', src: `${Formio.cdn.ckeditor}/ckeditor.css` }
2404
+ ], true);
2405
+ return Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', _.get(this.options, 'editors.ckeditor.src', `${Formio.cdn.ckeditor}/ckeditor.umd.js`), true)
2396
2406
  .then(() => {
2397
2407
  if (!element.parentNode) {
2398
2408
  return Promise.reject();
@@ -2578,6 +2588,17 @@ export default class Component extends Element {
2578
2588
  noUpdateEvent: true,
2579
2589
  noDefault: true
2580
2590
  });
2591
+ if (FormioUtils.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
2592
+ FormioUtils.eachComponent(this.components, (component) => {
2593
+ if (component.component.clearOnHide !== false) {
2594
+ component.setValue(null, {
2595
+ noUpdateEvent: true,
2596
+ noDefault: true
2597
+ });
2598
+ component.unset();
2599
+ }
2600
+ });
2601
+ }
2581
2602
  this.unset();
2582
2603
  }
2583
2604
  getCustomDefaultValue(defaultValue) {
@@ -2683,13 +2704,16 @@ export default class Component extends Element {
2683
2704
  }
2684
2705
  const isArray = Array.isArray(value);
2685
2706
  const valueInput = this.refs.fileLink || this.refs.input;
2707
+ const isFilelink = !!this.refs.fileLink;
2686
2708
  if (isArray &&
2687
2709
  Array.isArray(this.defaultValue) &&
2688
2710
  this.refs.hasOwnProperty('input') &&
2689
2711
  valueInput &&
2690
2712
  (valueInput.length !== value.length) &&
2691
2713
  this.visible) {
2692
- this.redraw();
2714
+ if (isFilelink || valueInput.length) {
2715
+ this.redraw();
2716
+ }
2693
2717
  }
2694
2718
  if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
2695
2719
  this.redraw();
@@ -2700,6 +2724,11 @@ export default class Component extends Element {
2700
2724
  this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2701
2725
  }
2702
2726
  }
2727
+ // Also reset value of the modal component, otherwise it will keep the old value locally and the preview
2728
+ // element won't refresh
2729
+ if (this.componentModal && flags && flags.resetValue) {
2730
+ this.componentModal.setValue(value);
2731
+ }
2703
2732
  return changed;
2704
2733
  }
2705
2734
  /**
@@ -3196,6 +3225,9 @@ export default class Component extends Element {
3196
3225
  data = data || this.rootValue;
3197
3226
  flags = flags || {};
3198
3227
  row = row || this.data;
3228
+ if (flags.noCheck) {
3229
+ return true;
3230
+ }
3199
3231
  // Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
3200
3232
  // as setValue. Historically, this was bypassed by a series of cached states around the data model
3201
3233
  // which caused its own problems. We need to ensure that premium and custom components do not fall into
@@ -3210,9 +3242,6 @@ export default class Component extends Element {
3210
3242
  if (!flags.fromBlur) {
3211
3243
  this.checkRefreshOn(flags.changes, flags);
3212
3244
  }
3213
- if (flags.noCheck) {
3214
- return true;
3215
- }
3216
3245
  this.checkComponentConditions(data, flags, row);
3217
3246
  if (this.id !== flags.triggeredComponentId) {
3218
3247
  this.calculateComponentValue(data, flags, row);
@@ -1,5 +1,5 @@
1
1
  import EditFormUtils from './utils';
2
- import { getContextComponents } from '../../../../utils/utils';
2
+ import { getContextComponents } from '../../../../utils';
3
3
  /* eslint-disable quotes, max-len */
4
4
  export default [
5
5
  {
@@ -82,6 +82,7 @@ declare const _default: ({
82
82
  inline?: undefined;
83
83
  defaultValue?: undefined;
84
84
  values?: undefined;
85
+ customConditional?: undefined;
85
86
  logic?: undefined;
86
87
  dataSrc?: undefined;
87
88
  valueProperty?: undefined;
@@ -101,6 +102,7 @@ declare const _default: ({
101
102
  inline?: undefined;
102
103
  defaultValue?: undefined;
103
104
  values?: undefined;
105
+ customConditional?: undefined;
104
106
  logic?: undefined;
105
107
  dataSrc?: undefined;
106
108
  valueProperty?: undefined;
@@ -126,6 +128,7 @@ declare const _default: ({
126
128
  value: string;
127
129
  })[];
128
130
  placeholder?: undefined;
131
+ customConditional?: undefined;
129
132
  logic?: undefined;
130
133
  dataSrc?: undefined;
131
134
  valueProperty?: undefined;
@@ -141,6 +144,7 @@ declare const _default: ({
141
144
  tooltip: string;
142
145
  key: string;
143
146
  input: boolean;
147
+ customConditional: string;
144
148
  logic: ({
145
149
  name: string;
146
150
  trigger: {
@@ -211,6 +215,7 @@ declare const _default: ({
211
215
  inline?: undefined;
212
216
  defaultValue?: undefined;
213
217
  values?: undefined;
218
+ customConditional?: undefined;
214
219
  logic?: undefined;
215
220
  as?: undefined;
216
221
  editor?: undefined;
@@ -226,6 +231,7 @@ declare const _default: ({
226
231
  placeholder?: undefined;
227
232
  inline?: undefined;
228
233
  values?: undefined;
234
+ customConditional?: undefined;
229
235
  logic?: undefined;
230
236
  dataSrc?: undefined;
231
237
  valueProperty?: undefined;
@@ -248,6 +254,7 @@ declare const _default: ({
248
254
  placeholder?: undefined;
249
255
  inline?: undefined;
250
256
  values?: undefined;
257
+ customConditional?: undefined;
251
258
  logic?: undefined;
252
259
  dataSrc?: undefined;
253
260
  valueProperty?: undefined;
@@ -56,6 +56,7 @@ export default [
56
56
  tooltip: 'Encrypt this field on the server. This is two way encryption which is not suitable for passwords.',
57
57
  key: 'encrypted',
58
58
  input: true,
59
+ customConditional: 'show = data.encrypted;',
59
60
  logic: [
60
61
  {
61
62
  name: 'disabled',
@@ -1,5 +1,5 @@
1
1
  import EditFormUtils from './utils';
2
- import { getContextComponents } from '../../../../utils/utils';
2
+ import { getContextComponents } from '../../../../utils';
3
3
  /* eslint-disable quotes, max-len */
4
4
  export default [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { fastCloneDeep } from '../../../utils/utils';
2
+ import { fastCloneDeep } from '../../../utils';
3
3
  export default class ComponentModal {
4
4
  static render(component, data, topLevel) {
5
5
  const children = component.renderTemplate('component', data, topLevel);
@@ -25,7 +25,7 @@ export default class Input extends Multivalue {
25
25
  get suffix(): any;
26
26
  renderElement(value: any, index: any): any;
27
27
  setCounter(type: any, element: any, count: any, max: any): void;
28
- updateValueAt(value: any, flags: any, index: any): void;
28
+ updateValueAt(value: any, flags: any, index?: number): void;
29
29
  getValueAt(index: any): any;
30
30
  updateValue(value: any, flags: any, index: any): boolean;
31
31
  parseValue(value: any): any;
@@ -1,5 +1,5 @@
1
1
  import Multivalue from '../multivalue/Multivalue';
2
- import { convertStringToHTMLElement } from '../../../utils/utils';
2
+ import { convertStringToHTMLElement } from '../../../utils';
3
3
  import Widgets from '../../../widgets';
4
4
  import _ from 'lodash';
5
5
  export default class Input extends Multivalue {
@@ -113,7 +113,7 @@ export default class Input extends Multivalue {
113
113
  }
114
114
  const info = this.inputInfo;
115
115
  info.attr = info.attr || {};
116
- info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(value)))
116
+ info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(this.isMultipleMasksField ? value.value : value)))
117
117
  .replace(/"/g, '"');
118
118
  const valueMask = this.component.inputMask;
119
119
  const displayMask = this.component.displayMask;
@@ -158,7 +158,7 @@ export default class Input extends Multivalue {
158
158
  }));
159
159
  }
160
160
  }
161
- updateValueAt(value, flags, index) {
161
+ updateValueAt(value, flags, index = 0) {
162
162
  flags = flags || {};
163
163
  if (_.get(this.component, 'showWordCount', false)) {
164
164
  if (this.refs.wordcount && this.refs.wordcount[index]) {
@@ -1,7 +1,7 @@
1
1
  import Field from '../field/Field';
2
2
  import { Formio } from '../../../Formio';
3
3
  import _ from 'lodash';
4
- import { getItemTemplateKeys } from '../../../utils/utils';
4
+ import { getItemTemplateKeys } from '../../../utils';
5
5
  export default class ListComponent extends Field {
6
6
  static schema(...extend) {
7
7
  return Field.schema({
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
108
108
  * @returns {any} - The component that is located.
109
109
  */
110
110
  getComponent(path: string): any;
111
+ componentMatches: {} | undefined;
111
112
  /**
112
113
  * Return a component provided the Id of the component.
113
114
  * @param {string} id - The Id of the component.