@formio/js 5.2.3 → 5.2.4

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 (66) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +22 -22
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.full.js +24 -24
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  10. package/dist/formio.js +3 -3
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -1
  13. package/dist/formio.utils.js +1 -1
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  16. package/lib/cjs/Element.js +6 -3
  17. package/lib/cjs/Embed.js +3 -2
  18. package/lib/cjs/Formio.js +1 -1
  19. package/lib/cjs/Webform.js +4 -2
  20. package/lib/cjs/WebformBuilder.js +8 -4
  21. package/lib/cjs/Wizard.js +3 -3
  22. package/lib/cjs/components/_classes/component/Component.js +19 -11
  23. package/lib/cjs/components/address/Address.js +7 -5
  24. package/lib/cjs/components/button/Button.js +21 -15
  25. package/lib/cjs/components/datagrid/DataGrid.js +6 -5
  26. package/lib/cjs/components/datamap/DataMap.js +4 -2
  27. package/lib/cjs/components/day/Day.js +2 -1
  28. package/lib/cjs/components/editgrid/EditGrid.js +10 -8
  29. package/lib/cjs/components/file/File.js +11 -6
  30. package/lib/cjs/components/file/editForm/File.edit.file.d.ts +37 -16
  31. package/lib/cjs/components/file/editForm/File.edit.file.js +78 -25
  32. package/lib/cjs/components/form/Form.js +10 -4
  33. package/lib/cjs/components/radio/Radio.js +6 -3
  34. package/lib/cjs/components/recaptcha/ReCaptcha.js +5 -3
  35. package/lib/cjs/components/select/Select.js +12 -1
  36. package/lib/cjs/components/selectboxes/SelectBoxes.js +5 -2
  37. package/lib/cjs/components/signature/Signature.js +2 -1
  38. package/lib/cjs/components/table/Table.js +2 -1
  39. package/lib/cjs/components/tabs/Tabs.js +2 -1
  40. package/lib/cjs/package.json +1 -1
  41. package/lib/mjs/Element.js +3 -3
  42. package/lib/mjs/Embed.js +2 -2
  43. package/lib/mjs/Formio.js +1 -1
  44. package/lib/mjs/Webform.js +2 -2
  45. package/lib/mjs/WebformBuilder.js +4 -4
  46. package/lib/mjs/Wizard.js +1 -1
  47. package/lib/mjs/components/_classes/component/Component.js +10 -10
  48. package/lib/mjs/components/address/Address.js +3 -3
  49. package/lib/mjs/components/button/Button.js +15 -15
  50. package/lib/mjs/components/datagrid/DataGrid.js +4 -4
  51. package/lib/mjs/components/datamap/DataMap.js +2 -2
  52. package/lib/mjs/components/day/Day.js +1 -1
  53. package/lib/mjs/components/editgrid/EditGrid.js +5 -5
  54. package/lib/mjs/components/file/File.js +6 -6
  55. package/lib/mjs/components/file/editForm/File.edit.file.d.ts +37 -16
  56. package/lib/mjs/components/file/editForm/File.edit.file.js +78 -25
  57. package/lib/mjs/components/form/Form.js +7 -4
  58. package/lib/mjs/components/radio/Radio.js +3 -3
  59. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -3
  60. package/lib/mjs/components/select/Select.js +12 -1
  61. package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -2
  62. package/lib/mjs/components/signature/Signature.js +1 -1
  63. package/lib/mjs/components/table/Table.js +1 -1
  64. package/lib/mjs/components/tabs/Tabs.js +1 -1
  65. package/lib/mjs/package.json +1 -1
  66. package/package.json +2 -2
@@ -594,6 +594,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
594
594
  return editRow;
595
595
  }
596
596
  addRow() {
597
+ var _a;
597
598
  if (this.options.readOnly) {
598
599
  return;
599
600
  }
@@ -604,7 +605,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
604
605
  this.emptyRow = (0, utils_1.fastCloneDeep)(editRow.data);
605
606
  }
