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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.27 | ISC */
1
+ /*! aport-tools v4.4.28 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -1036,38 +1036,33 @@ var InputCheck = function InputCheck(_a) {
1036
1036
  max = _a.max,
1037
1037
  _c = _a.rowAmount,
1038
1038
  rowAmount = _c === void 0 ? 3 : _c,
1039
- _d = _a.firstValue,
1040
- firstValue = _d === void 0 ? [] : _d,
1041
- _e = _a.iconPosition,
1042
- iconPosition = _e === void 0 ? "row" : _e,
1043
- _f = _a.disabled,
1044
- disabled = _f === void 0 ? false : _f;
1045
- var _g = useFormContext(),
1046
- formValues = _g.formValues,
1047
- setFormValue = _g.setFormValue,
1048
- formErrors = _g.errors;
1049
- var _h = React.useState(formValues[name] || []),
1050
- selectedValues = _h[0],
1051
- setSelectedValues = _h[1];
1039
+ firstValue = _a.firstValue,
1040
+ _d = _a.iconPosition,
1041
+ iconPosition = _d === void 0 ? "row" : _d,
1042
+ _e = _a.disabled,
1043
+ disabled = _e === void 0 ? false : _e;
1044
+ var _f = useFormContext();
1045
+ _f.formValues;
1046
+ var setFormValue = _f.setFormValue,
1047
+ formErrors = _f.errors;
1048
+ var _g = React.useState([]),
1049
+ selectedValues = _g[0],
1050
+ setSelectedValues = _g[1];
1052
1051
  var theme = React.useContext(aportThemes.ThemeContext).theme;
1053
1052
  var colors = theme.colors;
1054
- // Sync firstValue with selectedValues on mount or when firstValue changes
1053
+ var isFirstRender = React.useRef(true);
1054
+ // Initialize selectedValues on first render if firstValue is provided
1055
1055
  React.useEffect(function () {
1056
- var initialSelectedValues = options.filter(function (option) {
1057
- return firstValue.some(function (fv) {
1058
- return fv.value === option.value;
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
+ });
1059
1061
  });
1060
- });
1061
- var formattedValues = initialSelectedValues.map(function (_a) {
1062
- var id = _a.id,
1063
- value = _a.value;
1064
- return {
1065
- id: id,
1066
- value: value
1067
- };
1068
- });
1069
- setSelectedValues(formattedValues);
1070
- setFormValue(name, formattedValues); // Update form context
1062
+ setSelectedValues(initialSelectedValues);
1063
+ setFormValue(name, initialSelectedValues); // Update form context
1064
+ isFirstRender.current = false; // Prevent subsequent updates
1065
+ }
1071
1066
  }, [firstValue, name, options, setFormValue]);
1072
1067
  var handleSelect = function handleSelect(id, value) {
1073
1068
  if (disabled) return;