aport-tools 4.4.26 → 4.4.27
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 +8 -6
- package/dist/index.esm.js +34 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -14
- 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.27 | ISC */
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
var React = require('react');
|
@@ -1036,19 +1036,39 @@ 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.
|
1040
|
-
|
1041
|
-
_e = _a.
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
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];
|
1050
1052
|
var theme = React.useContext(aportThemes.ThemeContext).theme;
|
1051
1053
|
var colors = theme.colors;
|
1054
|
+
// Sync firstValue with selectedValues on mount or when firstValue changes
|
1055
|
+
React.useEffect(function () {
|
1056
|
+
var initialSelectedValues = options.filter(function (option) {
|
1057
|
+
return firstValue.some(function (fv) {
|
1058
|
+
return fv.value === option.value;
|
1059
|
+
});
|
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
|
1071
|
+
}, [firstValue, name, options, setFormValue]);
|
1052
1072
|
var handleSelect = function handleSelect(id, value) {
|
1053
1073
|
if (disabled) return;
|
1054
1074
|
var updatedSelection;
|
@@ -1096,11 +1116,11 @@ var InputCheck = function InputCheck(_a) {
|
|
1096
1116
|
uri: item.icon
|
1097
1117
|
},
|
1098
1118
|
style: [styles$2.icon, iconPosition === "column" && styles$2.iconColumn]
|
1099
|
-
})), /*#__PURE__*/React.createElement(Text, {
|
1119
|
+
})), item.label && (/*#__PURE__*/React.createElement(Text, {
|
1100
1120
|
style: [styles$2.label, {
|
1101
1121
|
color: isSelected ? colors.textButton.hex : colors.text.hex
|
1102
1122
|
}]
|
1103
|
-
}, item.label));
|
1123
|
+
}, item.label)));
|
1104
1124
|
};
|
1105
1125
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
1106
1126
|
style: styles$2.title
|