606
607
  if (this.inlineEditMode) {
607
- this.triggerChange();
608
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this);
608
609
  }
609
610
  this.emit('editGridAddRow', {
610
611
  component: this.component,
@@ -791,7 +792,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
791
792
  }
792
793
  }
793
794
  saveRow(rowIndex, modified) {
794
- var _a, _b;
795
+ var _a, _b, _c;
795
796
  const editRow = this.editRows[rowIndex];
796
797
  if (this.options.readOnly) {
797
798
  return;
@@ -836,7 +837,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
836
837
  row: editRow.data,
837
838
  instance: this
838
839
  });
839
- this.triggerChange({ modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });
840
+ (_c = this.triggerChange) === null || _c === void 0 ? void 0 : _c.call(this, { modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });
840
841
  if (this.component.rowDrafts) {
841
842
  editRow.components.forEach(comp => comp.setPristine(this.pristine));
842
843
  }
@@ -882,6 +883,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
882
883
  return editRow;
883
884
  }
884
885
  removeRow(rowIndex, modified) {
886
+ var _a;
885
887
  if (this.options.readOnly) {
886
888
  return;
887
889
  }
@@ -896,7 +898,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
896
898
  this.openWhenEmpty();
897
899
  this.updateRowsComponents(rowIndex);
898
900
  this.updateValue();
899
- this.triggerChange({ modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });
901
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this, { modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });
900
902
  this.checkValidity(null, true);
901
903
  this.checkData();
902
904
  this.redraw();
@@ -928,9 +930,9 @@ class EditGridComponent extends NestedArrayComponent_1.default {
928
930
  options.row = `${rowIndex}-${colIndex}`;
929
931
  options.rowIndex = rowIndex;
930
932
  options.onChange = (flags = {}, changed, modified) => {
931
- var _a, _b;
933
+ var _a, _b, _c, _d;
932
934
  if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {
933
- changed.instance.root.triggerChange(flags, changed, modified);
935
+ (_d = (_c = changed.instance.root) === null || _c === void 0 ? void 0 : _c.triggerChange) === null || _d === void 0 ? void 0 : _d.call(_c, flags, changed, modified);
934
936
  }
935
937
  else if (!this.component.modal) {
936
938
  this.triggerRootChange(flags, changed, modified);
@@ -1055,7 +1057,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1055
1057
  return true;
1056
1058
  }
1057
1059
  checkComponentValidity(data, dirty, row, options = {}, errors = []) {
1058
- var _a, _b;
1060
+ var _a, _b, _c;
1059
1061
  const { silentCheck, fromSubmission } = options;
1060
1062
  const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
1061
1063
  // If super tells us that component invalid and there is no need to update alerts, just return false
@@ -1105,7 +1107,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1105
1107
  if (allRowErrors.length && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted) && !message) {
1106
1108
  this._errors = this.setCustomValidity(message, dirty);
1107
1109
  errors.push(...this._errors);
1108
- this.root.showErrors([message]);
1110
+ (_c = this.root) === null || _c === void 0 ? void 0 : _c.showErrors([message]);
1109
1111
  }
1110
1112
  else {
1111
1113
  this._errors = this.setCustomValidity(message, dirty);
@@ -398,13 +398,14 @@ class FileComponent extends Field_1.default {
398
398
  });
399
399
  this.refs.restoreFile.forEach((fileToRestore, index) => {
400
400
  this.addEventListener(fileToRestore, 'click', (event) => {
401
+ var _a;
401
402
  event.preventDefault();
402
403
  const fileInfo = this.filesToSync.filesToDelete[index];
403
404
  delete fileInfo.status;
404
405
  delete fileInfo.message;
405
406
  this.filesToSync.filesToDelete.splice(index, 1);
406
407
  this.dataValue.push(fileInfo);
407
- this.triggerChange();
408
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this);
408
409
  this.redraw();
409
410
  });
410
411
  });
@@ -638,8 +639,9 @@ class FileComponent extends Field_1.default {
638
639
  };
639
640
  }
