aport-tools 4.4.27 → 4.4.28

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.
@@ -13,7 +13,7 @@ interface InputCheckProps {
13
13
  rowAmount?: number;
14
14
  iconPosition?: "row" | "column";
15
15
  disabled?: boolean;
16
- firstValue: InputOption[];
16
+ firstValue?: InputOption[];
17
17
  }
18
18
  declare const InputCheck: React.FC<InputCheckProps>;
19
19
  export default InputCheck;
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.27 | ISC */
1
+ /*! aport-tools v4.4.28 | ISC */
2
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';
@@ -1015,38 +1015,33 @@ var InputCheck = function InputCheck(_a) {
1015
1015
  max = _a.max,
1016
1016
  _c = _a.rowAmount,
1017
1017
  rowAmount = _c === void 0 ? 3 : _c,
1018
- _d = _a.firstValue,
1019
- firstValue = _d === void 0 ? [] : _d,
1020
- _e = _a.iconPosition,
1021
- iconPosition = _e === void 0 ? "row" : _e,
1022
- _f = _a.disabled,
1023
- disabled = _f === void 0 ? false : _f;
1024
- var _g = useFormContext(),
1025
- formValues = _g.formValues,
1026
- setFormValue = _g.setFormValue,
1027
- formErrors = _g.errors;
1028
- var _h = useState(formValues[name] || []),
1029
- selectedValues = _h[0],
1030
- setSelectedValues = _h[1];
1018
+ firstValue = _a.firstValue,
1019
+ _d = _a.iconPosition,
1020
+ iconPosition = _d === void 0 ? "row" : _d,
1021
+ _e = _a.disabled,
1022
+ disabled = _e === void 0 ? false : _e;
1023
+ var _f = useFormContext();
1024
+ _f.formValues;
1025
+ var setFormValue = _f.setFormValue,
1026
+ formErrors = _f.errors;
1027
+ var _g = useState([]),
1028
+ selectedValues = _g[0],
1029
+ setSelectedValues = _g[1];
1031
1030
  var theme = useContext(ThemeContext).theme;
1032
1031
  var colors = theme.colors;
1033
- // Sync firstValue with selectedValues on mount or when firstValue changes
1032
+ var isFirstRender = useRef(true);
1033
+ // Initialize selectedValues on first render if firstValue is provided
1034
1034
  useEffect(function () {
1035
- var initialSelectedValues = options.filter(function (option) {
1036
- return firstValue.some(function (fv) {
1037
- return fv.value === option.value;
1035
+ if (isFirstRender.current && firstValue) {
1036
+ var initialSelectedValues = options.filter(function (option) {
1037
+ return firstValue.some(function (fv) {
1038
+ return fv.value === option.value;
1039
+ });
1038
1040
  });
1039
- });
1040
- var formattedValues = initialSelectedValues.map(function (_a) {
1041
- var id = _a.id,
1042
- value = _a.value;
1043
- return {
1044
- id: id,
1045
- value: value
1046
- };
1047
- });
1048
- setSelectedValues(formattedValues);
1049
- setFormValue(name, formattedValues); // Update form context
1041
+ setSelectedValues(initialSelectedValues);
1042
+ setFormValue(name, initialSelectedValues); // Update form context
1043
+ isFirstRender.current = false; // Prevent subsequent updates
1044
+ }
1050
1045
  }, [firstValue, name, options, setFormValue]);
1051
1046
  var handleSelect = function handleSelect(id, value) {
1052
1047
  if (disabled) return;