aport-tools 4.4.31 → 4.4.32

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.31 | ISC */
1
+ /*! aport-tools v4.4.32 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -398,6 +398,18 @@ var styles$9 = reactNative.StyleSheet.create({
398
398
  });
399
399
 
400
400
  // src/forms/FormContext.tsx
401
+ // Create a ref to hold the global `setFormValue` function
402
+ var globalSetFormValueRef = {
403
+ current: null
404
+ };
405
+ // Utility to use `setFormValue` globally
406
+ var setFormValueGlobal = function setFormValueGlobal(name, value, firstValue) {
407
+ if (globalSetFormValueRef.current) {
408
+ globalSetFormValueRef.current(name, value, firstValue);
409
+ } else {
410
+ console.warn("setFormValueGlobal was called before the Form was rendered.");
411
+ }
412
+ };
401
413
  var FormContext = /*#__PURE__*/React.createContext(undefined);
402
414
  var useFormContext = function useFormContext() {
403
415
  var context = React.useContext(FormContext);
@@ -419,6 +431,13 @@ var Form = function Form(_a) {
419
431
  var _d = React.useState({}),
420
432
  firstValues = _d[0],
421
433
  setFirstValues = _d[1]; // Track firstValues
434
+ // Assign the local `setFormValue` to the global ref on first render
435
+ React.useEffect(function () {
436
+ globalSetFormValueRef.current = setFormValue;
437
+ return function () {
438
+ globalSetFormValueRef.current = null; // Cleanup on unmount
439
+ };
440
+ }, []);
422
441
  var setFormValue = function setFormValue(name, value, firstValue) {
423
442
  setFormValues(function (prev) {
424
443
  var _a;
@@ -1494,5 +1513,6 @@ exports.InputList = InputList;
1494
1513
  exports.Label = Label;
1495
1514
  exports.Text = Text;
1496
1515
  exports.TextArea = TextArea;
1516
+ exports.setFormValueGlobal = setFormValueGlobal;
1497
1517
  exports.useFormContext = useFormContext;
1498
1518
  //# sourceMappingURL=index.js.map