@formio/js 5.1.0-dev.6112.06b0f26 → 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 (39) hide show
  1. package/dist/formio.form.js +11 -11
  2. package/dist/formio.form.min.js +1 -1
  3. package/dist/formio.full.js +11 -11
  4. package/dist/formio.full.min.js +1 -1
  5. package/dist/formio.js +1 -1
  6. package/dist/formio.min.js +1 -1
  7. package/dist/formio.utils.js +1 -1
  8. package/dist/formio.utils.min.js +1 -1
  9. package/lib/cjs/Webform.js +1 -1
  10. package/lib/cjs/components/Components.js +7 -1
  11. package/lib/cjs/components/_classes/component/Component.js +20 -7
  12. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
  13. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
  14. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
  15. package/lib/cjs/components/_classes/nested/NestedComponent.js +13 -3
  16. package/lib/cjs/components/address/Address.js +1 -1
  17. package/lib/cjs/components/datagrid/DataGrid.js +4 -0
  18. package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
  19. package/lib/cjs/components/editgrid/EditGrid.js +0 -8
  20. package/lib/cjs/components/radio/Radio.d.ts +1 -0
  21. package/lib/cjs/components/radio/Radio.js +4 -4
  22. package/lib/cjs/providers/storage/url.js +7 -3
  23. package/lib/cjs/utils/utils.js +0 -4
  24. package/lib/mjs/Webform.js +1 -1
  25. package/lib/mjs/components/Components.js +7 -1
  26. package/lib/mjs/components/_classes/component/Component.js +19 -6
  27. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
  28. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
  29. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
  30. package/lib/mjs/components/_classes/nested/NestedComponent.js +13 -3
  31. package/lib/mjs/components/address/Address.js +1 -1
  32. package/lib/mjs/components/datagrid/DataGrid.js +4 -0
  33. package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
  34. package/lib/mjs/components/editgrid/EditGrid.js +0 -8
  35. package/lib/mjs/components/radio/Radio.d.ts +1 -0
  36. package/lib/mjs/components/radio/Radio.js +4 -4
  37. package/lib/mjs/providers/storage/url.js +7 -3
  38. package/lib/mjs/utils/utils.js +0 -4
  39. package/package.json +1 -1
