@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
@@ -7,7 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
7
7
  const Field_1 = __importDefault(require("../field/Field"));
8
8
  const Components_1 = __importDefault(require("../../Components"));
9
9
  '';
10
- const utils_1 = require("../../../utils/utils");
10
+ const utils_1 = __importDefault(require("../../../utils"));
11
11
  const process_1 = require("@formio/core/process");
12
12
  /**
13
13
  * NestedComponent class.
@@ -209,7 +209,7 @@ class NestedComponent extends Field_1.default {
209
209
  set rowIndex(value) {
210
210
  var _a, _b;
211
211
  this._rowIndex = value;
212
- this.paths = (0, utils_1.getComponentPaths)(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
212
+ this.paths = utils_1.default.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
213
213
  this.eachComponent((component) => {
214
214
  component.rowIndex = value;
215
215
  });
@@ -311,7 +311,14 @@ class NestedComponent extends Field_1.default {
311
311
  */
312
312
  getComponent(path) {
313
313
  var _a;
314
- path = (0, utils_1.getStringFromComponentPath)(path);
314
+ // If the component is found
315
+ if (!this.componentMatches) {
316
+ this.componentMatches = {};
317
+ }
318
+ if (this.componentMatches && this.componentMatches[path]) {
319
+ return this.componentMatches[path];
320
+ }
321
+ path = utils_1.default.getStringFromComponentPath(path);
315
322
  const matches = {
316
323
  path: undefined,
317
324
  fullPath: undefined,
@@ -324,7 +331,7 @@ class NestedComponent extends Field_1.default {
324
331
  this.everyComponent((component) => {
325
332
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
326
333
  // All searches are relative to this component so replace this path from the child paths.
327
- (0, utils_1.componentMatches)(component.component, {
334
+ utils_1.default.componentMatches(component.component, {
328
335
  path: (_b = (_a = component.paths) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(new RegExp(`^${(_c = this.paths) === null || _c === void 0 ? void 0 : _c.path}\\.?`), ''),
329
336
  fullPath: (_e = (_d = component.paths) === null || _d === void 0 ? void 0 : _d.fullPath) === null || _e === void 0 ? void 0 : _e.replace(new RegExp(`^${(_f = this.paths) === null || _f === void 0 ? void 0 : _f.fullPath}\\.?`), ''),
330
337
  localPath: (_h = (_g = component.paths) === null || _g === void 0 ? void 0 : _g.localPath) === null || _h === void 0 ? void 0 : _h.replace(new RegExp(`^${(_j = this.paths) === null || _j === void 0 ? void 0 : _j.localPath}\\.?`), ''),
@@ -336,7 +343,8 @@ class NestedComponent extends Field_1.default {
336
343
  return match;
337
344
  });
338
345
  });
339
- return (_a = (0, utils_1.getBestMatch)(matches)) === null || _a === void 0 ? void 0 : _a.instance;
346
+ this.componentMatches[path] = (_a = utils_1.default.getBestMatch(matches)) === null || _a === void 0 ? void 0 : _a.instance;
347
+ return this.componentMatches[path];
340
348
  }
341
349
  /**
342
350
  * Return a component provided the Id of the component.
@@ -378,7 +386,7 @@ class NestedComponent extends Field_1.default {
378
386
  options.localRoot = this.localRoot;
379
387
  options.skipInit = true;
380
388
  if (!(options.display === 'pdf' && this.builderMode)) {
381
- component.id = (0, utils_1.getRandomComponentId)();
389
+ component.id = utils_1.default.getRandomComponentId();
382
390
  }
383
391
  const comp = Components_1.default.create(component, options, data, true);
384
392
  comp.init();
@@ -664,7 +672,7 @@ class NestedComponent extends Field_1.default {
664
672
  validationProcessor({ scope, data, row, instance, paths }, flags) {
665
673
  var _a;
666
674
  const { dirty } = flags;
667
- if (this.root.hasExtraPages && this.page !== this.root.page) {
675
+ if (this.root && this.root.hasSubWizards && this.page !== this.root.page) {
668
676
  instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
669
677
  ? this.componentsMap[paths.dataPath]
670
678
  : this.getComponent(paths.dataPath);
@@ -800,8 +808,10 @@ class NestedComponent extends Field_1.default {
800
808
  return this.data;
801
809
  }
802
810
  resetValue() {
803
- super.resetValue();
811
+ // Reset values of child components first, then reset the parent one, otherwise it will restore the default
812
+ // value of parent component and clear it one by one while resetting child components
804
813
  this.getComponents().forEach((comp) => comp.resetValue());
814
+ super.resetValue();
805
815
  this.setPristine(true);
806
816
  }
807
817
  get dataReady() {
@@ -813,7 +823,7 @@ class NestedComponent extends Field_1.default {
813
823
  return false;
814
824
  }
815
825
  if (component.type === 'components') {
816
- if (component.tree && component.hasValue(value)) {
826
+ if ((component.tree || component.hasInput) && component.hasValue(value)) {
817
827
  return component.setValue(lodash_1.default.get(value, component.key), flags);
818
828
  }
819
829
  return component.setValue(value, flags);
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const utils_1 = require("@formio/core/utils");
8
8
  const { getComponentPaths } = utils_1.Utils;
9
- const utils_2 = require("../../../utils/utils");
9
+ const utils_2 = require("../../../utils");
10
10
  const Component_1 = __importDefault(require("../component/Component"));
11
11
  const NestedDataComponent_1 = __importDefault(require("../nesteddata/NestedDataComponent"));
12
12
  class NestedArrayComponent extends NestedDataComponent_1.default {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Component_1 = __importDefault(require("../component/Component"));
7
7
  const NestedComponent_1 = __importDefault(require("../nested/NestedComponent"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("../../../utils/utils");
9
+ const utils_1 = require("../../../utils");
10
10
  class NestedDataComponent extends NestedComponent_1.default {
11
11
  hasChanged(newValue, oldValue) {
12
12
  // If we do not have a value and are getting set to anything other than undefined or null, then we changed.
@@ -11,7 +11,7 @@ const GoogleAddressProvider_1 = require("../../providers/address/GoogleAddressPr
11
11
  const Field_1 = __importDefault(require("../_classes/field/Field"));
12
12
  const NestedComponent_1 = __importDefault(require("../_classes/nested/NestedComponent"));
13
13
  const Container_1 = __importDefault(require("../container/Container"));
14
- const utils_1 = require("../../utils/utils");
14
+ const utils_1 = require("../../utils");
15
15
  exports.AddressComponentMode = {
16
16
  Autocomplete: 'autocomplete',
17
17
  Manual: 'manual',
@@ -249,7 +249,7 @@ class AddressComponent extends Container_1.default {
249
249
  if (this.manualMode) {
250
250
  this.restoreComponentsContext();
251
251
  }
252
- if (changed || !lodash_1.default.isEmpty(value) && flags.fromSubmission) {
252
+ if (changed || !lodash_1.default.isEmpty(value) && flags.fromSubmission || flags.resetValue) {
253
253
  this.redraw();
254
254
  }
255
255
  return changed;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const utils_1 = require("../../utils/utils");
7
+ const utils_1 = require("../../utils");
8
8
  class Alert {
9
9
  constructor(container, component) {
10
10
  this.container = container;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const Field_1 = __importDefault(require("../_classes/field/Field"));
8
8
  const Input_1 = __importDefault(require("../_classes/input/Input"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class ButtonComponent extends Field_1.default {
11
11
  static schema(...extend) {
12
12
  return Input_1.default.schema({
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const utils_1 = require("../../utils/utils");
7
+ const utils_1 = require("../../utils");
8
8
  const Field_1 = __importDefault(require("../_classes/field/Field"));
9
9
  class CheckBoxComponent extends Field_1.default {
10
10
  static schema(...extend) {
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const utils_1 = require("../../utils/utils");
7
+ const utils_1 = require("../../utils");
8
8
  const Component_1 = __importDefault(require("../_classes/component/Component"));
9
9
  const Field_1 = __importDefault(require("../_classes/field/Field"));
10
10
  const NestedDataComponent_1 = __importDefault(require("../_classes/nesteddata/NestedDataComponent"));
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const text_mask_addons_1 = require("@formio/text-mask-addons");
7
7
  const vanilla_text_mask_1 = require("@formio/vanilla-text-mask");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  const Number_1 = __importDefault(require("../number/Number"));
11
11
  class CurrencyComponent extends Number_1.default {
12
12
  static schema(...extend) {
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
8
- const utils_1 = require("../../utils/utils");
8
+ const utils_1 = require("../../utils");
9
9
  class DataGridComponent extends NestedArrayComponent_1.default {
10
10
  static schema(...extend) {
11
11
  return NestedArrayComponent_1.default.schema({
@@ -419,12 +419,16 @@ class DataGridComponent extends NestedArrayComponent_1.default {
419
419
  updateComponentsRowIndex(components, rowIndex) {
420
420
  components.forEach((component, colIndex) => {
421
421
  var _a;
422
+ if (this.componentsMap[component.paths.dataPath]) {
423
+ delete this.componentsMap[component.paths.dataPath];
424
+ }
422
425
  if ((_a = component.options) === null || _a === void 0 ? void 0 : _a.name) {
423
426
  const newName = `[${this.key}][${rowIndex}]`;
424
427
  component.options.name = component.options.name.replace(`[${this.key}][${component.rowIndex}]`, newName);
425
428
  }
426
429
  component.rowIndex = rowIndex;
427
430
  component.row = `${rowIndex}-${colIndex}`;
431
+ this.componentsMap[component.paths.dataPath] = component;
428
432
  });
429
433
  }
430
434
  updateRowsComponents(rowIndex) {
@@ -228,6 +228,9 @@ class DataMapComponent extends DataGrid_1.default {
228
228
  options.name += `[${rowIndex}]`;
229
229
  options.row = `${rowIndex}`;
230
230
  options.rowIndex = rowIndex;
231
+ options.onChange = (flags, changed, modified) => {
232
+ this.triggerChange({ modified });
233
+ };
231
234
  const components = {};
232
235
  components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
233
236
  components['__key'].on('componentChange', (event) => {
@@ -243,7 +246,9 @@ class DataMapComponent extends DataGrid_1.default {
243
246
  valueComponent.key = key;
244
247
  const componentOptions = this.options;
245
248
  componentOptions.row = options.row;
246
- components[this.valueKey] = this.createComponent(valueComponent, componentOptions, this.dataValue);
249
+ const componentOptionsCloned = lodash_1.default.clone(componentOptions);
250
+ componentOptionsCloned.onChange = options.onChange;
251
+ components[this.valueKey] = this.createComponent(valueComponent, componentOptionsCloned, this.dataValue);
247
252
  return components;
248
253
  }
249
254
  get canAddColumn() {
@@ -266,7 +271,7 @@ class DataMapComponent extends DataGrid_1.default {
266
271
  const index = this.rows.length;
267
272
  this.rows[index] = this.createRowComponents(this.dataValue, index);
268
273
  this.redraw();
269
- this.triggerChange();
274
+ this.triggerChange({ modified: true });
270
275
  }
271
276
  removeRow(index) {
272
277
  const keys = Object.keys(this.dataValue);
@@ -17,7 +17,7 @@ export default class DateTimeComponent extends Input {
17
17
  };
18
18
  static savedValueTypes(schema: any): string[];
19
19
  get emptyValue(): string;
20
- get momentFormat(): string;
20
+ get dayjsFormat(): string;
21
21
  createWrapper(): boolean;
22
22
  checkValidity(data: any, dirty: any, rowData: any): boolean;
23
23
  getValueAsString(value: any, options: any): any;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
- const moment_1 = __importDefault(require("moment"));
7
+ const dayjs_1 = __importDefault(require("dayjs"));
8
8
  const utils_1 = __importDefault(require("../../utils"));
9
- const utils_2 = require("../../utils/utils");
9
+ const utils_2 = require("../../utils");
10
10
  const Input_1 = __importDefault(require("../_classes/input/Input"));
11
11
  class DateTimeComponent extends Input_1.default {
12
12
  static schema(...extend) {
@@ -123,8 +123,8 @@ class DateTimeComponent extends Input_1.default {
123
123
  get emptyValue() {
124
124
  return '';
125
125
  }
126
- get momentFormat() {
127
- return utils_1.default.convertFormatToMoment(this.component.format);
126
+ get dayjsFormat() {
127
+ return utils_1.default.convertFormatToDayjs(this.component.format);
128
128
  }
129
129
  isEmpty(value = this.dataValue) {
130
130
  if (value && (value.toString() === 'Invalid Date')) {
@@ -133,12 +133,14 @@ class DateTimeComponent extends Input_1.default {
133
133
  return super.isEmpty(value);
134
134
  }
135
135
  formatValue(input) {
136
- const result = moment_1.default.utc(input).toISOString();
137
- return result === 'Invalid date' ? input : result;
136
+ if ((0, dayjs_1.default)(input).isValid()) {
137
+ return dayjs_1.default.utc(input).toISOString();
138
+ }
139
+ return input;
138
140
  }
139
141
  isEqual(valueA, valueB = this.dataValue) {
140
142
  return (this.isEmpty(valueA) && this.isEmpty(valueB))
141
- || moment_1.default.utc(valueA).format(this.momentFormat) === moment_1.default.utc(valueB).format(this.momentFormat);
143
+ || dayjs_1.default.utc(valueA).format(this.dayjsFormat) === dayjs_1.default.utc(valueB).format(this.dayjsFormat);
142
144
  }
143
145
  createWrapper() {
144
146
  return false;
@@ -154,19 +156,19 @@ class DateTimeComponent extends Input_1.default {
154
156
  return super.checkValidity(data, dirty, rowData);
155
157
  }
156
158
  getValueAsString(value, options) {
157
- let format = utils_1.default.convertFormatToMoment(this.component.format);
158
- format += format.match(/z$/) ? '' : ' z';
159
+ let format = utils_1.default.convertFormatToDayjs(this.component.format);
159
160
  const timezone = this.timezone;
160
161
  if (value && !this.attached && timezone) {
162
+ format += format.match(/z$/) ? '' : ' z';
161
163
  if (Array.isArray(value) && this.component.multiple) {
162
- return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone, options).format(format))).join(', ');
164
+ return value.map(item => lodash_1.default.trim(utils_1.default.dayjsDate(item, format, timezone, options).format(format))).join(', ');
163
165
  }
164
- return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone, options).format(format));
166
+ return lodash_1.default.trim(utils_1.default.dayjsDate(value, format, timezone, options).format(format));
165
167
  }
166
168
  if (Array.isArray(value) && this.component.multiple) {
167
- return value.map(item => lodash_1.default.trim((0, moment_1.default)(item).format(format))).join(', ');
169
+ return value.map(item => lodash_1.default.trim((0, dayjs_1.default)(item).format(format))).join(', ');
168
170
  }
169
- return (value ? lodash_1.default.trim((0, moment_1.default)(value).format(format)) : value) || '';
171
+ return (value ? lodash_1.default.trim((0, dayjs_1.default)(value).format(format)) : value) || '';
170
172
  }
171
173
  }
172
174
  exports.default = DateTimeComponent;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const Field_1 = __importDefault(require("../_classes/field/Field"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  const core_1 = require("@formio/core");
11
11
  class DayComponent extends Field_1.default {
12
12
  static schema(...extend) {
@@ -53,7 +53,7 @@ class DayComponent extends Field_1.default {
53
53
  return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
54
54
  }
55
55
  constructor(component, options, data) {
56
- if (!options.inFormBuilder && !options.building) {
56
+ if (options && !options.inFormBuilder && !options.building) {
57
57
  if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
58
  component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
59
59
  }
@@ -101,7 +101,6 @@ export default class EditGridComponent extends NestedArrayComponent {
101
101
  changeState(changed: any, flags: any): void;
102
102
  openWhenEmpty(): void;
103
103
  restoreRowContext(editRow: any, flags?: {}): void;
104
- emptyRows(): void;
105
104
  hasChanged: (newValue: any, oldValue: any) => boolean;
106
105
  }
107
106
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
@@ -9,7 +9,7 @@ const components_1 = require("@formio/bootstrap/components");
9
9
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
10
10
  const Component_1 = __importDefault(require("../_classes/component/Component"));
11
11
  const Alert_1 = __importDefault(require("../alert/Alert"));
12
- const utils_1 = require("../../utils/utils");
12
+ const utils_1 = require("../../utils");
13
13
  const EditRowState = {
14
14
  New: 'new',
15
15
  Editing: 'editing',
@@ -1200,14 +1200,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1200
1200
  this.setNestedValue(component, editRow.data, flags);
1201
1201
  });
1202
1202
  }
1203
- emptyRows() {
1204
- this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));
1205
- this.editRows = [];
1206
- }
1207
- resetValue() {
1208
- super.resetValue();
1209
- this.emptyRows();
1210
- }
1211
1203
  }
1212
1204
  exports.default = EditGridComponent;
1213
1205
  EditGridComponent.prototype.hasChanged = Component_1.default.prototype.hasChanged;
@@ -35,7 +35,7 @@ exports.default = [
35
35
  weight: 1002,
36
36
  input: false,
37
37
  customConditional() {
38
- return !Evaluator_1.Evaluator.noeval;
38
+ return !Evaluator_1.Evaluator.noeval || !Evaluator_1.Evaluator.protectedEval;
39
39
  },
40
40
  },
41
41
  {
@@ -12,6 +12,7 @@ class FieldsetComponent extends NestedComponent_1.default {
12
12
  type: 'fieldset',
13
13
  legend: '',
14
14
  components: [],
15
+ clearOnHide: false,
15
16
  input: false,
16
17
  persistent: false
17
18
  }, ...extend);
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const Field_1 = __importDefault(require("../_classes/field/Field"));
16
- const utils_1 = require("../../utils/utils");
16
+ const utils_1 = require("../../utils");
17
17
  const downloadjs_1 = __importDefault(require("downloadjs"));
18
18
  const lodash_1 = __importDefault(require("lodash"));
19
19
  const fileProcessor_1 = __importDefault(require("../../providers/processor/fileProcessor"));
@@ -8,7 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
8
8
  const Component_1 = __importDefault(require("../_classes/component/Component"));
9
9
  const ComponentModal_1 = __importDefault(require("../_classes/componentModal/ComponentModal"));
10
10
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
11
- const utils_1 = require("../../utils/utils");
11
+ const utils_1 = require("../../utils");
12
12
  const Formio_1 = require("../../Formio");
13
13
  const Form_1 = __importDefault(require("../../Form"));
14
14
  class FormComponent extends Component_1.default {
@@ -278,6 +278,9 @@ class FormComponent extends Component_1.default {
278
278
  if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
279
279
  this.createSubForm(true);
280
280
  }
281
+ if (!this.subFormReady) {
282
+ return Promise.resolve();
283
+ }
281
284
  return this.subFormReady.then(() => {
282
285
  this.empty(element);
283
286
  if (this.options.builder) {
@@ -408,13 +411,15 @@ class FormComponent extends Component_1.default {
408
411
  }
409
412
  // Render the form.
410
413
  return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
414
+ var _a, _b;
411
415
  this.subForm = instance;
412
416
  this.subForm.currentForm = this;
413
417
  this.subForm.parentVisible = this.visible;
414
418
  const componentsMap = this.componentsMap;
415
419
  const formComponentsMap = this.subForm.componentsMap;
416
420
  lodash_1.default.assign(componentsMap, formComponentsMap);
417
- this.component.components = this.subForm.components.map((comp) => comp.component);
421
+ this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
422
+ this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
418
423
  this.subForm.on('change', () => {
419
424
  if (this.subForm && !this.shouldConditionallyClear()) {
420
425
  this.dataValue = this.subForm.getValue();
@@ -699,6 +704,13 @@ class FormComponent extends Component_1.default {
699
704
  }
700
705
  return errors;
701
706
  }
707
+ conditionallyHidden() {
708
+ const conditionallyHidden = super.conditionallyHidden();
709
+ if (this.subForm) {
710
+ this.subForm._conditionallyHidden = conditionallyHidden;
711
+ }
712
+ return conditionallyHidden;
713
+ }
702
714
  updateSubFormVisibility() {
703
715
  if (this.subForm) {
704
716
  this.subForm.parentVisible = this.visible;
@@ -32,10 +32,11 @@ exports.default = [
32
32
  tooltip: 'if it is checked, the subform is loaded after navigation to the page with this component within the wizard.',
33
33
  input: true,
34
34
  customConditional({ instance, data }) {
35
- var _a, _b, _c, _d;
36
- const formInfo = (_b = (_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('form')) === null || _b === void 0 ? void 0 : _b.defaultDownloadedResources.find(res => res._id === data.form);
35
+ var _a, _b, _c;
36
+ const formComp = (_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('form');
37
+ const formInfo = formComp === null || formComp === void 0 ? void 0 : formComp.defaultDownloadedResources.find(res => res._id === data.form);
37
38
  const displayMode = 'wizard';
38
- return ((_d = (_c = instance.options) === null || _c === void 0 ? void 0 : _c.editForm) === null || _d === void 0 ? void 0 : _d.display) === displayMode && formInfo && formInfo.display !== displayMode;
39
+ return ((_c = (_b = instance.options) === null || _b === void 0 ? void 0 : _b.editForm) === null || _c === void 0 ? void 0 : _c.display) === displayMode && ((data.form && !formInfo) || (formInfo && formInfo.display !== displayMode));
39
40
  },
40
41
  },
41
42
  {
@@ -7,7 +7,7 @@ const text_mask_addons_1 = require("@formio/text-mask-addons");
7
7
  const vanilla_text_mask_1 = require("@formio/vanilla-text-mask");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const Input_1 = __importDefault(require("../_classes/input/Input"));
10
- const utils_1 = require("../../utils/utils");
10
+ const utils_1 = require("../../utils/");
11
11
  class NumberComponent extends Input_1.default {
12
12
  static schema(...extend) {
13
13
  return Input_1.default.schema({
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const NestedComponent_1 = __importDefault(require("../_classes/nested/NestedComponent"));
7
- const utils_1 = require("../../utils/utils");
7
+ const utils_1 = require("../../utils");
8
8
  class PanelComponent extends NestedComponent_1.default {
9
9
  static schema(...extend) {
10
10
  return NestedComponent_1.default.schema({
@@ -16,6 +16,7 @@ export default class RadioComponent extends ListComponent {
16
16
  static savedValueTypes(schema: any): any[];
17
17
  constructor(component: any, options: any, data: any);
18
18
  previousValue: any;
19
+ uncheckValue(flags?: {}): void;
19
20
  get inputInfo(): any;
20
21
  get emptyValue(): string;
21
22
  get isRadio(): boolean;
@@ -28,6 +29,7 @@ export default class RadioComponent extends ListComponent {
28
29
  optionsLoaded: boolean | undefined;
29
30
  loadedOptions: any[] | undefined;
30
31
  beforeSubmit(): Promise<any>;
32
+ convertValues(values: any): any;
31
33
  render(): string;
32
34
  attach(element: any): Promise<void>;
33
35
  detach(element: any): void;
@@ -41,5 +43,12 @@ export default class RadioComponent extends ListComponent {
41
43
  setSelectedClasses(): void;
42
44
  updateValue(value: any, flags: any): boolean;
43
45
  currentValue: any;
46
+ /**
47
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
48
+ * @param {*} value - The value to normalize
49
+ * @returns {*} - Returns the normalized value
50
+ */
51
+ convertByDataType(value: any): any;
52
+ normalizeValue(value: any): any;
44
53
  }
45
54
  import ListComponent from '../_classes/list/ListComponent';
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
8
8
  const Formio_1 = require("../../Formio");
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class RadioComponent extends ListComponent_1.default {
11
11
  static schema(...extend) {
12
12
  return ListComponent_1.default.schema({
@@ -79,13 +79,15 @@ class RadioComponent extends ListComponent_1.default {
79
79
  }
80
80
  return defaultValue;
81
81
  }
82
- resetValue() {
82
+ uncheckValue(flags = {}) {
83
83
  this.unset();
84
84
  this.setValue(this.emptyValue, {
85
85
  noUpdateEvent: true,
86
86
  noValidate: true,
87
87
  resetValue: true
88
88
  });
89
+ this.triggerChange(flags);
90
+ this.setSelectedClasses();
89
91
  }
90
92
  get inputInfo() {
91
93
  var _a;
@@ -153,6 +155,12 @@ class RadioComponent extends ListComponent_1.default {
153
155
  this.dataReady.then(() => res(true));
154
156
  });
155
157
  }
158
+ convertValues(values) {
159
+ if (this.options.renderMode === 'html' && this.type === 'radio') {
160
+ return values.map(x => (Object.assign(Object.assign({}, x), { value: this.convertByDataType(x.value) })));
161
+ }
162
+ return values;
163
+ }
156
164
  render() {
157
165
  if (!this.optionsLoaded) {
158
166
  return super.render(this.renderTemplate('loader'));
@@ -160,7 +168,7 @@ class RadioComponent extends ListComponent_1.default {
160
168
  return super.render(this.renderTemplate('radio', {
161
169
  input: this.inputInfo,
162
170
  inline: this.component.inline,
163
- values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
171
+ values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
164
172
  value: this.dataValue,
165
173
  row: this.row,
166
174
  }));
@@ -394,9 +402,7 @@ class RadioComponent extends ListComponent_1.default {
394
402
  this.currentValue = this.dataValue;
395
403
  const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
396
404
  if (shouldResetValue) {
397
- this.resetValue();
398
- this.triggerChange(flags);
399
- this.setSelectedClasses();
405
+ this.uncheckValue(flags);
400
406
  }
401
407
  this.previousValue = this.dataValue;
402
408
  return changed;
@@ -406,7 +412,7 @@ class RadioComponent extends ListComponent_1.default {
406
412
  * @param {*} value - The value to normalize
407
413
  * @returns {*} - Returns the normalized value
408
414
  */
409
- normalizeValue(value) {
415
+ convertByDataType(value) {
410
416
  const dataType = this.component.dataType || 'auto';
411
417
  if (value === this.emptyValue) {
412
418
  return value;
@@ -438,14 +444,18 @@ class RadioComponent extends ListComponent_1.default {
438
444
  value = !(!value || value.toString() === 'false');
439
445
  break;
440
446
  }
441
- if (this.isSelectURL && this.templateData && this.templateData[value]) {
447
+ return value;
448
+ }
449
+ normalizeValue(value) {
450
+ const valueConverted = this.convertByDataType(value);
451
+ if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
442
452
  const submission = this.root.submission;
443
453
  if (!submission.metadata.selectData) {
444
454
  submission.metadata.selectData = {};
445
455
  }
446
- lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[value]);
456
+ lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
447
457
  }
448
- return super.normalizeValue(value);
458
+ return super.normalizeValue(valueConverted);
449
459
  }
450
460
  }
451
461
  exports.default = RadioComponent;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../../utils/utils");
3
+ const utils_1 = require("../../../utils");
4
4
  exports.default = [
5
5
  {
6
6
  key: 'recaptchaInfo',