aport-tools 4.4.24 → 4.4.26

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.26 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -1162,13 +1162,25 @@ 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
+ var _h = React.useState([]),
1172
+ selectedFiles = _h[0],
1173
+ setSelectedFiles = _h[1];
1174
+ // Ref to track initialization
1175
+ var isInitialized = React.useRef(false);
1176
+ // Sync firstValue with selectedFiles when it changes
1177
+ React.useEffect(function () {
1178
+ if (!isInitialized.current) {
1179
+ setSelectedFiles(firstValue);
1180
+ setFormValue(name, firstValue); // Update form context
1181
+ isInitialized.current = true;
1182
+ }
1183
+ }, [firstValue, name, setFormValue]);
1172
1184
  var theme = React.useContext(aportThemes.ThemeContext).theme;
1173
1185
  var colors = theme.colors;
1174
1186
  var pickImage = function pickImage() {