@@ -1119,7 +1119,7 @@ class Webform extends NestedDataComponent_1.default {
1119
1119
  const componentErrors = {};
1120
1120
  errors.forEach((err) => {
1121
1121
  var _a, _b;
1122
- const path = err.path || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1122
+ const path = (0, utils_1.getStringFromComponentPath)(err.path) || ((_a = err.context) === null || _a === void 0 ? void 0 : _a.path) || ((_b = err.component) === null || _b === void 0 ? void 0 : _b.key);
1123
1123
  if (!componentErrors[path]) {
1124
1124
  componentErrors[path] = [];
1125
1125
  }
@@ -57,7 +57,7 @@ class Components {
57
57
  // eslint-disable-next-line new-cap
58
58
  comp = new Components.components['datagrid'](component, options, data);
59
59
  }
60
- else if (component.tree) {
60
+ else if (component.tree || (component.input && Array.isArray(component.components))) {
61
61
  // eslint-disable-next-line new-cap
62
62
  comp = new Components.components['nesteddata'](component, options, data);
63
63
  }
@@ -75,6 +75,12 @@ class Components {
75
75
  if (comp.path) {
76
76
  comp.componentsMap[comp.path] = comp;
77
77
  }
78
+ // Reset the componentMatches on the root element if any new component is created.
79
+ let parent = comp.parent;
80
+ while (parent) {
81
+ parent.componentMatches = {};
82
+ parent = parent.parent;
83
+ }
78
84
  return comp;
79
85
  }
80
86
  }
@@ -1170,15 +1170,21 @@ class Component extends Element_1.default {
1170
1170
  * @returns {string} - The modal preview template.
1171
1171
  */
1172
1172
  getModalPreviewTemplate() {
1173
- var _a;
1173
+ var _a, _b;
1174
1174
  const dataValue = this.component.type === 'password' ? this.dataValue.replace(/./g, '•') : this.dataValue;
1175
1175
  let modalLabel;
1176
1176
  if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
1177
1177
  modalLabel = { className: 'field-required' };
1178
1178
  }
1179
+ let messages = '';
1180
+ if ((_b = this.errors) === null || _b === void 0 ? void 0 : _b.length) {
1181
+ messages = this.errors.map((err) => {
1182
+ return err.level === 'error' ? this.renderTemplate('message', Object.assign({}, err)) : '';
1183
+ }).join('');
1184
+ }
1179
1185
  return this.renderModalPreview({
1180
1186
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('clickToSetValue'),
1181
- messages: '',
1187
+ messages,
1182
1188
  labelInfo: modalLabel,
1183
1189
  });
1184
1190
  }
@@ -2592,11 +2598,13 @@ class Component extends Element_1.default {
2592
2598
  });
2593
2599
  if (utils_1.default.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
2594
2600
  utils_1.default.eachComponent(this.components, (component) => {
2595
- component.setValue(null, {
2596
- noUpdateEvent: true,
2597
- noDefault: true
2598
- });
2599
- component.unset();
2601
+ if (component.component.clearOnHide !== false) {
2602
+ component.setValue(null, {
2603
+ noUpdateEvent: true,
2604
+ noDefault: true
2605
+ });
2606
+ component.unset();
2607
+ }
2600
2608
  });
2601
2609
  }
2602
2610
  this.unset();
@@ -2724,6 +2732,11 @@ class Component extends Element_1.default {
2724
2732
  this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2725
2733
  }
2726
2734
  }
2735
+ // Also reset value of the modal component, otherwise it will keep the old value locally and the preview
2736
+ // element won't refresh
2737
+ if (this.componentModal && flags && flags.resetValue) {
2738
+ this.componentModal.setValue(value);
2739
+ }
2727
2740
  return changed;
2728
2741
  }
2729
2742
  /**
@@ -82,6 +82,7 @@ declare const _default: ({
82
82
  inline?: undefined;
83
83
  defaultValue?: undefined;
84
84
  values?: undefined;
85
+ customConditional?: undefined;
85
86
  logic?: undefined;
86
87
  dataSrc?: undefined;
87
88
  valueProperty?: undefined;
@@ -101,6 +102,7 @@ declare const _default: ({
101
102
  inline?: undefined;
102
103
  defaultValue?: undefined;
103
104
  values?: undefined;
105
+ customConditional?: undefined;
104
106
  logic?: undefined;
105
107
  dataSrc?: undefined;
106
108
  valueProperty?: undefined;
@@ -126,6 +128,7 @@ declare const _default: ({
126
128
  value: string;
127
129
  })[];
128
130
  placeholder?: undefined;
131
+ customConditional?: undefined;
129
132
  logic?: undefined;
130
133
  dataSrc?: undefined;
131
134
  valueProperty?: undefined;
@@ -141,6 +144,7 @@ declare const _default: ({
141
144
  tooltip: string;
142
145
  key: string;
143
146
  input: boolean;
147
+ customConditional: string;
144
148
  logic: ({
145
149
  name: string;
146
150
  trigger: {
@@ -211,6 +215,7 @@ declare const _default: ({
211
215
  inline?: undefined;
212
216
  defaultValue?: undefined;
213
217
  values?: undefined;
218
+ customConditional?: undefined;
214
219
  logic?: undefined;
215
220
  as?: undefined;
216
221
  editor?: undefined;
@@ -226,6 +231,7 @@ declare const _default: ({
226
231
  placeholder?: undefined;
227
232
  inline?: undefined;
228
233
  values?: undefined;
234
+ customConditional?: undefined;
229
235
  logic?: undefined;
230
236
  dataSrc?: undefined;
231
237
  valueProperty?: undefined;
@@ -248,6 +254,7 @@ declare const _default: ({
248
254
  placeholder?: undefined;
249
255
  inline?: undefined;
250
256
  values?: undefined;
257
+ customConditional?: undefined;
251
258
  logic?: undefined;
252
259
  dataSrc?: undefined;
253
260
  valueProperty?: undefined;
@@ -61,6 +61,7 @@ exports.default = [
61
61
  tooltip: 'Encrypt this field on the server. This is two way encryption which is not suitable for passwords.',
62
62
  key: 'encrypted',
63
63
  input: true,
64
+ customConditional: 'show = data.encrypted;',
64
65
  logic: [
65
66
  {
66
67
  name: 'disabled',
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
108
108
  * @returns {any} - The component that is located.
109
109
  */
