@bolttech/form-engine 3.0.2-beta.5 → 3.0.2-beta.7
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/README.md
CHANGED
|
@@ -1108,10 +1108,11 @@ useFormGroup({ ids: ['form1', 'form2'], onData: (payload) => console.log(payload
|
|
|
1108
1108
|
|
|
1109
1109
|
As `useForm`, `useFormGroup` serves the same purpose, but the difference is that it handles multiple forms and has limited callback functions to set:
|
|
1110
1110
|
|
|
1111
|
-
| method
|
|
1112
|
-
|
|
1113
|
-
| onData
|
|
1114
|
-
| onValid
|
|
1111
|
+
| method | payload | description |
|
|
1112
|
+
|----------|-----------------------------------|-------------------------------------------------------------|
|
|
1113
|
+
| onData | TFormGroupOnDataEventPayload<T> | event occurring when a value is changing via input or logic |
|
|
1114
|
+
| onValid | TFormGroupOnValidEventPayload | event occurring when validation status changes on the form |
|
|
1115
|
+
| onSubmit | TFormGroupOnSubmitEventPayload<T> | event occurring when form submission is trigger |
|
|
1115
1116
|
|
|
1116
1117
|
<a id="asformfield"></a>
|
|
1117
1118
|
|
package/index.esm.js
CHANGED
|
@@ -2955,27 +2955,27 @@ const AsFormFieldBuilder = props => {
|
|
|
2955
2955
|
}) : jsx(Fragment, {});
|
|
2956
2956
|
};
|
|
2957
2957
|
|
|
2958
|
-
|
|
2959
|
-
const useFormGroup = ({
|
|
2958
|
+
function useFormGroup({
|
|
2960
2959
|
ids,
|
|
2961
2960
|
onData,
|
|
2962
|
-
onValid
|
|
2963
|
-
|
|
2961
|
+
onValid,
|
|
2962
|
+
onSubmit
|
|
2963
|
+
}, deps) {
|
|
2964
2964
|
const {
|
|
2965
2965
|
formGroupInstance
|
|
2966
2966
|
} = useFormGroupContext({});
|
|
2967
2967
|
const onDataCallbackRef = useRef(onData);
|
|
2968
2968
|
const onValidCallbackRef = useRef(onValid);
|
|
2969
|
-
|
|
2969
|
+
const onSubmitCallbackRef = useRef(onSubmit);
|
|
2970
2970
|
useEffect(() => {
|
|
2971
2971
|
onDataCallbackRef.current = onData;
|
|
2972
2972
|
}, [onData]);
|
|
2973
2973
|
useEffect(() => {
|
|
2974
2974
|
onValidCallbackRef.current = onValid;
|
|
2975
2975
|
}, [onValid]);
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2976
|
+
useEffect(() => {
|
|
2977
|
+
onSubmitCallbackRef.current = onSubmit;
|
|
2978
|
+
}, [onSubmit]);
|
|
2979
2979
|
useEffect(() => {
|
|
2980
2980
|
const onDataCallback = payload => {
|
|
2981
2981
|
var _a;
|
|
@@ -2996,20 +2996,24 @@ const useFormGroup = ({
|
|
|
2996
2996
|
ids,
|
|
2997
2997
|
callback: onValidCallback
|
|
2998
2998
|
});
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
2999
|
+
const onSubmitCallback = payload => {
|
|
3000
|
+
var _a;
|
|
3001
|
+
if (onSubmitCallbackRef.current) {
|
|
3002
|
+
(_a = onSubmitCallbackRef.current) === null || _a === void 0 ? void 0 : _a.call(onSubmitCallbackRef, payload);
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
const onSubmitSub = formGroupInstance.onSubmitSubscription({
|
|
3006
|
+
ids,
|
|
3007
|
+
callback: onSubmitCallback
|
|
3008
|
+
});
|
|
3006
3009
|
return () => {
|
|
3007
3010
|
onDataSub.unsubscribe();
|
|
3008
3011
|
onValidSub.unsubscribe();
|
|
3012
|
+
onSubmitSub.unsubscribe();
|
|
3009
3013
|
};
|
|
3010
3014
|
}, [deps]);
|
|
3011
3015
|
return;
|
|
3012
|
-
}
|
|
3016
|
+
}
|
|
3013
3017
|
|
|
3014
3018
|
const defaultChangeEvent = event => {
|
|
3015
3019
|
return event.currentTarget.value;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/form-engine",
|
|
3
|
-
"version": "3.0.2-beta.
|
|
3
|
+
"version": "3.0.2-beta.7",
|
|
4
4
|
"description": "A react adapter for bolttech form engine",
|
|
5
5
|
"module": "./index.esm.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.esm.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@bolttech/form-engine-core": "0.0.3-beta.
|
|
9
|
+
"@bolttech/form-engine-core": "0.0.3-beta.6",
|
|
10
10
|
"react": "18.2.0",
|
|
11
11
|
"rxjs": "7.8.1"
|
|
12
12
|
},
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
onData?: ((payload: TFormGroupOnDataEventPayload<Record<string, unknown>>) => void) | undefined;
|
|
5
|
-
onValid?: ((payload: TFormGroupOnValidEventPayload) => void) | undefined;
|
|
6
|
-
}, deps?: React.DependencyList) => void;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TUseFormGroup } from './useFormGroup.type';
|
|
3
|
+
declare function useFormGroup<T>({ ids, onData, onValid, onSubmit }: TUseFormGroup<T>, deps?: React.DependencyList): void;
|
|
7
4
|
export default useFormGroup;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TFormGroupOnDataEventPayload, TFormGroupOnSubmitEventPayload, TFormGroupOnValidEventPayload } from '@bolttech/form-engine-core';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the properties for the useFormGroup hook, including a list of ID's and event callback properties.
|
|
4
|
+
*
|
|
5
|
+
* @property {string} ids - The unique identifier for the forms.
|
|
6
|
+
* @property {payload: TFormGroupOnDataEventPayload<T>} onData - callback event occurring when a value is changing via input or logic.
|
|
7
|
+
* @property {payload: TFormGroupOnValidEventPayload} onData - callback event occurring when validation status changes on the form.
|
|
8
|
+
* @property {payload: TFormGroupOnSubmitEventPayload<T>} onData - event occurring when form submission is trigger.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
type TUseFormGroup<T> = {
|
|
12
|
+
ids: string[];
|
|
13
|
+
onData?: (payload: TFormGroupOnDataEventPayload<T>) => void;
|
|
14
|
+
onValid?: (payload: TFormGroupOnValidEventPayload) => void;
|
|
15
|
+
onSubmit?: (payload: TFormGroupOnSubmitEventPayload<T>) => void;
|
|
16
|
+
};
|
|
17
|
+
export type { TUseFormGroup };
|