@formio/js 5.1.0-dev.6162.d0510e0 → 5.1.0-dev.6180.de668a0
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.
- package/dist/formio.form.js +10 -10
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +10 -10
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Webform.js +1 -1
- package/lib/cjs/components/Components.js +6 -0
- package/lib/cjs/components/_classes/component/Component.js +13 -2
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +12 -2
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +4 -0
- package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/cjs/components/editgrid/EditGrid.js +0 -8
- package/lib/cjs/components/radio/Radio.d.ts +1 -0
- package/lib/cjs/components/radio/Radio.js +4 -4
- package/lib/cjs/utils/utils.js +0 -4
- package/lib/mjs/Webform.js +1 -1
- package/lib/mjs/components/Components.js +6 -0
- package/lib/mjs/components/_classes/component/Component.js +12 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +12 -2
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +4 -0
- package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/mjs/components/editgrid/EditGrid.js +0 -8
- package/lib/mjs/components/radio/Radio.d.ts +1 -0
- package/lib/mjs/components/radio/Radio.js +4 -4
- package/lib/mjs/utils/utils.js +0 -4
- package/package.json +1 -1
package/lib/cjs/Webform.js
CHANGED
@@ -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
|
}
|
@@ -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
|
}
|
@@ -2715,6 +2721,11 @@ class Component extends Element_1.default {
|
|
2715
2721
|
this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
|
2716
2722
|
}
|
2717
2723
|
}
|
2724
|
+
// Also reset value of the modal component, otherwise it will keep the old value locally and the preview
|
2725
|
+
// element won't refresh
|
2726
|
+
if (this.componentModal && flags && flags.resetValue) {
|
2727
|
+
this.componentModal.setValue(value);
|
2728
|
+
}
|
2718
2729
|
return changed;
|
2719
2730
|
}
|
2720
2731
|
/**
|
@@ -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;
|
@@ -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
|
-
|
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
|
-
|
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() {
|
@@ -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
|
-
|
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.
|
404
|
-
this.triggerChange(flags);
|
405
|
-
this.setSelectedClasses();
|
405
|
+
this.uncheckValue(flags);
|
406
406
|
}
|
407
407
|
this.previousValue = this.dataValue;
|
408
408
|
return changed;
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -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
|
}
|
package/lib/mjs/Webform.js
CHANGED
@@ -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
|
}
|
@@ -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
|
}
|
@@ -2707,6 +2713,11 @@ export default class Component extends Element {
|
|
2707
2713
|
this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
|
2708
2714
|
}
|
2709
2715
|
}
|
2716
|
+
// Also reset value of the modal component, otherwise it will keep the old value locally and the preview
|
2717
|
+
// element won't refresh
|
2718
|
+
if (this.componentModal && flags && flags.resetValue) {
|
2719
|
+
this.componentModal.setValue(value);
|
2720
|
+
}
|
2710
2721
|
return changed;
|
2711
2722
|
}
|
2712
2723
|
/**
|
@@ -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;
|
@@ -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
|
-
|
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
|
-
|
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() {
|
@@ -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
|
-
|
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.
|
404
|
-
this.triggerChange(flags);
|
405
|
-
this.setSelectedClasses();
|
405
|
+
this.uncheckValue(flags);
|
406
406
|
}
|
407
407
|
this.previousValue = this.dataValue;
|
408
408
|
return changed;
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
/* global jQuery */
|
2
1
|
import _ from 'lodash';
|
3
2
|
import moment from 'moment-timezone/moment-timezone';
|
4
3
|
import jtz from 'jstimezonedetect';
|
@@ -1014,9 +1013,6 @@ export function bootstrapVersion(options) {
|
|
1014
1013
|
if (options.bootstrap) {
|
1015
1014
|
return options.bootstrap;
|
1016
1015
|
}
|
1017
|
-
if ((typeof jQuery === 'function') && (typeof jQuery().collapse === 'function')) {
|
1018
|
-
return parseInt(jQuery.fn.collapse.Constructor.VERSION.split('.')[0], 10);
|
1019
|
-
}
|
1020
1016
|
if (window.bootstrap && window.bootstrap.Collapse) {
|
1021
1017
|
return parseInt(window.bootstrap.Collapse.VERSION.split('.')[0], 10);
|
1022
1018
|
}
|