aport-tools 4.4.20 → 4.4.21

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,4 +1,4 @@
1
- /*! aport-tools v4.4.20 | ISC */
1
+ /*! aport-tools v4.4.21 | ISC */
2
2
  import React, { useContext, useState, createContext, 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';
@@ -747,23 +747,25 @@ var InputList = function InputList(_a) {
747
747
  var colors = theme.colors;
748
748
  // Initialize selected options based on firstValue
749
749
  // Filter initial selections from options based on `firstValue`
750
- var initialSelections = useMemo(function () {
750
+ useMemo(function () {
751
751
  return options.filter(function (opt) {
752
752
  return firstValue.includes(opt.value);
753
753
  });
754
754
  }, [options, firstValue]);
755
755
  // State for selected options
756
- var _l = useState(multi ? initialSelections : initialSelections[0] || null),
756
+ var _l = useState(multi ? firstValue : firstValue.length > 0 ? firstValue[0] : null),
757
757
  selectedOptions = _l[0],
758
758
  setSelectedOptions = _l[1];
759
759
  // Update form value on mount if firstValue is provided
760
760
  // Update form value and internal state on mount or `firstValue` change
761
761
  useEffect(function () {
762
- if (firstValue && selectedOptions !== firstValue) {
763
- setSelectedOptions(multi ? initialSelections : initialSelections[0] || null);
764
- setFormValue(name, multi ? initialSelections : initialSelections[0] || null);
762
+ var isDifferent = multi ? Array.isArray(selectedOptions) && (selectedOptions.length !== firstValue.length || !selectedOptions.every(function (opt) {
763
+ return firstValue.includes(opt);
764
+ })) : selectedOptions !== firstValue[0];
765
+ if (firstValue && isDifferent) {
766
+ setSelectedOptions(multi ? firstValue : firstValue[0] || null);
765
767
  }
766
- }, [firstValue, initialSelections, multi, name, selectedOptions, setFormValue]);
768
+ }, [firstValue, selectedOptions, multi]);
767
769
  // Handle option selection
768
770
  var handleSelectOption = function handleSelectOption(option) {
769
771
  var updatedSelections;