@bolttech/form-engine 3.1.1-beta.3 → 3.1.1
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/CHANGELOG.md +36 -0
- package/README.md +337 -88
- package/index.d.ts +326 -0
- package/index.esm.js +618 -2055
- package/package.json +18 -7
- package/index.esm.d.ts +0 -1
- package/src/components/AsFormField/AsFormField.d.ts +0 -13
- package/src/components/AsFormField/AsFormField.type.d.ts +0 -9
- package/src/components/AsFormFieldBuilder/AsFormFieldBuilder.d.ts +0 -11
- package/src/components/AsFormFieldBuilder/AsFormFieldBuilder.type.d.ts +0 -21
- package/src/components/FieldWrapper/FieldWrapper.d.ts +0 -11
- package/src/components/FieldWrapper/FieldWrapper.type.d.ts +0 -32
- package/src/components/Form/Form.d.ts +0 -9
- package/src/components/Form/Form.type.d.ts +0 -11
- package/src/components/index.d.ts +0 -3
- package/src/context/FormGroupContext.d.ts +0 -19
- package/src/context/FormGroupContext.type.d.ts +0 -48
- package/src/generators/formBuilder.d.ts +0 -9
- package/src/helpers/helpers.d.ts +0 -7
- package/src/helpers/mapper.d.ts +0 -8
- package/src/hooks/index.d.ts +0 -2
- package/src/hooks/useForm/useForm.d.ts +0 -7
- package/src/hooks/useForm/useForm.type.d.ts +0 -12
- package/src/hooks/useFormGroup/useFormGroup.d.ts +0 -4
- package/src/hooks/useFormGroup/useFormGroup.type.d.ts +0 -17
- package/src/index.d.ts +0 -5
- package/src/types/index.d.ts +0 -32
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/form-engine",
|
|
3
|
-
"version": "3.1.1
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "A react adapter for bolttech form engine",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"import": "./index.esm.js",
|
|
10
|
+
"default": "./index.esm.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@bolttech/form-engine-core": "1.1.0"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": "19.1.2",
|
|
18
|
+
"react-dom": "19.1.2"
|
|
19
|
+
},
|
|
5
20
|
"module": "./index.esm.js",
|
|
6
21
|
"type": "module",
|
|
7
22
|
"main": "./index.esm.js",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"react": "18.2.0"
|
|
11
|
-
},
|
|
12
|
-
"peerDependencies": {}
|
|
13
|
-
}
|
|
23
|
+
"types": "./index.d.ts"
|
|
24
|
+
}
|
package/index.esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { TAsFormFieldProps } from './AsFormField.type';
|
|
3
|
-
/**
|
|
4
|
-
* Component wrapper to aid building schemas with react without writting a JSON schema
|
|
5
|
-
* along with BuildAsFormFieldTree inside a Form component, FieldWrapper gets this props
|
|
6
|
-
* to build the component as it does with a JSON schema, this component only works inside
|
|
7
|
-
* the Form component
|
|
8
|
-
*
|
|
9
|
-
* @param {TAsFormFieldProps} props JSON schema props
|
|
10
|
-
* @returns {ReactNode}
|
|
11
|
-
*/
|
|
12
|
-
declare const AsFormField: (props: TAsFormFieldProps) => ReactNode;
|
|
13
|
-
export default AsFormField;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IComponentSchemaAsFormField } from '@bolttech/form-engine-core';
|
|
2
|
-
import { ElementType, PropsWithChildren } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* AsFormField props, inherits all schema field implementation except the children
|
|
5
|
-
* property and has mappers property to pass a custom component, that will be a ReactNode
|
|
6
|
-
* @see {@link IComponentSchemaWithMapper}
|
|
7
|
-
*/
|
|
8
|
-
type TAsFormFieldProps = PropsWithChildren<Omit<IComponentSchemaAsFormField<ElementType>, 'children'>>;
|
|
9
|
-
export type { TAsFormFieldProps };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { TAsFormFieldBuilderProps } from './AsFormFieldBuilder.type';
|
|
3
|
-
/**
|
|
4
|
-
* Component Wrapper to render form fields without the Form component, gets additional formId and mapper since
|
|
5
|
-
* it won't rely on them and needs to be manually declared
|
|
6
|
-
*
|
|
7
|
-
* @param {TAsFormFieldBuilderProps} props JSON schema props along with FieldWrapper props and mapper props
|
|
8
|
-
* @returns {ReactElement}
|
|
9
|
-
*/
|
|
10
|
-
declare const AsFormFieldBuilder: (props: TAsFormFieldBuilderProps) => ReactElement;
|
|
11
|
-
export default AsFormFieldBuilder;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { IComponentSchema, TFieldEvent, TMapper } from '@bolttech/form-engine-core';
|
|
2
|
-
import { ElementType, PropsWithChildren } from 'react';
|
|
3
|
-
import { TFieldWrapper } from '../../types';
|
|
4
|
-
/**
|
|
5
|
-
* AsFormField props, inherits all schema field implementation except the children
|
|
6
|
-
* property, that will be a ReactNode
|
|
7
|
-
* also gets the formIndex for form identification and the mapper to build the component
|
|
8
|
-
* @property {TMapper} mapper element mapper to use
|
|
9
|
-
* @property {boolean} visibility element controlled visibility
|
|
10
|
-
* @property {(data: TFieldEvent) => void} onSelected element callback on selected option
|
|
11
|
-
* @see {@link TMapper}
|
|
12
|
-
* @see {@link IComponentSchema}
|
|
13
|
-
* @see {@link TFieldWrapper}
|
|
14
|
-
*/
|
|
15
|
-
type TAsFormFieldBuilderProps = PropsWithChildren<Omit<IComponentSchema, 'children' | 'component' | 'name'> & Required<TFieldWrapper> & {
|
|
16
|
-
mapper: TMapper<ElementType>;
|
|
17
|
-
visibility?: boolean;
|
|
18
|
-
onSelected?: (data: TFieldEvent) => void;
|
|
19
|
-
formMounted?: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
export type { TAsFormFieldBuilderProps };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { TFieldWrapperProps } from './FieldWrapper.type';
|
|
3
|
-
/**
|
|
4
|
-
* Base field Wrapper to render the component with the necessary configurations from the schema
|
|
5
|
-
* and mapper configuration
|
|
6
|
-
*
|
|
7
|
-
* @param {TFieldWrapperProps} param FieldWrapper params
|
|
8
|
-
* @returns {ReactElement}
|
|
9
|
-
*/
|
|
10
|
-
declare const FieldWrapper: ({ name, formIndex, children, props, context, mounted, mapper, visibility, }: TFieldWrapperProps) => ReactElement;
|
|
11
|
-
export default FieldWrapper;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ElementType, PropsWithChildren } from 'react';
|
|
2
|
-
import { TFieldWrapper } from '../../types';
|
|
3
|
-
import { TFormContext } from '../../context/FormGroupContext';
|
|
4
|
-
import { FormField, TMapper } from '@bolttech/form-engine-core';
|
|
5
|
-
/**
|
|
6
|
-
* Represents the props for a field wrapper component, including children.
|
|
7
|
-
*
|
|
8
|
-
* @property {Record<string, unknown>} [props] - Additional properties for the field.
|
|
9
|
-
* @property {TFormContext | null} [context] - The context of the form, which may be null.
|
|
10
|
-
* @property {React.ReactNode} children - The child elements of the component.
|
|
11
|
-
* @see {@link TFieldWrapper}
|
|
12
|
-
*/
|
|
13
|
-
type TFieldWrapperProps = PropsWithChildren<TFieldWrapper & {
|
|
14
|
-
props?: Record<string, unknown>;
|
|
15
|
-
context?: TFormContext | null;
|
|
16
|
-
mounted?: boolean;
|
|
17
|
-
mapper?: TMapper<ElementType>;
|
|
18
|
-
visibility?: boolean;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Represents the props for rendering a field wrapper component, including children.
|
|
22
|
-
*
|
|
23
|
-
* @property {Record<string, unknown>} props - Additional properties for the field.
|
|
24
|
-
* @property {FormField} [fieldInstance] - The instance of the form field, which may be undefined.
|
|
25
|
-
* @property {React.ReactNode} children - The child elements of the component.
|
|
26
|
-
*/
|
|
27
|
-
type TFieldWrapperComponentRenderProps = PropsWithChildren<{
|
|
28
|
-
props: Record<string, unknown>;
|
|
29
|
-
fieldInstance?: FormField;
|
|
30
|
-
mapper?: TMapper<ElementType>;
|
|
31
|
-
}>;
|
|
32
|
-
export type { TFieldWrapperProps, TFieldWrapperComponentRenderProps };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { TFormProps } from './Form.type';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {TFormProps} param form properties initializor
|
|
6
|
-
* @returns {ReactElement}
|
|
7
|
-
*/
|
|
8
|
-
declare function Form<T>({ schema, index, initialValues, iVars, action, method, config, onSubmit, onFormMount, onData, onBlur, onChange, onApiResponse, onClick, onFocus, onKeyDown, onKeyUp, onMount, onValid, children, }: TFormProps<T>): ReactElement;
|
|
9
|
-
export default Form;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TFormEntry } from '@bolttech/form-engine-core';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { TEventsCallbackProps } from '../../types';
|
|
4
|
-
/**
|
|
5
|
-
* Form props, inherits the form instance constructor implementation except the mapper
|
|
6
|
-
* along with all event callback register props shared with other implementations
|
|
7
|
-
* @see {@link TFormEntry}
|
|
8
|
-
* @see {@link TEventsCallbackProps}
|
|
9
|
-
*/
|
|
10
|
-
type TFormProps<T> = PropsWithChildren<Omit<TFormEntry, 'mappers'> & TEventsCallbackProps<T>>;
|
|
11
|
-
export type { TFormProps };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
|
-
import { TFormContext, TFormContextProvider } from './FormGroupContext.type';
|
|
3
|
-
declare const FormGroupContext: import("react").Context<TFormContext>;
|
|
4
|
-
/**
|
|
5
|
-
* context provider to wrap form-engine adapter elements
|
|
6
|
-
*
|
|
7
|
-
* @param {PropsWithChildren<TFormContextProvider>} param context parameters
|
|
8
|
-
* @returns {ReactElement}
|
|
9
|
-
*/
|
|
10
|
-
declare const FormGroupContextProvider: ({ children, mappers, debugMode, config, }: PropsWithChildren<TFormContextProvider>) => ReactElement;
|
|
11
|
-
/**
|
|
12
|
-
* FormGroup context hook to handle context or isolated context implementations
|
|
13
|
-
*
|
|
14
|
-
* @param {TFormContextProvider} props form group context parameters
|
|
15
|
-
* @returns {TFormContext}
|
|
16
|
-
*/
|
|
17
|
-
declare const useFormGroupContext: (props?: TFormContextProvider) => TFormContext;
|
|
18
|
-
export { FormGroupContext, FormGroupContextProvider, useFormGroupContext };
|
|
19
|
-
export type { TFormContext };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { FormCore, TFormEntry, TFormGroup, TFormValues, TMapper, TSchemaFormConfig } from '@bolttech/form-engine-core';
|
|
2
|
-
import { ElementType } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Represents the context for managing forms within a form group.
|
|
5
|
-
*
|
|
6
|
-
* @property {function(string): void} addFormWithIndex - Adds a form to the form group by its index.
|
|
7
|
-
* @property {function({ key: string, formInstance: TFormCore }): void} addForm - Adds a form to the form group using a payload containing the key and form instance.
|
|
8
|
-
* @property {function({ key: string }): (FormCore | undefined)} getForm - Retrieves a form from the form group using a payload containing the key.
|
|
9
|
-
* @property {function({ key: string }): void} removeForm - Removes a form from the form group using a payload containing the key.
|
|
10
|
-
* @property {TFormGroup} formGroupInstance - The instance of the form group.
|
|
11
|
-
* @property {TMapper<ElementType>[]} [mappers] - Optional array of mappers for elements.
|
|
12
|
-
* @property {function(): void} printFormGroupInstance - Prints the form group instance.
|
|
13
|
-
* @property {function(string[]): TFormValues} submitMultipleFormsByIndex - Submits multiple forms by their indexes and returns the form values.
|
|
14
|
-
* @property {boolean} debugMode - Indicates if debug mode is active.
|
|
15
|
-
* @property {boolean} active - Indicates if the form context is active.
|
|
16
|
-
*/
|
|
17
|
-
type TFormContext = {
|
|
18
|
-
addFormWithIndex: (index: string) => void;
|
|
19
|
-
addForm: (payload: {
|
|
20
|
-
key: string;
|
|
21
|
-
params: TFormEntry;
|
|
22
|
-
}) => void;
|
|
23
|
-
getForm: (payload: {
|
|
24
|
-
key: string;
|
|
25
|
-
}) => FormCore | undefined;
|
|
26
|
-
removeForm: (payload: {
|
|
27
|
-
key: string;
|
|
28
|
-
}) => void;
|
|
29
|
-
formGroupInstance: TFormGroup;
|
|
30
|
-
mappers?: TMapper<ElementType>[];
|
|
31
|
-
printFormGroupInstance: () => void;
|
|
32
|
-
submitMultipleFormsByIndex: <T>(indexes: string[], callback?: (payload: TFormValues<T>) => void) => void;
|
|
33
|
-
debugMode: boolean;
|
|
34
|
-
active: boolean;
|
|
35
|
-
config?: TSchemaFormConfig;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Represents the props for a form context provider.
|
|
39
|
-
*
|
|
40
|
-
* @property {TMapper<ElementType>[]} [mappers] - Optional array of mappers for elements.
|
|
41
|
-
* @property {boolean} [debugMode] - Optional flag indicating if debug mode should be enabled.
|
|
42
|
-
*/
|
|
43
|
-
type TFormContextProvider = {
|
|
44
|
-
mappers?: TMapper<ElementType>[];
|
|
45
|
-
debugMode?: boolean;
|
|
46
|
-
config?: TSchemaFormConfig;
|
|
47
|
-
};
|
|
48
|
-
export type { TFormContext, TFormContextProvider };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ElementType } from 'react';
|
|
2
|
-
import { TMapper, IComponentSchema } from '@bolttech/form-engine-core';
|
|
3
|
-
declare const BuildSchemaAsFields: ({ components, mappers, formIndex, mountedForm, }: {
|
|
4
|
-
components?: IComponentSchema[] | undefined;
|
|
5
|
-
mappers?: TMapper<ElementType>[] | undefined;
|
|
6
|
-
formIndex: string;
|
|
7
|
-
mountedForm: boolean;
|
|
8
|
-
}) => import("react/jsx-runtime").JSX.Element[] | undefined;
|
|
9
|
-
export { BuildSchemaAsFields };
|
package/src/helpers/helpers.d.ts
DELETED
package/src/helpers/mapper.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TValueChangeEvent } from '@bolttech/form-engine-core';
|
|
2
|
-
declare const defaultChangeEvent: TValueChangeEvent;
|
|
3
|
-
declare const checkedChangeEvent: TValueChangeEvent;
|
|
4
|
-
declare const valueChangeEvent: TValueChangeEvent;
|
|
5
|
-
declare const numberInputChangeEvent: TValueChangeEvent;
|
|
6
|
-
declare const datepickerChangeEvent: TValueChangeEvent;
|
|
7
|
-
declare const dropdownChangeEvent: TValueChangeEvent;
|
|
8
|
-
export { defaultChangeEvent, checkedChangeEvent, valueChangeEvent, numberInputChangeEvent, datepickerChangeEvent, dropdownChangeEvent, };
|
package/src/hooks/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { TUseFormProps } from './useForm.type';
|
|
3
|
-
/**
|
|
4
|
-
* Hook to register events callback functions
|
|
5
|
-
*/
|
|
6
|
-
declare function useForm<T>({ id, onData, onSubmit, onFormMount, onValid, ...rest }: TUseFormProps<T>, deps?: React.DependencyList): void;
|
|
7
|
-
export default useForm;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TEventsCallbackProps } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Represents the properties for the useForm hook, including an ID and event callback properties.
|
|
4
|
-
*
|
|
5
|
-
* @property {string} id - The unique identifier for the form.
|
|
6
|
-
*
|
|
7
|
-
* @see {@link TEventsCallbackProps}
|
|
8
|
-
*/
|
|
9
|
-
type TUseFormProps<T> = {
|
|
10
|
-
id: string;
|
|
11
|
-
} & TEventsCallbackProps<T>;
|
|
12
|
-
export type { TUseFormProps };
|
|
@@ -1,17 +0,0 @@
|
|
|
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 };
|
package/src/index.d.ts
DELETED
package/src/types/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { TFieldEvent, TFormValidationPayload, TFormValues } from '@bolttech/form-engine-core';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a field wrapper containing the name of the field and its index in the form.
|
|
4
|
-
*
|
|
5
|
-
* @property {string} name - The name of the field.
|
|
6
|
-
* @property {string} formIndex - The index of the field within the form.
|
|
7
|
-
*/
|
|
8
|
-
type TFieldWrapper = {
|
|
9
|
-
name: string;
|
|
10
|
-
formIndex: string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Represents the possible event properties for form fields callbacks.
|
|
14
|
-
*/
|
|
15
|
-
type TEventProps = 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'onMount' | 'onApiResponse' | 'onApiRequest' | 'onClick' | 'onFieldCleared';
|
|
16
|
-
/**
|
|
17
|
-
* Represents the content inside onData payload action.
|
|
18
|
-
*/
|
|
19
|
-
type TFormData<T> = {
|
|
20
|
-
field: string;
|
|
21
|
-
data: TFormValues<T>;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Represents a mapping of event properties to their corresponding callback functions.
|
|
25
|
-
*/
|
|
26
|
-
type TEventsCallbackProps<T> = Partial<Record<TEventProps, ((payload: TFieldEvent) => void) | null | undefined>> & {
|
|
27
|
-
onFormMount?: (payload: TFormValues<T>) => void;
|
|
28
|
-
onData?: (payload: TFormData<T>) => void;
|
|
29
|
-
onSubmit?: (payload: TFormValues<T>) => void;
|
|
30
|
-
onValid?: (payload: TFormValidationPayload) => void;
|
|
31
|
-
};
|
|
32
|
-
export { TFieldWrapper, TEventProps, TEventsCallbackProps, TFormData };
|