aport-tools 4.4.28 → 4.4.30
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/index.esm.js +19 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! aport-tools v4.4.
|
1
|
+
/*! aport-tools v4.4.30 | ISC */
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
var React = require('react');
|
@@ -424,18 +424,32 @@ var Form = function Form(_a) {
|
|
424
424
|
};
|
425
425
|
var handleSubmit = function handleSubmit() {
|
426
426
|
return __awaiter(void 0, void 0, void 0, function () {
|
427
|
-
var validationErrors;
|
427
|
+
var modifiedFields, validationErrors;
|
428
428
|
return __generator(this, function (_a) {
|
429
429
|
switch (_a.label) {
|
430
430
|
case 0:
|
431
|
-
|
431
|
+
modifiedFields = Object.keys(formValues).reduce(function (acc, key) {
|
432
|
+
var currentField = formValues[key];
|
433
|
+
// Check if firstValue exists
|
434
|
+
if ((currentField === null || currentField === void 0 ? void 0 : currentField.firstValue) !== undefined) {
|
435
|
+
// Only include the field if the value has changed
|
436
|
+
if (currentField.value !== currentField.firstValue) {
|
437
|
+
acc[key] = currentField.value;
|
438
|
+
}
|
439
|
+
} else {
|
440
|
+
// Include the field if firstValue is not defined
|
441
|
+
acc[key] = currentField.value;
|
442
|
+
}
|
443
|
+
return acc;
|
444
|
+
}, {});
|
445
|
+
return [4 /*yield*/, onSubmit(modifiedFields)];
|
432
446
|
case 1:
|
433
447
|
validationErrors = _a.sent();
|
434
448
|
// Set the validation errors in state
|
435
449
|
setErrors(validationErrors);
|
436
|
-
// Prevent submission if there are
|
450
|
+
// Prevent submission if there are validation errors
|
437
451
|
if (Object.keys(validationErrors).length > 0) {
|
438
|
-
return [2 /*return*/]; //
|
452
|
+
return [2 /*return*/]; // Exit early if errors are present
|
439
453
|
}
|
440
454
|
return [2 /*return*/];
|
441
455
|
}
|