aport-tools 4.4.24 → 4.4.25

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.24 | ISC */
1
+ /*! aport-tools v4.4.25 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -1162,13 +1162,24 @@ var InputAttach = function InputAttach(_a) {
1162
1162
  _d = _a.disabled,
1163
1163
  disabled = _d === void 0 ? false : _d,
1164
1164
  _e = _a.placeholder,
1165
- placeholder = _e === void 0 ? "Upload an image" : _e;
1166
- var _f = useFormContext(),
1167
- setFormValue = _f.setFormValue,
1168
- formErrors = _f.errors;
1169
- var _g = React.useState([]),
1170
- selectedFiles = _g[0],
1171
- setSelectedFiles = _g[1];
1165
+ placeholder = _e === void 0 ? "Upload an image" : _e,
1166
+ _f = _a.firstValue,
1167
+ firstValue = _f === void 0 ? [] : _f;
1168
+ var _g = useFormContext(),
1169
+ setFormValue = _g.setFormValue,
1170
+ formErrors = _g.errors;
1171
+ // Initialize with firstValue or an empty array
1172
+ var _h = React.useState(function () {
1173
+ return Array.isArray(firstValue) ? firstValue.slice(0, amount) : [];
1174
+ }),
1175
+ selectedFiles = _h[0],
1176
+ setSelectedFiles = _h[1];
1177
+ // Update the form context on mount with firstValue if provided
1178
+ React.useEffect(function () {
1179
+ if (firstValue.length > 0) {
1180
+ setFormValue(name, firstValue.slice(0, amount));
1181
+ }
1182
+ }, [firstValue, name, setFormValue, amount]);
1172
1183
  var theme = React.useContext(aportThemes.ThemeContext).theme;
1173
1184
  var colors = theme.colors;
1174
1185
  var pickImage = function pickImage() {