640
641
  handleSubmissionRevisions(file) {
642
+ var _a;
641
643
  return __awaiter(this, void 0, void 0, function* () {
642
- if (this.root.form.submissionRevisions !== 'true') {
644
+ if (((_a = this.root) === null || _a === void 0 ? void 0 : _a.form.submissionRevisions) !== 'true') {
643
645
  return '';
644
646
  }
645
647
  const bmf = new browser_md5_file_1.default();
@@ -719,10 +721,11 @@ class FileComponent extends Field_1.default {
719
721
  return this.validateFileSettings(file);
720
722
  }
721
723
  getGroupPermissions() {
724
+ var _a;
722
725
  let groupKey = null;
723
726
  let groupPermissions = null;
724
727
  //Iterate through form components to find group resource if one exists
725
- this.root.everyComponent((element) => {
728
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.everyComponent((element) => {
726
729
  var _a, _b;
727
730
  if (((_a = element.component) === null || _a === void 0 ? void 0 : _a.submissionAccess) || ((_b = element.component) === null || _b === void 0 ? void 0 : _b.defaultPermission)) {
728
731
  groupPermissions = !element.component.submissionAccess ? [
@@ -739,14 +742,15 @@ class FileComponent extends Field_1.default {
739
742
  return { groupKey, groupPermissions };
740
743
  }
741
744
  triggerFileProcessor(file) {
745
+ var _a, _b;
742
746
  return __awaiter(this, void 0, void 0, function* () {
743
747
  let processedFile = null;
744
- if (this.root.options.fileProcessor) {
748
+ if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.options.fileProcessor) {
745
749
  try {
746
750
  if (this.refs.fileProcessingLoader) {
747
751
  this.refs.fileProcessingLoader.style.display = 'block';
748
752
  }
749
- const fileProcessorHandler = (0, fileProcessor_1.default)(this.fileService, this.root.options.fileProcessor);
753
+ const fileProcessorHandler = (0, fileProcessor_1.default)(this.fileService, (_b = this.root) === null || _b === void 0 ? void 0 : _b.options.fileProcessor);
750
754
  processedFile = yield fileProcessorHandler(file, this.component.properties);
751
755
  }
752
756
  catch (err) {
@@ -964,6 +968,7 @@ class FileComponent extends Field_1.default {
964
968
  });
965
969
  }
966
970
  syncFiles() {
971
+ var _a;
967
972
  return __awaiter(this, void 0, void 0, function* () {
968
973
  this.isSyncing = true;
969
974
  this.fileDropHidden = true;
@@ -983,7 +988,7 @@ class FileComponent extends Field_1.default {
983
988
  .filter(file => { var _a; return ((_a = file.fileToSync) === null || _a === void 0 ? void 0 : _a.status) === 'success'; })
984
989
  .map(file => file.fileInfo);
985
990
  this.dataValue.push(...data);
986
- this.triggerChange();
991
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this);
987
992
  return Promise.resolve();
988
993
  }
989
994
  catch (err) {
@@ -17,6 +17,7 @@ declare const _default: ({
17
17
  rows?: undefined;
18
18
  editor?: undefined;
19
19
  as?: undefined;
20
+ logic?: undefined;
20
21
  optionsLabelPosition?: undefined;
21
22
  inline?: undefined;
22
23
  defaultValue?: undefined;
@@ -33,7 +34,6 @@ declare const _default: ({
33
34
  var: string;
34
35
  })[];
35
36
  in?: undefined;
36
- '!=='?: undefined;
37
37
  '=='?: undefined;
38
38
  };
39
39
  };
@@ -47,6 +47,7 @@ declare const _default: ({
47
47
  rows?: undefined;
48
48
  editor?: undefined;
49
49
  as?: undefined;
50
+ logic?: undefined;
50
51
  optionsLabelPosition?: undefined;
51
52
  inline?: undefined;
52
53
  defaultValue?: undefined;
@@ -81,7 +82,6 @@ declare const _default: ({
81
82
  var: string;
82
83
  })[];
83
84
  in?: undefined;
84
- '!=='?: undefined;
85
85
  '=='?: undefined;
86
86
  };
87
87
  };
@@ -94,6 +94,7 @@ declare const _default: ({
94
94
  rows?: undefined;
95
95
  editor?: undefined;
96
96
  as?: undefined;
97
+ logic?: undefined;
97
98
  optionsLabelPosition?: undefined;
98
99
  inline?: undefined;
99
100
  defaultValue?: undefined;
@@ -112,7 +113,6 @@ declare const _default: ({
112
113
  var: string;
113
114
  })[];
114
115
  in?: undefined;
115
- '!=='?: undefined;
116
116
  '=='?: undefined;
117
117
  };
118
118
  };
@@ -124,6 +124,7 @@ declare const _default: ({
124
124
  rows?: undefined;
125
125
  editor?: undefined;
126
126
  as?: undefined;
127
+ logic?: undefined;
127
128
  optionsLabelPosition?: undefined;
128
129
  inline?: undefined;
129
130
  defaultValue?: undefined;
@@ -141,7 +142,6 @@ declare const _default: ({
141
142
  var: string;
142
143
  })[];
143
144
  '==='?: undefined;
144
- '!=='?: undefined;
145
145
  '=='?: undefined;
146
146
  };
147
147
  };
@@ -154,6 +154,7 @@ declare const _default: ({
154
154
  rows?: undefined;
155
155
  editor?: undefined;
156
156
  as?: undefined;
157
+ logic?: undefined;
157
158
  optionsLabelPosition?: undefined;
158
159
  inline?: undefined;
159
160
  defaultValue?: undefined;
@@ -175,7 +176,6 @@ declare const _default: ({
175
176
  var: string;
176
177
  })[];
177
178
  in?: undefined;
178
- '!=='?: undefined;
179
179
  '=='?: undefined;
180
180
  };
181
181
  };
@@ -184,6 +184,7 @@ declare const _default: ({
184
184
  data?: undefined;
185
185
  tableView?: undefined;
186
186
  components?: undefined;
187
+ logic?: undefined;
187
188
  optionsLabelPosition?: undefined;
188
189
  inline?: undefined;
189
190
  defaultValue?: undefined;
@@ -196,19 +197,35 @@ declare const _default: ({
196
197
  placeholder: string;
197
198
  tooltip: string;
198
199
  weight: number;
199
- conditional: {
200
- json: {
201
- '!==': (string | {
202
- var: string;
203
- })[];
204
- '==='?: undefined;
205
- in?: undefined;
206
- '=='?: undefined;
200
+ logic: {
201
+ name: string;
202
+ trigger: {
203
+ type: string;
204
+ simple: {
205
+ show: boolean;
206
+ conjunction: string;
207
+ conditions: {
208
+ component: string;
209
+ operator: string;
210
+ value: string;
211
+ }[];
212
+ };
207
213
  };
208
- };
214
+ actions: {
215
+ name: string;
216
+ type: string;
217
+ property: {
218
+ label: string;
219
+ value: string;
220
+ type: string;
221
+ };
222
+ text: string;
223
+ }[];
224
+ }[];
209
225
  valueProperty?: undefined;
210
226
  dataSrc?: undefined;
211
227
  data?: undefined;
228
+ conditional?: undefined;
212
229
  tableView?: undefined;
213
230
  components?: undefined;
214
231
  rows?: undefined;
@@ -235,6 +252,7 @@ declare const _default: ({
235
252
  rows?: undefined;
236
253
  editor?: undefined;
237
254
  as?: undefined;
255
+ logic?: undefined;
238
256
  optionsLabelPosition?: undefined;
239
257
  inline?: undefined;
240
258
  defaultValue?: undefined;
@@ -256,6 +274,7 @@ declare const _default: ({
256
274
  rows?: undefined;
257
275
  editor?: undefined;
258
276
  as?: undefined;
277
+ logic?: undefined;
259
278
  optionsLabelPosition?: undefined;
260
279
  inline?: undefined;
261
280
  defaultValue?: undefined;
@@ -273,7 +292,6 @@ declare const _default: ({
273
292
  var: string;
274
293
  })[];
275
294
  in?: undefined;
276
- '!=='?: undefined;
277
295
  '=='?: undefined;
278
296
  };
279
297
  };
@@ -286,6 +304,7 @@ declare const _default: ({
286
304
  rows?: undefined;
287
305
  editor?: undefined;
288
306
  as?: undefined;
307
+ logic?: undefined;
289
308
  optionsLabelPosition?: undefined;
290
309
  inline?: undefined;
291
310
  defaultValue?: undefined;
@@ -305,7 +324,6 @@ declare const _default: ({
305
324
  })[];
306
325
  '==='?: undefined;
307
326
  in?: undefined;
308
- '!=='?: undefined;
309
327
  };
310
328
  };
311
329
  valueProperty?: undefined;
@@ -316,6 +334,7 @@ declare const _default: ({
316
334
  rows?: undefined;
317
335
  editor?: undefined;
318
336
  as?: undefined;
337
+ logic?: undefined;
319
338
  optionsLabelPosition?: undefined;
320
339
  inline?: undefined;
321
340
  defaultValue?: undefined;
@@ -344,6 +363,7 @@ declare const _default: ({
344
363
  rows?: undefined;
345
364
  editor?: undefined;
346
365
  as?: undefined;
366
+ logic?: undefined;
347
367
  } | {
348
368
  type: string;
349
369
  input: boolean;
@@ -366,6 +386,7 @@ declare const _default: ({
366
386
  rows?: undefined;
367
387
  editor?: undefined;
368
388
  as?: undefined;
389
+ logic?: undefined;
369
390
  optionsLabelPosition?: undefined;
370
391
  inline?: undefined;
371
392
  defaultValue?: undefined;
@@ -152,8 +152,7 @@ exports.default = [
152
152
  }, 'url']
153
153
  }
154
154
  }
155
- },
156
- {
155
+ }, {
157
156
  type: 'textfield',
158
157
  input: true,
159
158
  key: 'dir',
@@ -161,29 +160,83 @@ exports.default = [
161
160
  placeholder: '(optional) Enter a directory for the files',
162
161
  tooltip: 'This will place all the files uploaded in this field in the directory',
163
162
  weight: 20,
164
- conditional: {
165
- json: {
166
- '!==': [{
167
- var: 'data.storage'
168
- }, 'googledrive']
169
- }
170
- }
171
- },
172
- {
173
- type: 'textfield',
174
- input: true,
175
- key: 'dir',
176
- label: 'Folder ID',
177
- placeholder: '(optional) Enter an ID of the folder for the files',
178
- tooltip: 'This will place all the files uploaded in this field in the folder',
179
- weight: 20,
180
- conditional: {
181
- json: {
182
- '===': [{
183
- var: 'data.storage'
184
- }, 'googledrive']
185
- }
186
- }
163
+ logic: [
164
+ {
165
+ name: 'Change To File ID',
166
+ trigger: {
167
+ type: 'simple',
168
+ simple: {
169
+ show: true,
170
+ conjunction: 'all',
171
+ conditions: [
172
+ {
173
+ component: 'storage',
174
+ operator: 'isEqual',
175
+ value: 'googledrive',
176
+ },
177
+ ],
178
+ },
179
+ },
180
+ actions: [
181
+ {
182
+ name: 'Change placeholder',
183
+ type: 'property',
184
+ property: {
185
+ label: 'Placeholder',
186
+ value: 'placeholder',
187
+ type: 'string',
188
+ },
189
+ text: '(optional) Enter an ID of the folder for the files',
190
+ }, {
191
+ name: 'Change label',
192
+ type: 'property',
193
+ property: {
194
+ label: 'Label',
195
+ value: 'label',
196
+ type: 'string',
197
+ },
198
+ text: 'Folder ID',
199
+ },
200
+ ],
201
+ }, {
202
+ name: 'Change to Directory',
203
+ trigger: {
204
+ type: 'simple',
205
+ simple: {
206
+ show: true,
207
+ conjunction: 'all',
208
+ conditions: [
209
+ {
210
+ component: 'storage',
211
+ operator: 'isNotEqual',
212
+ value: 'googledrive',
213
+ },
214
+ ],
215
+ },
216
+ },
217
+ actions: [
218
+ {
219
+ name: 'Change placeholder',
220
+ type: 'property',
221
+ property: {
222
+ label: 'Placeholder',
223
+ value: 'placeholder',
224
+ type: 'string',
225
+ },
226
+ text: '(optional) Enter a directory for the files',
227
+ }, {
228
+ name: 'Change label',
229
+ type: 'property',
230
+ property: {
231
+ label: 'Label',
232
+ value: 'label',
233
+ type: 'string',
234
+ },
235
+ text: 'Directory',
236
+ },
237
+ ],
238
+ },
239
+ ],
187
240
  },
188
241
  {
189
242
  type: 'textfield',
@@ -282,6 +282,7 @@ class FormComponent extends Component_1.default {
282
282
  return Promise.resolve();
283
283
  }
284
284
  return this.subFormReady.then(() => {
285
+ var _a;
285
286
  this.empty(element);
286
287
  if (this.options.builder) {
287
288
  this.setContent(element, this.ce('div', {
@@ -302,7 +303,7 @@ class FormComponent extends Component_1.default {
302
303
  };
303
304
  if (this.subForm) {
304
305
  if (this.isNestedWizard) {
305
- element = this.root.element;
306
+ element = (_a = this.root) === null || _a === void 0 ? void 0 : _a.element;
306
307
  }
307
308
  return this.subForm.attach(element).then(() => {
308
309
  this.valueChanged = this.hasSetValue;
@@ -433,9 +434,10 @@ class FormComponent extends Component_1.default {
433
434
  this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
434
435
  this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
435
436
  this.subForm.on('change', () => {
437
+ var _a;
436
438
  if (this.subForm && !this.shouldConditionallyClear()) {
437
439
  this.dataValue = this.subForm.getValue();
438
- this.triggerChange({
440
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this, {
439
441
  noEmit: true
440
442
  });
441
443
  }
@@ -546,7 +548,10 @@ class FormComponent extends Component_1.default {
546
548
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
547
549
  */
548
550
  get shouldSubmit() {
549
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.shouldConditionallyClear();
551
+ return (this.subFormReady &&
552
+ (!this.component.hasOwnProperty('reference') || this.component.reference) &&
553
+ !this.shouldConditionallyClear() &&
554
+ !(this.component.hidden && this.component.clearOnHide));
550
555
  }
551
556
  /**
552
557
  * Returns the data for the subform.
@@ -741,6 +746,7 @@ class FormComponent extends Component_1.default {
741
746
  return super.visible;
742
747
  }
743
748
  set visible(value) {
749
+ var _a;
744
750
  const isNestedWizard = this.isNestedWizard;
745
751
  if (this._visible !== value) {
746
752
  this._visible = value;
@@ -759,7 +765,7 @@ class FormComponent extends Component_1.default {
759
765
  isNestedWizard ? this.rebuild() : this.redraw();
760
766
  }
761
767
  if (!value && isNestedWizard) {
762
- this.root.redraw();
768
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.redraw();
763
769
  }
764
770
  }
765
771
  get parentVisible() {
@@ -334,6 +334,7 @@ class RadioComponent extends ListComponent_1.default {
334
334
  this.redraw();
335
335
  }
336
336
  setItems(items) {
337
+ var _a;
337
338
  const listData = [];
338
339
  items === null || items === void 0 ? void 0 : items.forEach((item, i) => {
339
340
  const valueAtProperty = lodash_1.default.get(item, this.component.valueProperty);
@@ -348,7 +349,7 @@ class RadioComponent extends ListComponent_1.default {
348
349
  }
349
350
  });
350
351
  if (this.isSelectURL) {
351
- const submission = this.root.submission;
352
+ const submission = (_a = this.root) === null || _a === void 0 ? void 0 : _a.submission;
352
353
  if (!submission.metadata) {
353
354
  submission.metadata = {};
354
355
  }
@@ -380,6 +381,7 @@ class RadioComponent extends ListComponent_1.default {
380
381
  }
381
382
  }
382
383
  updateValue(value, flags) {
384
+ var _a;
383
385
  const changed = super.updateValue(value, flags);
384
386
  if (changed) {
385
387
  this.setSelectedClasses();
@@ -395,7 +397,7 @@ class RadioComponent extends ListComponent_1.default {
395
397
  const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
396
398
  if (shouldResetValue) {
397
399
  this.resetValue();
398
- this.triggerChange(flags);
400
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this, flags);
399
401
  this.setSelectedClasses();
400
402
  }
401
403
  this.previousValue = this.dataValue;
@@ -407,6 +409,7 @@ class RadioComponent extends ListComponent_1.default {
407
409
  * @returns {*} - Returns the normalized value
408
410
  */
409
411
  normalizeValue(value) {
412
+ var _a;
410
413
  const dataType = this.component.dataType || 'auto';
411
414
  if (value === this.emptyValue) {
412
415
  return value;
@@ -439,7 +442,7 @@ class RadioComponent extends ListComponent_1.default {
439
442
  break;
440
443
  }
441
444
  if (this.isSelectURL && this.templateData && this.templateData[value]) {
442
- const submission = this.root.submission;
445
+ const submission = (_a = this.root) === null || _a === void 0 ? void 0 : _a.submission;
443
446
  if (!submission.metadata.selectData) {
444
447
  submission.metadata.selectData = {};
445
448
  }
@@ -47,12 +47,13 @@ class ReCaptchaComponent extends Component_1.default {
47
47
  }
48
48
  }
49
49
  createInput() {
50
+ var _a;
50
51
  if (this.builderMode) {
51
52
  // We need to see it in builder mode.
52
53
  this.append(this.text(this.name));
53
54
  }
54
55
  else {
55
- const siteKey = (0, get_1.default)(this.root.form, 'settings.recaptcha.siteKey');
56
+ const siteKey = (0, get_1.default)((_a = this.root) === null || _a === void 0 ? void 0 : _a.form, 'settings.recaptcha.siteKey');
56
57
  if (siteKey) {
57
58
  const recaptchaApiScriptUrl = `https://www.google.com/recaptcha/api.js?render=${siteKey}`;
58
59
  this.recaptchaApiReady = Formio_1.Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
@@ -69,14 +70,15 @@ class ReCaptchaComponent extends Component_1.default {
69
70
  return true;
70
71
  }
71
72
  verify(actionName) {
73
+ var _a, _b;
72
74
  return __awaiter(this, void 0, void 0, function* () {
73
- const siteKey = (0, get_1.default)(this.root.form, 'settings.recaptcha.siteKey');
75
+ const siteKey = (0, get_1.default)((_a = this.root) === null || _a === void 0 ? void 0 : _a.form, 'settings.recaptcha.siteKey');
74
76
  if (!siteKey) {
75
77
  console.warn('There is no Site Key specified in settings in form JSON');
76
78
  return;
77
79
  }
78
80
  if (!this.recaptchaApiReady) {
79
- const recaptchaApiScriptUrl = `https://www.google.com/recaptcha/api.js?render=${(0, get_1.default)(this.root.form, 'settings.recaptcha.siteKey')}`;
81
+ const recaptchaApiScriptUrl = `https://www.google.com/recaptcha/api.js?render=${(0, get_1.default)((_b = this.root) === null || _b === void 0 ? void 0 : _b.form, 'settings.recaptcha.siteKey')}`;
80
82
  this.recaptchaApiReady = Formio_1.Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
81
83
  }
82
84
  try {
@@ -226,7 +226,14 @@ class SelectComponent extends ListComponent_1.default {
226
226
  return this.component.dataSrc === 'resource' && this.valueProperty === 'data';
227
227
  }
228
228
  selectValueAndLabel(data) {
229
- const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
229
+ let value;
230
+ // If the select is a resource reference, use the actual object value
231
+ if (this.component.reference && this.isSelectResource) {
232
+ value = this.getOptionValue(data);
233
+ }
234
+ else {
235
+ value = this.getOptionValue(this.isEntireObjectDisplay() && !this.itemValue(data) ? data : this.itemValue(data));
236
+ }
230
237
  return {
231
238
  value,
232
239
  label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)
@@ -265,6 +272,10 @@ class SelectComponent extends ListComponent_1.default {
265
272
  else {
266
273
  data = selectData;
267
274
  }
275
+ // use template data for reference fields to make sure the data is updated
276
+ if (this.component.reference && this.templateData[templateValue]) {
277
+ data = this.templateData[templateValue];
278
+ }
268
279
  }
269
280
  }
270
281
  if (typeof data === 'string' || typeof data === 'number') {
@@ -116,6 +116,7 @@ class SelectBoxesComponent extends Radio_1.default {
116
116
  * @returns {*} - The normalized value
117
117
  */
118
118
  normalizeValue(value) {
119
+ var _a;
119
120
  value = value || {};
120
121
  if (typeof value !== 'object') {
121
122
  if (typeof value === 'string') {
@@ -133,8 +134,10 @@ class SelectBoxesComponent extends Radio_1.default {
133
134
  });
134
135
  }
135
136
  const checkedValues = lodash_1.default.keys(lodash_1.default.pickBy(value, (val) => val));
136
- if (this.isSelectURL && this.templateData && lodash_1.default.every(checkedValues, (val) => this.templateData[val])) {
137
- const submission = this.root.submission;
137
+ if (this.isSelectURL &&
138
+ this.templateData &&
139
+ lodash_1.default.every(checkedValues, (val) => this.templateData[val])) {
140
+ const submission = (_a = this.root) === null || _a === void 0 ? void 0 : _a.submission;
138
141
  if (!submission.metadata.selectData) {
139
142
  submission.metadata.selectData = {};
140
143
  }
@@ -82,6 +82,7 @@ class SignatureComponent extends Input_1.default {
82
82
  return this.component.hideLabel;
83
83
  }
84
84
  setValue(value, flags = {}) {
85
+ var _a;
85
86
  const changed = super.setValue(value, flags);
86
87
  if (this.refs.signatureImage && (this.options.readOnly || this.disabled)) {
87
88
  this.refs.signatureImage.setAttribute('src', value);
@@ -92,7 +93,7 @@ class SignatureComponent extends Input_1.default {
92
93
  this.signaturePad.clear();
93
94
  }
94
95
  else if (changed) {
95
- this.triggerChange();
96
+ (_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this);
96
97
  }
97
98
  }
98
99
  if (this.signaturePad && this.dataValue && this.signaturePad.isEmpty()) {