@formio/js 5.1.0-dev.6155.8178240 → 5.1.0-dev.6156.9cd5779
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 +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +3 -3
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/PDFBuilder.d.ts +0 -1
- package/lib/cjs/PDFBuilder.js +8 -8
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +8 -20
- package/lib/cjs/components/datamap/DataMap.js +7 -2
- package/lib/mjs/PDFBuilder.d.ts +0 -1
- package/lib/mjs/PDFBuilder.js +8 -8
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +8 -19
- package/lib/mjs/components/datamap/DataMap.js +7 -2
- package/package.json +1 -1
package/lib/cjs/PDFBuilder.d.ts
CHANGED
package/lib/cjs/PDFBuilder.js
CHANGED
@@ -451,21 +451,21 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
451
451
|
e.target.style.cursor = 'default';
|
452
452
|
}
|
453
453
|
highlightInvalidComponents() {
|
454
|
-
const
|
454
|
+
const repeatablePaths = this.findRepeatablePaths();
|
455
455
|
// update elements which path was duplicated if any pathes have been changed
|
456
|
-
if (!lodash_1.default.isEqual(this.
|
457
|
-
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
|
458
|
-
if (this.
|
456
|
+
if (!lodash_1.default.isEqual(this.repeatablePaths, repeatablePaths)) {
|
457
|
+
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
|
458
|
+
if (this.repeatablePaths.includes(path)) {
|
459
459
|
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
460
460
|
}
|
461
461
|
});
|
462
|
-
this.
|
462
|
+
this.repeatablePaths = repeatablePaths;
|
463
463
|
}
|
464
|
-
if (!
|
464
|
+
if (!repeatablePaths.length) {
|
465
465
|
return;
|
466
466
|
}
|
467
|
-
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
|
468
|
-
if (this.
|
467
|
+
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
|
468
|
+
if (this.repeatablePaths.includes(path)) {
|
469
469
|
this.webform.postMessage({
|
470
470
|
name: 'showBuilderErrors',
|
471
471
|
data: {
|
@@ -78,7 +78,7 @@ export default class WebformBuilder extends Component {
|
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
79
79
|
updateComponent(component: any, changed: any): void;
|
80
80
|
originalDefaultValue: any;
|
81
|
-
|
81
|
+
findRepeatablePaths(): any[];
|
82
82
|
highlightInvalidComponents(): void;
|
83
83
|
/**
|
84
84
|
* Called when a new component is saved.
|
@@ -1125,37 +1125,25 @@ class WebformBuilder extends Component_1.default {
|
|
1125
1125
|
// Called when we update a component.
|
1126
1126
|
this.emit('updateComponent', component);
|
1127
1127
|
}
|
1128
|
-
|
1129
|
-
const repeatablePaths =
|
1128
|
+
findRepeatablePaths() {
|
1129
|
+
const repeatablePaths = [];
|
1130
1130
|
const keys = new Map();
|
1131
1131
|
(0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
|
1132
|
-
var _a, _b;
|
1133
|
-
const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
|
1134
1132
|
if (keys.has(paths.dataPath)) {
|
1135
|
-
|
1136
|
-
repeatablePaths[paths.dataPath] = {
|
1137
|
-
comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
|
1138
|
-
onlyRadioCheckboxes,
|
1139
|
-
};
|
1133
|
+
repeatablePaths.push(paths.dataPath);
|
1140
1134
|
}
|
1141
1135
|
else {
|
1142
|
-
keys.set(paths.dataPath,
|
1136
|
+
keys.set(paths.dataPath, true);
|
1143
1137
|
}
|
1144
1138
|
}, true);
|
1145
|
-
|
1146
|
-
Object.keys(repeatablePaths).forEach((path) => {
|
1147
|
-
const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
|
1148
|
-
if (!onlyRadioCheckboxes) {
|
1149
|
-
componentsWithRepeatablePaths.push(...comps);
|
1150
|
-
}
|
1151
|
-
});
|
1152
|
-
return componentsWithRepeatablePaths;
|
1139
|
+
return repeatablePaths;
|
1153
1140
|
}
|
1154
1141
|
highlightInvalidComponents() {
|
1155
|
-
const
|
1142
|
+
const repeatablePaths = this.findRepeatablePaths();
|
1156
1143
|
let hasInvalidComponents = false;
|
1157
1144
|
this.webform.everyComponent((comp) => {
|
1158
|
-
|
1145
|
+
const path = comp.path;
|
1146
|
+
if (repeatablePaths.includes(path)) {
|
1159
1147
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1160
1148
|
hasInvalidComponents = true;
|
1161
1149
|
}
|
@@ -228,6 +228,9 @@ class DataMapComponent extends DataGrid_1.default {
|
|
228
228
|
options.name += `[${rowIndex}]`;
|
229
229
|
options.row = `${rowIndex}`;
|
230
230
|
options.rowIndex = rowIndex;
|
231
|
+
options.onChange = (flags, changed, modified) => {
|
232
|
+
this.triggerChange({ modified });
|
233
|
+
};
|
231
234
|
const components = {};
|
232
235
|
components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
|
233
236
|
components['__key'].on('componentChange', (event) => {
|
@@ -243,7 +246,9 @@ class DataMapComponent extends DataGrid_1.default {
|
|
243
246
|
valueComponent.key = key;
|
244
247
|
const componentOptions = this.options;
|
245
248
|
componentOptions.row = options.row;
|
246
|
-
|
249
|
+
const componentOptionsCloned = lodash_1.default.clone(componentOptions);
|
250
|
+
componentOptionsCloned.onChange = options.onChange;
|
251
|
+
components[this.valueKey] = this.createComponent(valueComponent, componentOptionsCloned, this.dataValue);
|
247
252
|
return components;
|
248
253
|
}
|
249
254
|
get canAddColumn() {
|
@@ -266,7 +271,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
266
271
|
const index = this.rows.length;
|
267
272
|
this.rows[index] = this.createRowComponents(this.dataValue, index);
|
268
273
|
this.redraw();
|
269
|
-
this.triggerChange();
|
274
|
+
this.triggerChange({ modified: true });
|
270
275
|
}
|
271
276
|
removeRow(index) {
|
272
277
|
const keys = Object.keys(this.dataValue);
|
package/lib/mjs/PDFBuilder.d.ts
CHANGED
package/lib/mjs/PDFBuilder.js
CHANGED
@@ -444,21 +444,21 @@ export default class PDFBuilder extends WebformBuilder {
|
|
444
444
|
e.target.style.cursor = 'default';
|
445
445
|
}
|
446
446
|
highlightInvalidComponents() {
|
447
|
-
const
|
447
|
+
const repeatablePaths = this.findRepeatablePaths();
|
448
448
|
// update elements which path was duplicated if any pathes have been changed
|
449
|
-
if (!_.isEqual(this.
|
450
|
-
eachComponent(this.webform.getComponents(), (comp) => {
|
451
|
-
if (this.
|
449
|
+
if (!_.isEqual(this.repeatablePaths, repeatablePaths)) {
|
450
|
+
eachComponent(this.webform.getComponents(), (comp, path) => {
|
451
|
+
if (this.repeatablePaths.includes(path)) {
|
452
452
|
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
453
453
|
}
|
454
454
|
});
|
455
|
-
this.
|
455
|
+
this.repeatablePaths = repeatablePaths;
|
456
456
|
}
|
457
|
-
if (!
|
457
|
+
if (!repeatablePaths.length) {
|
458
458
|
return;
|
459
459
|
}
|
460
|
-
eachComponent(this.webform.getComponents(), (comp) => {
|
461
|
-
if (this.
|
460
|
+
eachComponent(this.webform.getComponents(), (comp, path) => {
|
461
|
+
if (this.repeatablePaths.includes(path)) {
|
462
462
|
this.webform.postMessage({
|
463
463
|
name: 'showBuilderErrors',
|
464
464
|
data: {
|
@@ -78,7 +78,7 @@ export default class WebformBuilder extends Component {
|
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
79
79
|
updateComponent(component: any, changed: any): void;
|
80
80
|
originalDefaultValue: any;
|
81
|
-
|
81
|
+
findRepeatablePaths(): any[];
|
82
82
|
highlightInvalidComponents(): void;
|
83
83
|
/**
|
84
84
|
* Called when a new component is saved.
|
@@ -1108,36 +1108,25 @@ export default class WebformBuilder extends Component {
|
|
1108
1108
|
// Called when we update a component.
|
1109
1109
|
this.emit('updateComponent', component);
|
1110
1110
|
}
|
1111
|
-
|
1112
|
-
const repeatablePaths =
|
1111
|
+
findRepeatablePaths() {
|
1112
|
+
const repeatablePaths = [];
|
1113
1113
|
const keys = new Map();
|
1114
1114
|
eachComponent(this.form.components, (comp, path, components, parent, paths) => {
|
1115
|
-
const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
|
1116
1115
|
if (keys.has(paths.dataPath)) {
|
1117
|
-
|
1118
|
-
repeatablePaths[paths.dataPath] = {
|
1119
|
-
comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
|
1120
|
-
onlyRadioCheckboxes,
|
1121
|
-
};
|
1116
|
+
repeatablePaths.push(paths.dataPath);
|
1122
1117
|
}
|
1123
1118
|
else {
|
1124
|
-
keys.set(paths.dataPath,
|
1119
|
+
keys.set(paths.dataPath, true);
|
1125
1120
|
}
|
1126
1121
|
}, true);
|
1127
|
-
|
1128
|
-
Object.keys(repeatablePaths).forEach((path) => {
|
1129
|
-
const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
|
1130
|
-
if (!onlyRadioCheckboxes) {
|
1131
|
-
componentsWithRepeatablePaths.push(...comps);
|
1132
|
-
}
|
1133
|
-
});
|
1134
|
-
return componentsWithRepeatablePaths;
|
1122
|
+
return repeatablePaths;
|
1135
1123
|
}
|
1136
1124
|
highlightInvalidComponents() {
|
1137
|
-
const
|
1125
|
+
const repeatablePaths = this.findRepeatablePaths();
|
1138
1126
|
let hasInvalidComponents = false;
|
1139
1127
|
this.webform.everyComponent((comp) => {
|
1140
|
-
|
1128
|
+
const path = comp.path;
|
1129
|
+
if (repeatablePaths.includes(path)) {
|
1141
1130
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1142
1131
|
hasInvalidComponents = true;
|
1143
1132
|
}
|
@@ -223,6 +223,9 @@ export default class DataMapComponent extends DataGridComponent {
|
|
223
223
|
options.name += `[${rowIndex}]`;
|
224
224
|
options.row = `${rowIndex}`;
|
225
225
|
options.rowIndex = rowIndex;
|
226
|
+
options.onChange = (flags, changed, modified) => {
|
227
|
+
this.triggerChange({ modified });
|
228
|
+
};
|
226
229
|
const components = {};
|
227
230
|
components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
|
228
231
|
components['__key'].on('componentChange', (event) => {
|
@@ -238,7 +241,9 @@ export default class DataMapComponent extends DataGridComponent {
|
|
238
241
|
valueComponent.key = key;
|
239
242
|
const componentOptions = this.options;
|
240
243
|
componentOptions.row = options.row;
|
241
|
-
|
244
|
+
const componentOptionsCloned = _.clone(componentOptions);
|
245
|
+
componentOptionsCloned.onChange = options.onChange;
|
246
|
+
components[this.valueKey] = this.createComponent(valueComponent, componentOptionsCloned, this.dataValue);
|
242
247
|
return components;
|
243
248
|
}
|
244
249
|
get canAddColumn() {
|
@@ -261,7 +266,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
261
266
|
const index = this.rows.length;
|
262
267
|
this.rows[index] = this.createRowComponents(this.dataValue, index);
|
263
268
|
this.redraw();
|
264
|
-
this.triggerChange();
|
269
|
+
this.triggerChange({ modified: true });
|
265
270
|
}
|
266
271
|
removeRow(index) {
|
267
272
|
const keys = Object.keys(this.dataValue);
|