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/forms/Form.d.ts +1 -1
- package/dist/forms/FormContext.d.ts +1 -0
- package/dist/forms/index.d.ts +1 -1
- package/dist/index.esm.js +21 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/forms/Form.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Form, useFormContext } from './FormContext';
|
1
|
+
export { Form, useFormContext, setFormValueGlobal } from './FormContext';
|
@@ -45,6 +45,7 @@ interface FormContextProps {
|
|
45
45
|
handleSubmit: () => void;
|
46
46
|
handleFormSubmit: (formValues: Record<string, any>) => Promise<Record<string, string[]>>;
|
47
47
|
}
|
48
|
+
export declare const setFormValueGlobal: (name: string, value: any, firstValue?: any) => void;
|
48
49
|
export declare const useFormContext: () => FormContextProps;
|
49
50
|
interface StepperProps {
|
50
51
|
/**
|
package/dist/forms/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export { Input } from './Input';
|
2
|
-
export { Form, useFormContext } from './FormContext';
|
2
|
+
export { Form, useFormContext, setFormValueGlobal } from './FormContext';
|
3
3
|
export { default as TextArea } from './TextArea';
|
4
4
|
export { default as Label } from './Label';
|
5
5
|
export { default as ErrorList } from './ErrorList';
|
package/dist/index.esm.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! aport-tools v4.4.
|
1
|
+
/*! aport-tools v4.4.32 | ISC */
|
2
2
|
import React, { useContext, useState, createContext, useRef, useEffect, useMemo, useCallback } from 'react';
|
3
3
|
import { StyleSheet, Text as Text$1, Animated, View, TouchableOpacity, Image, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Alert, ActivityIndicator } from 'react-native';
|
4
4
|
import { ThemeContext } from 'aport-themes';
|
@@ -377,6 +377,18 @@ var styles$9 = StyleSheet.create({
|
|
377
377
|
});
|
378
378
|
|
379
379
|
// src/forms/FormContext.tsx
|
380
|
+
// Create a ref to hold the global `setFormValue` function
|
381
|
+
var globalSetFormValueRef = {
|
382
|
+
current: null
|
383
|
+
};
|
384
|
+
// Utility to use `setFormValue` globally
|
385
|
+
var setFormValueGlobal = function setFormValueGlobal(name, value, firstValue) {
|
386
|
+
if (globalSetFormValueRef.current) {
|
387
|
+
globalSetFormValueRef.current(name, value, firstValue);
|
388
|
+
} else {
|
389
|
+
console.warn("setFormValueGlobal was called before the Form was rendered.");
|
390
|
+
}
|
391
|
+
};
|
380
392
|
var FormContext = /*#__PURE__*/createContext(undefined);
|
381
393
|
var useFormContext = function useFormContext() {
|
382
394
|
var context = useContext(FormContext);
|
@@ -398,6 +410,13 @@ var Form = function Form(_a) {
|
|
398
410
|
var _d = useState({}),
|
399
411
|
firstValues = _d[0],
|
400
412
|
setFirstValues = _d[1]; // Track firstValues
|
413
|
+
// Assign the local `setFormValue` to the global ref on first render
|
414
|
+
React.useEffect(function () {
|
415
|
+
globalSetFormValueRef.current = setFormValue;
|
416
|
+
return function () {
|
417
|
+
globalSetFormValueRef.current = null; // Cleanup on unmount
|
418
|
+
};
|
419
|
+
}, []);
|
401
420
|
var setFormValue = function setFormValue(name, value, firstValue) {
|
402
421
|
setFormValues(function (prev) {
|
403
422
|
var _a;
|
@@ -1462,5 +1481,5 @@ var styles = StyleSheet.create({
|
|
1462
1481
|
}
|
1463
1482
|
});
|
1464
1483
|
|
1465
|
-
export { Button, Card, ErrorList, Form, Input, InputAttach, InputCheck, InputList, Label, Text, TextArea, useFormContext };
|
1484
|
+
export { Button, Card, ErrorList, Form, Input, InputAttach, InputCheck, InputList, Label, Text, TextArea, setFormValueGlobal, useFormContext };
|
1466
1485
|
//# sourceMappingURL=index.esm.js.map
|