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/forms/InputCheck.d.ts +1 -1
- package/dist/index.esm.js +24 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! aport-tools v4.4.
|
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
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
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
|
-
|
1053
|
+
var isFirstRender = React.useRef(true);
|
1054
|
+
// Initialize selectedValues on first render if firstValue is provided
|
1055
1055
|
React.useEffect(function () {
|
1056
|
-
|
1057
|
-
|
1058
|
-
return
|
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
|
-
|
1062
|
-
|
1063
|
-
|
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;
|