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.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.20 | ISC */
1
+ /*! aport-tools v4.4.21 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -768,23 +768,25 @@ var InputList = function InputList(_a) {
768
768
  var colors = theme.colors;
769
769
  // Initialize selected options based on firstValue
770
770
  // Filter initial selections from options based on `firstValue`
771
- var initialSelections = React.useMemo(function () {
771
+ React.useMemo(function () {
772
772
  return options.filter(function (opt) {
773
773
  return firstValue.includes(opt.value);
774
774
  });
775
775
  }, [options, firstValue]);
776
776
  // State for selected options
777
- var _l = React.useState(multi ? initialSelections : initialSelections[0] || null),
777
+ var _l = React.useState(multi ? firstValue : firstValue.length > 0 ? firstValue[0] : null),
778
778
  selectedOptions = _l[0],
779
779
  setSelectedOptions = _l[1];
780
780
  // Update form value on mount if firstValue is provided
781
781
  // Update form value and internal state on mount or `firstValue` change
782
782
  React.useEffect(function () {
783
- if (firstValue && selectedOptions !== firstValue) {
784
- setSelectedOptions(multi ? initialSelections : initialSelections[0] || null);
785
- setFormValue(name, multi ? initialSelections : initialSelections[0] || null);
783
+ var isDifferent = multi ? Array.isArray(selectedOptions) && (selectedOptions.length !== firstValue.length || !selectedOptions.every(function (opt) {
784
+ return firstValue.includes(opt);
785
+ })) : selectedOptions !== firstValue[0];
786
+ if (firstValue && isDifferent) {
787
+ setSelectedOptions(multi ? firstValue : firstValue[0] || null);
786
788
  }
787
- }, [firstValue, initialSelections, multi, name, selectedOptions, setFormValue]);
789
+ }, [firstValue, selectedOptions, multi]);
788
790
  // Handle option selection
789
791
  var handleSelectOption = function handleSelectOption(option) {
790
792
  var updatedSelections;