@formio/js 5.1.0-dev.6042.18ef5d3 → 5.1.0-dev.6042.603237d

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 (156) hide show
  1. package/Changelog.md +57 -402
  2. package/README.md +7 -0
  3. package/dist/formio.builder.css +1 -0
  4. package/dist/formio.builder.min.css +1 -1
  5. package/dist/formio.form.css +1 -0
  6. package/dist/formio.form.js +104 -126
  7. package/dist/formio.form.min.css +1 -1
  8. package/dist/formio.form.min.js +1 -1
  9. package/dist/formio.form.min.js.LICENSE.txt +3 -1
  10. package/dist/formio.full.css +1 -0
  11. package/dist/formio.full.js +111 -133
  12. package/dist/formio.full.min.css +1 -1
  13. package/dist/formio.full.min.js +1 -1
  14. package/dist/formio.full.min.js.LICENSE.txt +3 -1
  15. package/dist/formio.js +53 -64
  16. package/dist/formio.min.js +1 -1
  17. package/dist/formio.utils.js +66 -77
  18. package/dist/formio.utils.min.js +1 -1
  19. package/dist/formio.utils.min.js.LICENSE.txt +3 -1
  20. package/lib/cjs/Element.js +13 -36
  21. package/lib/cjs/EventEmitter.js +2 -25
  22. package/lib/cjs/Form.js +2 -25
  23. package/lib/cjs/PDF.js +1 -1
  24. package/lib/cjs/PDFBuilder.js +4 -5
  25. package/lib/cjs/Webform.js +8 -7
  26. package/lib/cjs/WebformBuilder.d.ts +1 -0
  27. package/lib/cjs/WebformBuilder.js +40 -14
  28. package/lib/cjs/Wizard.d.ts +1 -2
  29. package/lib/cjs/Wizard.js +18 -24
  30. package/lib/cjs/WizardBuilder.js +1 -1
  31. package/lib/cjs/components/_classes/component/Component.d.ts +26 -2
  32. package/lib/cjs/components/_classes/component/Component.js +97 -88
  33. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  34. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  35. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  36. package/lib/cjs/components/_classes/input/Input.js +1 -1
  37. package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
  38. package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -7
  39. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  40. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  41. package/lib/cjs/components/address/Address.js +1 -1
  42. package/lib/cjs/components/alert/Alert.js +1 -1
  43. package/lib/cjs/components/button/Button.d.ts +1 -1
  44. package/lib/cjs/components/button/Button.js +7 -11
  45. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  46. package/lib/cjs/components/container/Container.js +1 -1
  47. package/lib/cjs/components/currency/Currency.js +1 -1
  48. package/lib/cjs/components/datagrid/DataGrid.js +5 -1
  49. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  50. package/lib/cjs/components/datetime/DateTime.js +15 -13
  51. package/lib/cjs/components/day/Day.js +2 -2
  52. package/lib/cjs/components/editgrid/EditGrid.js +1 -1
  53. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  54. package/lib/cjs/components/file/File.js +5 -6
  55. package/lib/cjs/components/form/Form.d.ts +0 -1
  56. package/lib/cjs/components/form/Form.js +26 -22
  57. package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
  58. package/lib/cjs/components/number/Number.js +1 -1
  59. package/lib/cjs/components/panel/Panel.js +1 -1
  60. package/lib/cjs/components/radio/Radio.d.ts +8 -0
  61. package/lib/cjs/components/radio/Radio.js +16 -6
  62. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  63. package/lib/cjs/components/select/Select.d.ts +1 -0
  64. package/lib/cjs/components/select/Select.js +20 -4
  65. package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
  66. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  67. package/lib/cjs/components/selectboxes/SelectBoxes.js +4 -1
  68. package/lib/cjs/components/signature/Signature.js +1 -1
  69. package/lib/cjs/components/survey/Survey.js +1 -1
  70. package/lib/cjs/components/tags/Tags.js +1 -1
  71. package/lib/cjs/components/textarea/TextArea.js +3 -3
  72. package/lib/cjs/components/textfield/TextField.js +9 -32
  73. package/lib/cjs/components/time/Time.js +1 -1
  74. package/lib/cjs/formio.form.js +3 -3
  75. package/lib/cjs/providers/storage/uploadAdapter.js +3 -3
  76. package/lib/cjs/translations/en.js +1 -1
  77. package/lib/cjs/utils/Evaluator.d.ts +20 -6
  78. package/lib/cjs/utils/Evaluator.js +38 -15
  79. package/lib/cjs/utils/builder.js +5 -5
  80. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  81. package/lib/cjs/utils/formUtils.d.ts +2 -2
  82. package/lib/cjs/utils/index.d.ts +169 -2
  83. package/lib/cjs/utils/index.js +22 -2
  84. package/lib/cjs/utils/utils.d.ts +31 -37
  85. package/lib/cjs/utils/utils.js +79 -135
  86. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
  87. package/lib/cjs/widgets/CalendarWidget.js +19 -40
  88. package/lib/mjs/Element.js +6 -6
  89. package/lib/mjs/EventEmitter.js +2 -2
  90. package/lib/mjs/Form.js +1 -1
  91. package/lib/mjs/PDF.js +1 -1
  92. package/lib/mjs/PDFBuilder.js +1 -2
  93. package/lib/mjs/Webform.js +6 -5
  94. package/lib/mjs/WebformBuilder.d.ts +1 -0
  95. package/lib/mjs/WebformBuilder.js +32 -7
  96. package/lib/mjs/Wizard.d.ts +1 -2
  97. package/lib/mjs/Wizard.js +17 -23
  98. package/lib/mjs/WizardBuilder.js +1 -1
  99. package/lib/mjs/components/_classes/component/Component.d.ts +26 -2
  100. package/lib/mjs/components/_classes/component/Component.js +70 -38
  101. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  102. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  103. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  104. package/lib/mjs/components/_classes/input/Input.js +1 -1
  105. package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
  106. package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -7
  107. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  108. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  109. package/lib/mjs/components/address/Address.js +1 -1
  110. package/lib/mjs/components/alert/Alert.js +1 -1
  111. package/lib/mjs/components/button/Button.d.ts +1 -1
  112. package/lib/mjs/components/button/Button.js +7 -10
  113. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  114. package/lib/mjs/components/container/Container.js +1 -1
  115. package/lib/mjs/components/currency/Currency.js +1 -1
  116. package/lib/mjs/components/datagrid/DataGrid.js +5 -1
  117. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  118. package/lib/mjs/components/datetime/DateTime.js +15 -13
  119. package/lib/mjs/components/day/Day.js +2 -2
  120. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  121. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  122. package/lib/mjs/components/file/File.js +5 -6
  123. package/lib/mjs/components/form/Form.d.ts +0 -1
  124. package/lib/mjs/components/form/Form.js +25 -22
  125. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
  126. package/lib/mjs/components/number/Number.js +1 -1
  127. package/lib/mjs/components/panel/Panel.js +1 -1
  128. package/lib/mjs/components/radio/Radio.d.ts +8 -0
  129. package/lib/mjs/components/radio/Radio.js +16 -6
  130. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  131. package/lib/mjs/components/select/Select.d.ts +1 -0
  132. package/lib/mjs/components/select/Select.js +20 -4
  133. package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
  134. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  135. package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -1
  136. package/lib/mjs/components/signature/Signature.js +1 -1
  137. package/lib/mjs/components/survey/Survey.js +1 -1
  138. package/lib/mjs/components/tags/Tags.js +1 -1
  139. package/lib/mjs/components/textarea/TextArea.js +3 -3
  140. package/lib/mjs/components/textfield/TextField.js +3 -3
  141. package/lib/mjs/components/time/Time.js +1 -1
  142. package/lib/mjs/formio.form.js +2 -2
  143. package/lib/mjs/providers/storage/uploadAdapter.js +3 -3
  144. package/lib/mjs/translations/en.js +3 -0
  145. package/lib/mjs/utils/Evaluator.d.ts +20 -6
  146. package/lib/mjs/utils/Evaluator.js +31 -13
  147. package/lib/mjs/utils/builder.js +1 -1
  148. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  149. package/lib/mjs/utils/formUtils.d.ts +2 -2
  150. package/lib/mjs/utils/index.d.ts +169 -2
  151. package/lib/mjs/utils/index.js +18 -1
  152. package/lib/mjs/utils/utils.d.ts +31 -37
  153. package/lib/mjs/utils/utils.js +71 -109
  154. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
  155. package/lib/mjs/widgets/CalendarWidget.js +19 -40
  156. package/package.json +8 -6
