aport-tools 4.4.29 → 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 CHANGED
@@ -1,5 +1,5 @@
1
- /*! aport-tools v4.4.29 | ISC */
2
- import React, { useContext, useState, useRef, createContext, useEffect, useMemo, useCallback } from 'react';
1
+ /*! aport-tools v4.4.30 | ISC */
2
+ import React, { useContext, useState, createContext, useRef, useEffect, useMemo, useCallback } from 'react';
3
3
  import { StyleSheet, Text as Text$1, Animated, View, TouchableOpacity, Image, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Alert, ActivityIndicator } from 'react-native';
4
4
  import { ThemeContext } from 'aport-themes';
5
5
  import * as ImagePicker from 'expo-image-picker';
@@ -395,16 +395,11 @@ var Form = function Form(_a) {
395
395
  var _c = useState({}),
396
396
  errors = _c[0],
397
397
  setErrors = _c[1];
398
- // Ref to store the initial form values (firstValue).
399
- var initialFormValues = useRef({});
400
398
  var setFormValue = function setFormValue(name, value) {
401
399
  setFormValues(function (prev) {
402
400
  var _a;
403
401
  return __assign(__assign({}, prev), (_a = {}, _a[name] = value, _a));
404
402
  });
405
- if (!initialFormValues.current[name]) {
406
- initialFormValues.current[name] = value; // Set the initial value once.
407
- }
408
403
  };
409
404
  var handleSubmit = function handleSubmit() {
410
405
  return __awaiter(void 0, void 0, void 0, function () {
@@ -413,11 +408,16 @@ var Form = function Form(_a) {
413
408
  switch (_a.label) {
414
409
  case 0:
415
410
  modifiedFields = Object.keys(formValues).reduce(function (acc, key) {
416
- var currentField = formValues[key]; // currentField is FormField
417
- var initialField = currentField.firstValue; // Get initial value
418
- // Compare current value with initial value
419
- if (currentField.value !== initialField) {
420
- acc[key] = currentField.value; // Include only modified fields
411
+ var currentField = formValues[key];
412
+ // Check if firstValue exists
413
+ if ((currentField === null || currentField === void 0 ? void 0 : currentField.firstValue) !== undefined) {
414
+ // Only include the field if the value has changed
415
+ if (currentField.value !== currentField.firstValue) {
416
+ acc[key] = currentField.value;
417
+ }
418
+ } else {
419
+ // Include the field if firstValue is not defined
420
+ acc[key] = currentField.value;
421
421
  }
422
422
  return acc;
423
423
  }, {});
@@ -435,26 +435,16 @@ var Form = function Form(_a) {
435
435
  });
436
436
  });
437
437
  };
438
- var handleFormSubmit = function handleFormSubmit() {
438
+ var handleFormSubmit = function handleFormSubmit(formValues) {
439
439
  return __awaiter(void 0, void 0, void 0, function () {
440
- var modifiedFields, validationErrors;
440
+ var validationErrors;
441
441
  return __generator(this, function (_a) {
442
442
  switch (_a.label) {
443
443
  case 0:
444
- modifiedFields = Object.keys(formValues).reduce(function (acc, key) {
445
- var currentField = formValues[key];
446
- var initialField = currentField === null || currentField === void 0 ? void 0 : currentField.firstValue; // Get initial value
447
- if (currentField.value !== initialField) {
448
- acc[key] = currentField.value; // Include only modified fields
449
- }
450
- return acc;
451
- }, {});
452
- return [4 /*yield*/, onSubmit(modifiedFields)];
444
+ return [4 /*yield*/, onSubmit(formValues)];
453
445
  case 1:
454
446
  validationErrors = _a.sent();
455
- // Set the validation errors in state
456
447
  setErrors(validationErrors);
457
- // Return validation errors to allow further actions if needed
458
448
  return [2 /*return*/, validationErrors];
459
449
  }
460
450
  });