@bolttech/form-engine 0.1.9 → 0.2.0

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.2.0](http://bitbucket.org/gofrank/bolttech-frontend/compare/form-engine-0.1.9...form-engine-0.2.0) (2023-08-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * select index on step back or forward ([c651570](http://bitbucket.org/gofrank/bolttech-frontend/commit/c651570ab0a6c378310a79799910ceb5891f1c7f))
11
+
5
12
  ## [0.1.9](http://bitbucket.org/gofrank/bolttech-frontend/compare/form-engine-0.1.8...form-engine-0.1.9) (2023-08-01)
6
13
 
7
14
  ## [0.1.8](http://bitbucket.org/gofrank/bolttech-frontend/compare/form-engine-0.1.7...form-engine-0.1.8) (2023-08-01)
package/README.md CHANGED
@@ -2,36 +2,37 @@
2
2
 
3
3
  Achieve form logic reusage with forms expressed in json format.
4
4
 
5
- > version 0.1.7
5
+ > version 0.2.0
6
6
 
7
7
  ---
8
8
 
9
9
  1. [Basic setup](#markdown-header-basic-setup)
10
10
  2. [Step by step](#markdown-header-step-by-step)
11
11
  3. [Form Features](#markdown-header-available-features)
12
- 3.1. [Validations - Allow form to run validations in the field](#markdown-header-validations)
13
- 3.1.1. [Named Validations](#markdown-header-validations)
14
- 3.1.2. [Error Messages](#markdown-header-validations)
15
- 3.1.3. [Available Validations](#markdown-header-validations)
16
- 3.2. [Filters - Allow only what you want in the field](#markdown-header-filters)
17
- 3.2.1. [Available formatters](#markdown-header-formatters)
18
- 3.3. [Formatters - Style your field value with formatters](#markdown-header-formatters)
19
- 3.4. [Masks - Modify the field value, while maintaining the original with masks](#markdown-header-masks)
20
- 3.4.1. [Available Masks](#markdown-header-formatters)
21
- 3.5. [Visibility conditions - Configure when to show hide/components](#markdown-header-visibility-conditions)
22
- 3.6. [Clear fields](#markdown-header-clear-fields)
23
- 3.7. [Api - Make api calls on certain form events](#markdown-header-api)
24
- 3.8. [Data binding - Allow to have dynamic data in the form, binding and subscribing to form changes](#markdown-header-data-binding)
25
- 3.8.1. [Scopes](#markdown-header-scope)
26
- 3.8.2. [Templates](#markdown-header-templates)
27
- 3.8.3. [varOps](#markdown-header-varops)
28
- 3.9. [State - Define component state](#markdown-header-state)
29
- 3.10. [Group](#markdown-header-group)
12
+ - 3.1. [Validations - Allow form to run validations in the field](#markdown-header-validations)
13
+ - 3.1.1. [Named Validations](#markdown-header-validations)
14
+ - 3.1.2. [Error Messages](#markdown-header-validations)
15
+ - 3.1.3. [Available Validations](#markdown-header-validations)
16
+ - 3.2. [Filters - Allow only what you want in the field](#markdown-header-filters)
17
+ - 3.2.1. [Available formatters](#markdown-header-formatters)
18
+ - 3.3. [Formatters - Style your field value with formatters](#markdown-header-formatters)
19
+ - 3.4. [Masks - Modify the field value, while maintaining the original with masks](#markdown-header-masks)
20
+ - 3.4.1. [Available Masks](#markdown-header-formatters)
21
+ - 3.5. [Visibility conditions - Configure when to show hide/components](#markdown-header-visibility-conditions)
22
+ - 3.6. [Clear fields](#markdown-header-clear-fields)
23
+ - 3.7. [Api - Make api calls on certain form events](#markdown-header-api)
24
+ - 3.8. [Data binding - Allow to have dynamic data in the form, binding and subscribing to form changes](#markdown-header-data-binding)
25
+ - 3.8.1. [Scopes](#markdown-header-scope)
26
+ - 3.8.2. [Templates](#markdown-header-templates)
27
+ - 3.8.3. [varOps](#markdown-header-varops)
28
+ - 3.9. [State - Define component state](#markdown-header-state)
29
+ - 3.10. [Group](#markdown-header-group)
30
+ - 3.11. [Steps](#markdown-header-form-step)
30
31
  4. [React](#markdown-header-react-components)
31
- 4.1. [FormProvider - Provider to configure the form with component mappings](#markdown-header-react-formprovider)
32
- 4.2. [Form - Component to render a form based on a schema and listen to some events](#markdown-header-react-form)
33
- 4.3. [useForm hook- Allo to connect to any form in the page](#markdown-header-react-useform)
34
- 4.4. [asFormField HOC- Leverage form features but keep the control of your component](#markdown-header-react-asFormField-HOC)
32
+ - 4.1. [FormProvider - Provider to configure the form with component mappings](#markdown-header-react-formprovider)
33
+ - 4.2. [Form - Component to render a form based on a schema and listen to some events](#markdown-header-react-form)
34
+ - 4.3. [useForm hook- Allo to connect to any form in the page](#markdown-header-react-useform)
35
+ - 4.4. [asFormField HOC- Leverage form features but keep the control of your component](#markdown-header-react-asFormField-HOC)
35
36
 
36
37
  ## **Basic setup**
37
38
 
@@ -912,6 +913,65 @@ Say you have two checkboxes and want the selected value. You can use `group` for
912
913
 
913
914
  This example will store the selected value of the checkbox in the `checkedGroup` and will then be sent to the client.
914
915
 
916
+ ## Form Step
917
+
918
+ In the form it is possible to use it as steps. With this it is possible to have more than one form in just one schema.
919
+
920
+ For example, if you implement something like:
921
+
922
+ ```js
923
+ {
924
+ components: [
925
+ { component: '', name: 'step1', children: [] },
926
+ { component: '', name: 'step2', children: [] },
927
+ { component: '', name: 'step3', children: [] },
928
+ ]
929
+ }
930
+ ```
931
+
932
+ You can control the go back and forth event from the [onClick](#props) event of a button inside one of the forms using the form reference.
933
+ Or Simply using the form reference in a button outside the form, for example:
934
+
935
+ ```js
936
+ {
937
+ const ref = useRef<TFormRefActions>(null);
938
+
939
+ return <Form
940
+ id='form'
941
+ ref={ref}
942
+ onClick={() => ref.current?.stepForward()}
943
+ />
944
+ }
945
+
946
+ // --------------------- OR --------------------- //
947
+
948
+ {
949
+ const ref = useRef<TFormRefActions>(null);
950
+
951
+ return (
952
+ <>
953
+ <Form
954
+ id='form'
955
+ ref={ref}
956
+ />
957
+ <button onClick={ref.current?.stepBack()} />
958
+ </>
959
+ )
960
+ }
961
+ ```
962
+
963
+ However, it is possible to choose which step you want to go or go back, using the numerical index or simply the name of the step you want, for example:
964
+
965
+ ```js
966
+ () => ref.current?.stepForward(2);
967
+ // --------------- OR -------------- //
968
+ () => ref.current?.stepForward('step3');
969
+
970
+ () => ref.current?.stepBack(0);
971
+ // --------------- OR -------------- //
972
+ () => ref.current?.stepBack('step1');
973
+ ```
974
+
915
975
  # React Components
916
976
 
917
977
  ## React `<FormProvider />`
@@ -958,7 +1018,7 @@ const App = () => {
958
1018
  };
959
1019
  ```
960
1020
 
961
- You now can use in your [form](#react-form) the mapped components with names `inputForm` and `dropdownForm`.
1021
+ You now can use in your [form](#react-form-) the mapped components with names `inputForm` and `dropdownForm`.
962
1022
 
963
1023
  Also note the data in `propsMapping`. There you can map up to five form functionalities per component
964
1024
 
@@ -1024,7 +1084,7 @@ After configuring the provider, `<Form />` components lets you render a form
1024
1084
  | onStep | callback(TFormValues) | Called when a form step changed |
1025
1085
  | onLog | callback(TLoggingEvent) | Called on each log, if the logging is enabled |
1026
1086
  | onScopeChange | onScopeChange?(scope: TScope, namespace: string, key: string): void; | Called everything scope change with the changing information (namespace and key) and the changed scope |
1027
- | |
1087
+ | onClick | onClick(TFormValues, TField) | Callback function that runs on each component click |
1028
1088
  | onFieldRehydrate | onFieldRehydrate?(values: TFormValues, component: TComponent, field: TField): void | This callback is called whenever some form field was rehydrated |
1029
1089
  | renderLoading | renderLoading?(): ReactElement; | Component to render while the schema has not rendered |
1030
1090
  | onFormMount | onFormMount?(values: TFormValues): void; | Called when the form finished mounted |