@@ -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({
@@ -492,6 +492,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
492
492
  options.row = `${rowIndex}-${colIndex}`;
493
493
  options.rowIndex = rowIndex;
494
494
  options.onChange = (flags, changed, modified) => {
495
+ if (changed.component.type === 'form') {
496
+ const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
497
+ lodash_1.default.set(formComp, 'components', changed.component.components);
498
+ }
495
499
  this.triggerChange({ modified });
496
500
  };
497
501
  let columnComponent;
@@ -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
  }
@@ -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',
@@ -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
  {
@@ -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"));
@@ -905,17 +905,16 @@ class FileComponent extends Field_1.default {
905
905
  }
906
906
  uploadFile(fileToSync) {
907
907
  return __awaiter(this, void 0, void 0, function* () {
908
- const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
908
+ return yield this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
909
909
  // Progress callback
910
910
  this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
911
- this.emit('fileUploadingStart', filePromise);
911
+ this.emit('fileUploadingStart');
912
912
  },
913
913
  // Abort upload callback
914
914
  (abort) => this.abortUploads.push({
915
915
  id: fileToSync.id,
916
916
  abort,
917
917
  }), this.getMultipartOptions(fileToSync));
918
- return yield filePromise;
919
918
  });
920
919
  }
921
920
  upload() {
@@ -937,7 +936,7 @@ class FileComponent extends Field_1.default {
937
936
  fileToSync.message = this.t('succefullyUploaded');
938
937
  fileInfo.originalName = fileToSync.originalName;
939
938
  fileInfo.hash = fileToSync.hash;
940
- this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
939
+ this.emit('fileUploadingEnd');
941
940
  }
942
941
  catch (response) {
943
942
  fileToSync.status = 'error';
@@ -947,7 +946,7 @@ class FileComponent extends Field_1.default {
947
946
  : response.type === 'abort'
948
947
  ? this.t('Request was aborted')
949
948
  : response.toString();
950
- this.emit('fileUploadingEnd', Promise.reject(response));
949
+ this.emit('fileUploadingEnd');
951
950
  this.emit('fileUploadError', {
952
951
  fileToSync,
953
952
  response,
@@ -98,7 +98,6 @@ export default class FormComponent extends Component {
98
98
  * @returns {void}
99
99
  */
100
100
  onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
101
- areAllComponentsEmpty(data: any): boolean;
102
101
  updateSubFormVisibility(): void;
103
102
  /**
104
103
  * Determines if this form is a Nested Wizard
@@ -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 {
@@ -101,6 +101,9 @@ class FormComponent extends Component_1.default {
101
101
  }
102
102
  return this.createSubForm();
103
103
  }
104
+ shouldConditionallyClearOnPristine() {
105
+ return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
106
+ }
104
107
  get dataReady() {
105
108
  var _a;
106
109
  return ((_a = this.subForm) === null || _a === void 0 ? void 0 : _a.dataReady) || this.subFormReady || Promise.resolve();
@@ -275,6 +278,9 @@ class FormComponent extends Component_1.default {
275
278
  if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
276
279
  this.createSubForm(true);
277
280
  }
281
+ if (!this.subFormReady) {
282
+ return Promise.resolve();
283
+ }
278
284
  return this.subFormReady.then(() => {
279
285
  this.empty(element);
280
286
  if (this.options.builder) {
@@ -290,11 +296,13 @@ class FormComponent extends Component_1.default {
290
296
  }
291
297
  this.subForm.attach(element);
292
298
  this.valueChanged = this.hasSetValue;
293
- if (!this.valueChanged && this.dataValue.state !== 'submitted') {
294
- this.setDefaultValue();
295
- }
296
- else {
297
- this.restoreValue();
299
+ if (!this.shouldConditionallyClear()) {
300
+ if (!this.valueChanged && this.dataValue.state !== 'submitted') {
301
+ this.setDefaultValue();
302
+ }
303
+ else {
304
+ this.restoreValue();
305
+ }
298
306
  }
299
307
  }
300
308
  if (!this.builderMode && this.component.modalEdit) {
@@ -403,15 +411,17 @@ class FormComponent extends Component_1.default {
403
411
  }
404
412
  // Render the form.
405
413
  return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
414
+ var _a, _b;
406
415
  this.subForm = instance;
407
416
  this.subForm.currentForm = this;
408
417
  this.subForm.parentVisible = this.visible;
409
418
  const componentsMap = this.componentsMap;
410
419
  const formComponentsMap = this.subForm.componentsMap;
411
420
  lodash_1.default.assign(componentsMap, formComponentsMap);
412
- 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;
413
423
  this.subForm.on('change', () => {
414
- if (this.subForm) {
424
+ if (this.subForm && !this.shouldConditionallyClear()) {
415
425
  this.dataValue = this.subForm.getValue();
416
426
  this.triggerChange({
417
427
  noEmit: true
@@ -679,20 +689,7 @@ class FormComponent extends Component_1.default {
679
689
  }
680
690
  }
681
691
  isEmpty(value = this.dataValue) {
682
- return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
683
- }
684
- areAllComponentsEmpty(data) {
685
- let res = true;
686
- if (this.subForm) {
687
- this.subForm.everyComponent((comp) => {
688
- const componentValue = lodash_1.default.get(data, comp.key);
689
- res &= comp.isEmpty(componentValue);
690
- });
691
- }
692
- else {
693
- res = false;
694
- }
695
- return res;
692
+ return value === null || lodash_1.default.isEqual(value, this.emptyValue);
696
693
  }
697
694
  getValue() {
698
695
  if (this.subForm) {
@@ -707,6 +704,13 @@ class FormComponent extends Component_1.default {
707
704
  }
708
705
  return errors;
709
706
  }
707
+ conditionallyHidden() {
708
+ const conditionallyHidden = super.conditionallyHidden();
709
+ if (this.subForm) {
710
+ this.subForm._conditionallyHidden = conditionallyHidden;
711
+ }
712
+ return conditionallyHidden;
713
+ }
710
714
  updateSubFormVisibility() {
711
715
  if (this.subForm) {
712
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({
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
28
28
  optionsLoaded: boolean | undefined;
29
29
  loadedOptions: any[] | undefined;
30
30
  beforeSubmit(): Promise<any>;
31
+ convertValues(values: any): any;
31
32
  render(): string;
32
33
  attach(element: any): Promise<void>;
33
34
  detach(element: any): void;
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
41
42
  setSelectedClasses(): void;
42
43
  updateValue(value: any, flags: any): boolean;
43
44
  currentValue: any;
45
+ /**
46
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
47
+ * @param {*} value - The value to normalize
48
+ * @returns {*} - Returns the normalized value
49
+ */
50
+ convertByDataType(value: any): any;
51
+ normalizeValue(value: any): any;
44
52
  }
45
53
  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({
@@ -153,6 +153,12 @@ class RadioComponent extends ListComponent_1.default {
153
153
  this.dataReady.then(() => res(true));
154
154
  });
155
155
  }
156
+ convertValues(values) {
157
+ if (this.options.renderMode === 'html' && this.type === 'radio') {
158
+ return values.map(x => (Object.assign(Object.assign({}, x), { value: this.convertByDataType(x.value) })));
159
+ }
160
+ return values;
161
+ }
156
162
  render() {
157
163
  if (!this.optionsLoaded) {
158
164
  return super.render(this.renderTemplate('loader'));
@@ -160,7 +166,7 @@ class RadioComponent extends ListComponent_1.default {
160
166
  return super.render(this.renderTemplate('radio', {
161
167
  input: this.inputInfo,
162
168
  inline: this.component.inline,
163
- values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
169
+ values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
164
170
  value: this.dataValue,
165
171
  row: this.row,
166
172
  }));
@@ -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',
@@ -89,6 +89,7 @@ export default class SelectComponent extends ListComponent {
89
89
  disableInfiniteScroll(): void;
90
90
  set serverCount(value: any);
91
91
  get serverCount(): any;
92
+ shouldResetChoicesItems(items: any): boolean;
92
93
  setItems(items: any, fromSearch: any): void;
93
94
  selectItems: any;
94
95
  set downloadedResources(value: any);
@@ -7,7 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
7
7
  const Formio_1 = require("../../Formio");
8
8
  const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
9
9
  const Form_1 = __importDefault(require("../../Form"));
10
- const utils_1 = require("../../utils/utils");
10
+ const utils_1 = require("../../utils");
11
11
  const ChoicesWrapper_1 = __importDefault(require("../../utils/ChoicesWrapper"));
12
12
  class SelectComponent extends ListComponent_1.default {
13
13
  static schema(...extend) {
@@ -355,6 +355,18 @@ class SelectComponent extends ListComponent_1.default {
355
355
  this.downloadedResources.serverCount = this.downloadedResources.length;
356
356
  this.serverCount = this.downloadedResources.length;
357
357
  }
358
+ shouldResetChoicesItems(items) {
359
+ if (this.choices._store.choices.length !== items.length) {
360
+ return true;
361
+ }
362
+ for (let item of items) {
363
+ const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
364
+ if (!choicesItem) {
365
+ return true;
366
+ }
367
+ }
368
+ return false;
369
+ }
358
370
  /* eslint-disable max-statements */
359
371
  setItems(items, fromSearch) {
360
372
  var _a, _b;
@@ -441,7 +453,7 @@ class SelectComponent extends ListComponent_1.default {
441
453
  this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));
442
454
  });
443
455
  if (this.choices) {
444
- this.choices.setChoices(this.selectOptions, 'value', 'label', true);
456
+ this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
445
457
  }
446
458
  else if (this.loading) {
447
459
  // Re-attach select input.
@@ -903,8 +915,9 @@ class SelectComponent extends ListComponent_1.default {
903
915
  });
904
916
  }
905
917
  // Add value options.
918
+ const value = this.undoValueTyping(this.dataValue);
906
919
  this.addValueOptions();
907
- this.setChoicesValue(this.dataValue);
920
+ this.setChoicesValue(value);
908
921
  if (this.isSelectResource && this.refs.addResource) {
909
922
  this.addEventListener(this.refs.addResource, 'click', (event) => {
910
923
  event.preventDefault();
@@ -1219,7 +1232,7 @@ class SelectComponent extends ListComponent_1.default {
1219
1232
  }
1220
1233
  lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
1221
1234
  }
1222
- if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
1235
+ if (flags.resetValue && !flags.fromSubmission && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
1223
1236
  const submission = this.root.submission;
1224
1237
  if (!submission.metadata) {
1225
1238
  submission.metadata = {};
@@ -1283,6 +1296,9 @@ class SelectComponent extends ListComponent_1.default {
1283
1296
  this.lazyLoadInit = true;
1284
1297
  const searchProperty = this.component.searchField || this.component.valueProperty;
1285
1298
  this.triggerUpdate(lodash_1.default.get(value.data || value, searchProperty, value), true);
1299
+ this.itemsLoaded.then(() => {
1300
+ this.setChoicesValue(value, hasPreviousValue, flags);
1301
+ });
1286
1302
  return changed;
1287
1303
  }
1288
1304
  // Add the value options.
@@ -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 calculateSingleSelectData = (context, defaultValue) => {
9
9
  const { instance, data } = context;
10
10
  const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);
@@ -8,6 +8,12 @@ export default class SelectBoxesComponent extends RadioComponent {
8
8
  * @returns {boolean} - If the value is empty.
9
9
  */
10
10
  isEmpty(value?: any): boolean;
11
+ /**
12
+ * Normalize values coming into updateValue.
13
+ * @param {any} value - The value to normalize.
14
+ * @returns {*} - The normalized value
15
+ */
16
+ normalizeValue(value: any): any;
11
17
  setInputsDisabled(value: any, onlyUnchecked: any): void;
12
18
  checkComponentValidity(data: any, dirty: any, rowData: any, options: any, errors?: any[]): boolean;
13
19
  }
@@ -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 Radio_1 = __importDefault(require("../radio/Radio"));
9
9
  class SelectBoxesComponent extends Radio_1.default {
10
10
  static schema(...extend) {
@@ -150,6 +150,9 @@ class SelectBoxesComponent extends Radio_1.default {
150
150
  }
151
151
  }
152
152
  }
153
+ else if (lodash_1.default.isEmpty(this.loadedOptions) && !checkedValues.length) {
154
+ value = {};
155
+ }
153
156
  return value;
154
157
  }
155
158
  /**
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const signature_pad_1 = __importDefault(require("signature_pad"));
7
7
  const Input_1 = __importDefault(require("../_classes/input/Input"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class SignatureComponent extends Input_1.default {
11
11
  static schema(...extend) {
12
12
  return Input_1.default.schema({
@@ -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 Field_1 = __importDefault(require("../_classes/field/Field"));
8
- const utils_1 = require("../../utils/utils");
8
+ const utils_1 = require("../../utils");
9
9
  class SurveyComponent extends Field_1.default {
10
10
  static schema(...extend) {
11
11
  return Field_1.default.schema({
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("../../utils/utils");
6
+ const utils_1 = require("../../utils");
7
7
  const Input_1 = __importDefault(require("../_classes/input/Input"));
8
8
  const choices_js_1 = __importDefault(require("choices.js"));
9
9
  class TagsComponent extends Input_1.default {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* global Quill */
7
7
  const TextField_1 = __importDefault(require("../textfield/TextField"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("../../utils/utils");
9
+ const utils_1 = require("../../utils");
10
10
  class TextAreaComponent extends TextField_1.default {
11
11
  static schema(...extend) {
12
12
  return TextField_1.default.schema({
@@ -63,8 +63,8 @@ class TextAreaComponent extends TextField_1.default {
63
63
  if ((this.options.readOnly || this.disabled) && !this.isHtmlRenderMode()) {
64
64
  const elementStyle = this.info.attr.style || '';
65
65
  const children = `
66
- <div ${this._referenceAttributeName}="input"
67
- class="formio-editor-read-only-content"
66
+ <div ${this._referenceAttributeName}="input"
67
+ class="formio-editor-read-only-content"
68
68
  ${elementStyle ? `style='${elementStyle}'` : ''}
69
69
  role="textbox"
70
70
  aria-multiline="true"