@bolttech/form-engine 3.0.0-beta.42 → 3.0.0-beta.45

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/index.esm.js CHANGED
@@ -2383,7 +2383,7 @@ const eventsMapping = {
2383
2383
  /**
2384
2384
  * Hook to register events callback functions
2385
2385
  */
2386
- const useForm = _a => {
2386
+ function useForm(_a) {
2387
2387
  var {
2388
2388
  id,
2389
2389
  onData,
@@ -2457,14 +2457,14 @@ const useForm = _a => {
2457
2457
  };
2458
2458
  }, []);
2459
2459
  return;
2460
- };
2460
+ }
2461
2461
 
2462
2462
  /**
2463
2463
  *
2464
2464
  * @param {TFormProps} param form properties initializor
2465
2465
  * @returns {ReactElement}
2466
2466
  */
2467
- const Form = ({
2467
+ function Form({
2468
2468
  schema,
2469
2469
  index,
2470
2470
  initialValues,
@@ -2482,7 +2482,7 @@ const Form = ({
2482
2482
  onKeyUp,
2483
2483
  onMount,
2484
2484
  children
2485
- }) => {
2485
+ }) {
2486
2486
  const {
2487
2487
  addForm,
2488
2488
  removeForm,
@@ -2636,7 +2636,7 @@ const Form = ({
2636
2636
  children: tree && tree
2637
2637
  })]
2638
2638
  });
2639
- };
2639
+ }
2640
2640
 
2641
2641
  /**
2642
2642
  * Component wrapper to aid building schemas with react without writting a JSON schema
@@ -2850,7 +2850,7 @@ const AsFormFieldBuilder = props => {
2850
2850
  * Also has the logic to remove it once this element is removed
2851
2851
  */
2852
2852
  useEffect(() => {
2853
- var _a;
2853
+ var _a, _b, _c;
2854
2854
  if (!((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
2855
2855
  context.addFormWithIndex(props.formIndex);
2856
2856
  }
@@ -2863,6 +2863,14 @@ const AsFormFieldBuilder = props => {
2863
2863
  fieldSchema,
2864
2864
  mapperElement: props.mapper
2865
2865
  });
2866
+ if (((_b = props.mapper.events) === null || _b === void 0 ? void 0 : _b.setValue) && props.props) {
2867
+ (_c = formInstance === null || formInstance === void 0 ? void 0 : formInstance.getField({
2868
+ key: props.name
2869
+ })) === null || _c === void 0 ? void 0 : _c.emitValue({
2870
+ value: props.props[props.mapper.events.setValue],
2871
+ event: 'ON_FIELD_MOUNT'
2872
+ });
2873
+ }
2866
2874
  setMounted(true);
2867
2875
  return () => formInstance === null || formInstance === void 0 ? void 0 : formInstance.removeField({
2868
2876
  key: props.name
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine",
3
- "version": "3.0.0-beta.42",
3
+ "version": "3.0.0-beta.45",
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.1-beta.30",
9
+ "@bolttech/form-engine-core": "0.0.1-beta.32",
10
10
  "react": "18.2.0"
11
11
  },
12
12
  "peerDependencies": {}
@@ -5,5 +5,5 @@ import { TFormProps } from './Form.type';
5
5
  * @param {TFormProps} param form properties initializor
6
6
  * @returns {ReactElement}
7
7
  */
8
- declare const Form: ({ schema, index, initialValues, iVars, action, method, onSubmit, onData, onBlur, onChange, onApiResponse, onClick, onFocus, onKeyDown, onKeyUp, onMount, children, }: TFormProps) => ReactElement;
8
+ declare function Form<T>({ schema, index, initialValues, iVars, action, method, onSubmit, onData, onBlur, onChange, onApiResponse, onClick, onFocus, onKeyDown, onKeyUp, onMount, children, }: TFormProps<T>): ReactElement;
9
9
  export default Form;
@@ -7,5 +7,5 @@ import { TEventsCallbackProps } from '../../types';
7
7
  * @see {@link TFormEntry}
8
8
  * @see {@link TEventsCallbackProps}
9
9
  */
10
- type TFormProps = PropsWithChildren<Omit<TFormEntry, 'mappers'> & TEventsCallbackProps>;
10
+ type TFormProps<T> = PropsWithChildren<Omit<TFormEntry, 'mappers'> & TEventsCallbackProps<T>>;
11
11
  export type { TFormProps };
@@ -29,7 +29,7 @@ type TFormContext = {
29
29
  formGroupInstance: TFormGroup;
30
30
  mappers?: TMapper<ElementType>[];
31
31
  printFormGroupInstance: () => void;
32
- submitMultipleFormsByIndex: <T>(indexes: string[]) => void;
32
+ submitMultipleFormsByIndex: (indexes: string[]) => void;
33
33
  debugMode: boolean;
34
34
  active: boolean;
35
35
  };
@@ -2,5 +2,5 @@ import { TUseFormProps } from './useForm.type';
2
2
  /**
3
3
  * Hook to register events callback functions
4
4
  */
5
- declare const useForm: ({ id, onData, onSubmit, ...rest }: TUseFormProps) => void;
5
+ declare function useForm<T>({ id, onData, onSubmit, ...rest }: TUseFormProps<T>): void;
6
6
  export default useForm;
@@ -6,7 +6,7 @@ import { TEventsCallbackProps } from '../../types';
6
6
  *
7
7
  * @see {@link TEventsCallbackProps}
8
8
  */
9
- type TUseFormProps = {
9
+ type TUseFormProps<T> = {
10
10
  id: string;
11
- } & TEventsCallbackProps;
11
+ } & TEventsCallbackProps<T>;
12
12
  export type { TUseFormProps };
@@ -23,8 +23,8 @@ type TFormData<T> = {
23
23
  /**
24
24
  * Represents a mapping of event properties to their corresponding callback functions.
25
25
  */
26
- type TEventsCallbackProps = Partial<Record<TEventProps, ((payload: TFieldEvent) => void) | null | undefined>> & {
27
- onData?: <T>(payload: TFormData<T>) => void;
28
- onSubmit?: <T>(payload: TFormValues<T>) => void;
26
+ type TEventsCallbackProps<T> = Partial<Record<TEventProps, ((payload: TFieldEvent) => void) | null | undefined>> & {
27
+ onData?: (payload: TFormData<T>) => void;
28
+ onSubmit?: (payload: TFormValues<T>) => void;
29
29
  };
30
30
  export { TFieldWrapper, TEventProps, TEventsCallbackProps, TFormData };