110
110
  getComponent(path: string): any;
111
+ componentMatches: {} | undefined;
111
112
  /**
112
113
  * Return a component provided the Id of the component.
113
114
  * @param {string} id - The Id of the component.
@@ -311,6 +311,13 @@ class NestedComponent extends Field_1.default {
311
311
  */
312
312
  getComponent(path) {
313
313
  var _a;
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
+ }
314
321
  path = utils_1.default.getStringFromComponentPath(path);
315
322
  const matches = {
316
323
  path: undefined,
@@ -336,7 +343,8 @@ class NestedComponent extends Field_1.default {
336
343
  return match;
337
344
  });
338
345
  });
339
- return (_a = utils_1.default.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.
@@ -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);
@@ -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;
@@ -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) {
@@ -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';
@@ -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;
@@ -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;
@@ -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;
@@ -400,9 +402,7 @@ class RadioComponent extends ListComponent_1.default {
400
402
  this.currentValue = this.dataValue;
401
403
  const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
402
404
  if (shouldResetValue) {
403
- this.resetValue();
404
- this.triggerChange(flags);
405
- this.setSelectedClasses();
405
+ this.uncheckValue(flags);
406
406
  }
407
407
  this.previousValue = this.dataValue;
408
408
  return changed;
@@ -127,13 +127,17 @@ function url(formio) {
127
127
  deleteFile(fileInfo, options) {
128
128
  return new Promise((resolve, reject) => {
129
129
  const xhr = new XMLHttpRequest();
130
- xhr.open('DELETE', fileInfo.url, true);
130
+ xhr.open("DELETE", fileInfo.url, true);
131
+ const token = formio.getToken();
132
+ if (token) {
133
+ xhr.setRequestHeader("x-jwt-token", token);
134
+ }
131
135
  xhr.onload = () => {
132
136
  if (xhr.status >= 200 && xhr.status < 300) {
133
- resolve('File deleted');
137
+ resolve("File deleted");
134
138
  }
135
139
  else {
136
- reject(xhr.response || 'Unable to delete file');
140
+ reject(xhr.response || "Unable to delete file");
137
141
  }
138
142
  };
139
143
  if (options) {
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToDayjs = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.dayjsDate = exports.shouldHandleTimezone = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = void 0;
7
7
  exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.getFocusableElements = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.fastCloneDeep = exports.sanitize = void 0;
8
- /* global jQuery */
9
8
  const lodash_1 = __importDefault(require("lodash"));
10
9
  const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
11
10
  const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
@@ -1064,9 +1063,6 @@ function bootstrapVersion(options) {
1064
1063
  if (options.bootstrap) {
1065
1064
  return options.bootstrap;
1066
1065
  }
1067
- if ((typeof jQuery === 'function') && (typeof jQuery().collapse === 'function')) {
1068
- return parseInt(jQuery.fn.collapse.Constructor.VERSION.split('.')[0], 10);
1069
- }
1070
1066
  if (window.bootstrap && window.bootstrap.Collapse) {
1071
1067
  return parseInt(window.bootstrap.Collapse.VERSION.split('.')[0], 10);
1072
1068
  }
@@ -1121,7 +1121,7 @@ export default class Webform extends NestedDataComponent {
1121
1121
  // Mark any components as invalid if in a custom message.
1122
1122
  const componentErrors = {};
1123
1123
  errors.forEach((err) => {
1124
- const path = err.path || err.context?.path || err.component?.key;
1124
+ const path = getStringFromComponentPath(err.path) || err.context?.path || err.component?.key;
1125
1125
  if (!componentErrors[path]) {
1126
1126
  componentErrors[path] = [];
1127
1127
  }
@@ -54,7 +54,7 @@ export default class Components {
54
54
  // eslint-disable-next-line new-cap
55
55
  comp = new Components.components['datagrid'](component, options, data);
56
56
  }
57
- else if (component.tree) {
57
+ else if (component.tree || (component.input && Array.isArray(component.components))) {
58
58
  // eslint-disable-next-line new-cap
59
59
  comp = new Components.components['nesteddata'](component, options, data);
60
60
  }
@@ -72,6 +72,12 @@ export default class Components {
72
72
  if (comp.path) {
73
73
  comp.componentsMap[comp.path] = comp;
74
74
  }
75
+ // Reset the componentMatches on the root element if any new component is created.
76
+ let parent = comp.parent;
77
+ while (parent) {
78
+ parent.componentMatches = {};
79
+ parent = parent.parent;
80
+ }
75
81
  return comp;
76
82
  }
77
83
  }
@@ -1160,9 +1160,15 @@ export default class Component extends Element {
1160
1160
  if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
1161
1161
  modalLabel = { className: 'field-required' };
1162
1162
  }
1163
+ let messages = '';
1164
+ if (this.errors?.length) {
1165
+ messages = this.errors.map((err) => {
1166
+ return err.level === 'error' ? this.renderTemplate('message', { ...err }) : '';
1167
+ }).join('');
1168
+ }
1163
1169
  return this.renderModalPreview({
1164
1170
  previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('clickToSetValue'),
1165
- messages: '',
1171
+ messages,
1166
1172
  labelInfo: modalLabel,
1167
1173
  });
1168
1174
  }
@@ -2584,11 +2590,13 @@ export default class Component extends Element {
2584
2590
  });
2585
2591
  if (FormioUtils.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
2586
2592
  FormioUtils.eachComponent(this.components, (component) => {
2587
- component.setValue(null, {
2588
- noUpdateEvent: true,
2589
- noDefault: true
2590
- });
2591
- component.unset();
2593
+ if (component.component.clearOnHide !== false) {
2594
+ component.setValue(null, {
2595
+ noUpdateEvent: true,
2596
+ noDefault: true
2597
+ });
2598
+ component.unset();
2599
+ }
2592
2600
  });
2593
2601
  }
2594
2602
  this.unset();
@@ -2716,6 +2724,11 @@ export default class Component extends Element {
2716
2724
  this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
2717
2725
  }
2718
2726
  }
2727
+ // Also reset value of the modal component, otherwise it will keep the old value locally and the preview
2728
+ // element won't refresh
2729
+ if (this.componentModal && flags && flags.resetValue) {
2730
+ this.componentModal.setValue(value);
2731
+ }
2719
2732
  return changed;
2720
2733
  }
2721
2734
  /**
@@ -82,6 +82,7 @@ declare const _default: ({
82
82
  inline?: undefined;
83
83
  defaultValue?: undefined;
84
84
  values?: undefined;
85
+ customConditional?: undefined;
85
86
  logic?: undefined;
86
87
  dataSrc?: undefined;
87
88
  valueProperty?: undefined;
@@ -101,6 +102,7 @@ declare const _default: ({
101
102
  inline?: undefined;
102
103
  defaultValue?: undefined;
103
104
  values?: undefined;
105
+ customConditional?: undefined;
104
106
  logic?: undefined;
105
107
  dataSrc?: undefined;
106
108
  valueProperty?: undefined;
@@ -126,6 +128,7 @@ declare const _default: ({
126
128
  value: string;
127
129
  })[];
128
130
  placeholder?: undefined;
131
+ customConditional?: undefined;
129
132
  logic?: undefined;
130
133
  dataSrc?: undefined;
131
134
  valueProperty?: undefined;
@@ -141,6 +144,7 @@ declare const _default: ({
141
144
  tooltip: string;
142
145
  key: string;
143
146
  input: boolean;
147
+ customConditional: string;
144
148
  logic: ({
145
149
  name: string;
146
150
  trigger: {
@@ -211,6 +215,7 @@ declare const _default: ({
211
215
  inline?: undefined;
212
216
  defaultValue?: undefined;
213
217
  values?: undefined;
218
+ customConditional?: undefined;
214
219
  logic?: undefined;
215
220
  as?: undefined;
216
221
  editor?: undefined;
@@ -226,6 +231,7 @@ declare const _default: ({
226
231
  placeholder?: undefined;
227
232
  inline?: undefined;
228
233
  values?: undefined;
234
+ customConditional?: undefined;
229
235
  logic?: undefined;
230
236
  dataSrc?: undefined;
231
237
  valueProperty?: undefined;
@@ -248,6 +254,7 @@ declare const _default: ({
248
254
  placeholder?: undefined;
249
255
  inline?: undefined;
250
256
  values?: undefined;
257
+ customConditional?: undefined;
251
258
  logic?: undefined;
252
259
  dataSrc?: undefined;
253
260
  valueProperty?: undefined;
@@ -56,6 +56,7 @@ export default [
56
56
  tooltip: 'Encrypt this field on the server. This is two way encryption which is not suitable for passwords.',
57
57
  key: 'encrypted',
58
58
  input: true,
59
+ customConditional: 'show = data.encrypted;',
59
60
  logic: [
60
61
  {
61
62
  name: 'disabled',
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
108
108
  * @returns {any} - The component that is located.
109
109
  */
110
110
  getComponent(path: string): any;
111
+ componentMatches: {} | undefined;
111
112
  /**
112
113
  * Return a component provided the Id of the component.
113
114
  * @param {string} id - The Id of the component.
@@ -308,6 +308,13 @@ export default class NestedComponent extends Field {
308
308
  * @returns {any} - The component that is located.
309
309
  */
310
310
  getComponent(path) {
311
+ // If the component is found
312
+ if (!this.componentMatches) {
313
+ this.componentMatches = {};
314
+ }
315
+ if (this.componentMatches && this.componentMatches[path]) {
316
+ return this.componentMatches[path];
317
+ }
311
318
  path = FormioUtils.getStringFromComponentPath(path);
312
319
  const matches = {
313
320
  path: undefined,
@@ -332,7 +339,8 @@ export default class NestedComponent extends Field {
332
339
  return match;
333
340
  });
334
341
  });
335
- return FormioUtils.getBestMatch(matches)?.instance;
342
+ this.componentMatches[path] = FormioUtils.getBestMatch(matches)?.instance;
343
+ return this.componentMatches[path];
336
344
  }
337
345
  /**
338
346
  * Return a component provided the Id of the component.
@@ -795,8 +803,10 @@ export default class NestedComponent extends Field {
795
803
  return this.data;
796
804
  }
797
805
  resetValue() {
798
- super.resetValue();
806
+ // Reset values of child components first, then reset the parent one, otherwise it will restore the default
807
+ // value of parent component and clear it one by one while resetting child components
799
808
  this.getComponents().forEach((comp) => comp.resetValue());
809
+ super.resetValue();
800
810
  this.setPristine(true);
801
811
  }
802
812
  get dataReady() {
@@ -808,7 +818,7 @@ export default class NestedComponent extends Field {
808
818
  return false;
809
819
  }
810
820
  if (component.type === 'components') {
811
- if (component.tree && component.hasValue(value)) {
821
+ if ((component.tree || component.hasInput) && component.hasValue(value)) {
812
822
  return component.setValue(_.get(value, component.key), flags);
813
823
  }
814
824
  return component.setValue(value, flags);
@@ -245,7 +245,7 @@ export default class AddressComponent extends ContainerComponent {
245
245
  if (this.manualMode) {
246
246
  this.restoreComponentsContext();
247
247
  }
248
- if (changed || !_.isEmpty(value) && flags.fromSubmission) {
248
+ if (changed || !_.isEmpty(value) && flags.fromSubmission || flags.resetValue) {
249
249
  this.redraw();
250
250
  }
251
251
  return changed;
@@ -415,12 +415,16 @@ export default class DataGridComponent extends NestedArrayComponent {
415
415
  }
416
416
  updateComponentsRowIndex(components, rowIndex) {
417
417
  components.forEach((component, colIndex) => {
418
+ if (this.componentsMap[component.paths.dataPath]) {
419
+ delete this.componentsMap[component.paths.dataPath];
420
+ }
418
421
  if (component.options?.name) {
419
422
  const newName = `[${this.key}][${rowIndex}]`;
420
423
  component.options.name = component.options.name.replace(`[${this.key}][${component.rowIndex}]`, newName);
421
424
  }
422
425
  component.rowIndex = rowIndex;
423
426
  component.row = `${rowIndex}-${colIndex}`;
427
+ this.componentsMap[component.paths.dataPath] = component;
424
428
  });
425
429
  }
426
430
  updateRowsComponents(rowIndex) {
@@ -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';
@@ -1192,13 +1192,5 @@ export default class EditGridComponent extends NestedArrayComponent {
1192
1192
  this.setNestedValue(component, editRow.data, flags);
1193
1193
  });
1194
1194
  }
1195
- emptyRows() {
1196
- this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));
1197
- this.editRows = [];
1198
- }
1199
- resetValue() {
1200
- super.resetValue();
1201
- this.emptyRows();
1202
- }
1203
1195
  }
1204
1196
  EditGridComponent.prototype.hasChanged = Component.prototype.hasChanged;
@@ -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;
@@ -80,13 +80,15 @@ export default class RadioComponent extends ListComponent {
80
80
  }
81
81
  return defaultValue;
82
82
  }
83
- resetValue() {
83
+ uncheckValue(flags = {}) {
84
84
  this.unset();
85
85
  this.setValue(this.emptyValue, {
86
86
  noUpdateEvent: true,
87
87
  noValidate: true,
88
88
  resetValue: true
89
89
  });
90
+ this.triggerChange(flags);
91
+ this.setSelectedClasses();
90
92
  }
91
93
  get inputInfo() {
92
94
  const info = super.elementInfo();
@@ -400,9 +402,7 @@ export default class RadioComponent extends ListComponent {
400
402
  this.currentValue = this.dataValue;
401
403
  const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
402
404
  if (shouldResetValue) {
403
- this.resetValue();
404
- this.triggerChange(flags);
405
- this.setSelectedClasses();
405
+ this.uncheckValue(flags);
406
406
  }
407
407
  this.previousValue = this.dataValue;
408
408
  return changed;
@@ -125,13 +125,17 @@ function url(formio) {
125
125
  deleteFile(fileInfo, options) {
126
126
  return new Promise((resolve, reject) => {
127
127
  const xhr = new XMLHttpRequest();
128
- xhr.open('DELETE', fileInfo.url, true);
128
+ xhr.open("DELETE", fileInfo.url, true);
129
+ const token = formio.getToken();
130
+ if (token) {
131
+ xhr.setRequestHeader("x-jwt-token", token);
132
+ }
129
133
  xhr.onload = () => {
130
134
  if (xhr.status >= 200 && xhr.status < 300) {
131
- resolve('File deleted');
135
+ resolve("File deleted");
132
136
  }
133
137
  else {
134
- reject(xhr.response || 'Unable to delete file');
138
+ reject(xhr.response || "Unable to delete file");
135
139
  }
136
140
  };
137
141
  if (options) {