aport-tools 4.4.26 → 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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.26 | ISC */
1
+ /*! aport-tools v4.4.28 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -1036,19 +1036,34 @@ var InputCheck = function InputCheck(_a) {
1036
1036
  max = _a.max,
1037
1037
  _c = _a.rowAmount,
1038
1038
  rowAmount = _c === void 0 ? 3 : _c,
1039
+ firstValue = _a.firstValue,
1039
1040
  _d = _a.iconPosition,
1040
1041
  iconPosition = _d === void 0 ? "row" : _d,
1041
1042
  _e = _a.disabled,
1042
1043
  disabled = _e === void 0 ? false : _e;
1043
- var _f = useFormContext(),
1044
- formValues = _f.formValues,
1045
- setFormValue = _f.setFormValue,
1044
+ var _f = useFormContext();
1045
+ _f.formValues;
1046
+ var setFormValue = _f.setFormValue,
1046
1047
  formErrors = _f.errors;
1047
- var _g = React.useState(formValues[name] || []),
1048
+ var _g = React.useState([]),
1048
1049
  selectedValues = _g[0],
1049
1050
  setSelectedValues = _g[1];
1050
1051
  var theme = React.useContext(aportThemes.ThemeContext).theme;
1051
1052
  var colors = theme.colors;
1053
+ var isFirstRender = React.useRef(true);
1054
+ // Initialize selectedValues on first render if firstValue is provided
1055
+ React.useEffect(function () {
1056
+ if (isFirstRender.current && firstValue) {
1057
+ var initialSelectedValues = options.filter(function (option) {
1058
+ return firstValue.some(function (fv) {
1059
+ return fv.value === option.value;
1060
+ });
1061
+ });
1062
+ setSelectedValues(initialSelectedValues);
1063
+ setFormValue(name, initialSelectedValues); // Update form context
1064
+ isFirstRender.current = false; // Prevent subsequent updates
1065
+ }
1066
+ }, [firstValue, name, options, setFormValue]);
1052
1067
  var handleSelect = function handleSelect(id, value) {
1053
1068
  if (disabled) return;
1054
1069
  var updatedSelection;
@@ -1096,11 +1111,11 @@ var InputCheck = function InputCheck(_a) {
1096
1111
  uri: item.icon
1097
1112
  },
1098
1113
  style: [styles$2.icon, iconPosition === "column" && styles$2.iconColumn]
1099
- })), /*#__PURE__*/React.createElement(Text, {
1114
+ })), item.label && (/*#__PURE__*/React.createElement(Text, {
1100
1115
  style: [styles$2.label, {
1101
1116
  color: isSelected ? colors.textButton.hex : colors.text.hex
1102
1117
  }]
1103
- }, item.label));
1118
+ }, item.label)));
1104
1119
  };
1105
1120
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
1106
1121
  style: styles$2.title