@bolttech/form-engine 3.0.1-beta.7 → 3.0.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/README.md CHANGED
@@ -17,13 +17,16 @@ This is an adapter to be used with the bolttech form engine. Compatible with Nex
17
17
  6. [schema components](#schema-components)
18
18
 
19
19
  - 6.1 [formatters](#formatters)
20
- - 6.2 [masks] (#masks)
20
+ - 6.2 [masks](#masks)
21
21
  - 6.3 [nameToSubmit](#nametosubmit)
22
22
  - 6.4 [props](#props)
23
23
  - 6.5 [validations](#validations)
24
24
  - 6.6 [api](#api)
25
25
  - 6.7 [resetValues](#resetvalues)
26
26
  - 6.8 [visibilityConditions](#visibilityconditions)
27
+ - 6.9 [resetPropertyValues](#resetpropertyvalues)
28
+ - 6.10 [visibility](#visibility)
29
+ - 6.11 [persistValue](#persistValue)
27
30
 
28
31
  7. [templating](#templating)
29
32
 
@@ -34,8 +37,10 @@ This is an adapter to be used with the bolttech form engine. Compatible with Nex
34
37
 
35
38
  9. [AsFormField](#asformfield)
36
39
  10. [AsFormFieldBuilder](#asformfieldbuilder)
40
+ 11. [AsFormFieldRepeater](#asformfieldrepeater)
37
41
 
38
42
  <a id="sample"></a>
43
+
39
44
  ## **Sample**
40
45
 
41
46
  ```typescript
@@ -110,6 +115,7 @@ const Sample = () => {
110
115
  );
111
116
  };
112
117
  ```
118
+
113
119
  <a id="mappers"></a>
114
120
 
115
121
  ## **Mappers**
@@ -128,17 +134,18 @@ The mapper configuration goes as it follows:
128
134
 
129
135
  `events` are optional and will reference component props that will provide it's dynamic behaviour:
130
136
 
131
- | Prop | Type | Description |
132
- | --------------- | ------ | ------------------------------------------------------------------------------------------- |
133
- | getValue | string | component property that will contain the value |
134
- | setValue | string | component property that handles onChange events triggered by the component |
135
- | onBlur | string | component property that handles onBlur events triggered by the component |
136
- | onClick | string | component property that handles onClick events triggered by the component |
137
- | onFocus | string | component property that handles onFocus events triggered by the component |
138
- | onKeyUp | string | component property that handles onKeyUp events triggered by the component |
139
- | onKeyDown | string | component property that handles onKeyDown events triggered by the component |
140
- | setErrorMessage | string | component property that recieves the errors of the field as string |
141
- | setErrorState | string | component property that recieves the error status of the field as boolean (not implemented) |
137
+ | Prop | Type | Description |
138
+ | --------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
139
+ | getValue | string | component property that will contain the value |
140
+ | setValue | string | component property that handles onChange events triggered by the component |
141
+ | onBlur | string | component property that handles onBlur events triggered by the component |
142
+ | onClick | string | component property that handles onClick events triggered by the component |
143
+ | onSubmit | string | component property that handles form submission event triggered by the component (a way to submit a form using AsFormFieldBuilder, if used with AsFormField and Form will trigger submission twice) |
144
+ | onFocus | string | component property that handles onFocus events triggered by the component |
145
+ | onKeyUp | string | component property that handles onKeyUp events triggered by the component |
146
+ | onKeyDown | string | component property that handles onKeyDown events triggered by the component |
147
+ | setErrorMessage | string | component property that receives the errors of the field as string |
148
+ | setErrorState | string | component property that receives the error status of the field as boolean (not implemented) |
142
149
 
143
150
  ### component and asynccomponent
144
151
 
@@ -245,7 +252,7 @@ const mapper = [
245
252
 
246
253
  <a id="form-group-context"></a>
247
254
 
248
- ## **Form Group Context**
255
+ ## **Form Group Context**
249
256
 
250
257
  <a id="formgroupcontextprovider"></a>
251
258
 
@@ -406,6 +413,7 @@ const FormComponent = (): React.ReactElement => {
406
413
 
407
414
  export default FormComponent;
408
415
  ```
416
+
409
417
  <a id="form"></a>
410
418
 
411
419
  ## **Form**
@@ -414,33 +422,40 @@ After configuring the provider, `<Form />` components lets you render a form
414
422
 
415
423
  ### Props
416
424
 
417
- | Prop | Type | Description |
418
- | ----------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
419
- | [DEPRECIATED] disable | boolean | Disable all form inputs. It will use the default htm disable attribute |
425
+ | Prop | Type | Description |
426
+ | ----------------------------------- | ---------------------------------------------------------------------------------- | ------------ |
427
+ | [DEPRECIATED] disable | boolean | Disable all form inputs. It will use the default htm disable attribute |
420
428
  | [DEPRECIATED] group | string | Form group identifier. Used be able to group several forms and then get data with useGroupForm. One will be generated as default if omitted |
421
- | index | string | Form identified. One will be generated as default if omitted |
422
- | [DEPRECIATED] hooks | THooks | Provide functions to run on certain life-cycle events |
423
- | iVars | Object | One object with internal variables to be used in form with data binding |
424
- | initialValues | Object | Object with form initial values that will map to a field. |
425
- | Schema | TSchema | Form Schema |
426
- | [DEPRECIATED] autoComplete | string | HTML autocomplete |
427
- | className | string | Allow to style form |
428
- | onSubmit | callback(TFormValues) | Will be called when there is a submit action in the form |
429
- | onData | callback(TFormData) | Will be called when any field data change. The arguments will let you know which field changed and the field configuration |
430
- | onBlur | callback(TFieldEvent) | Will be called when any field blured. The arguments will let you know which field blured and the field configuration |
431
- | onFocus | callback(TFieldEvent) | Will be called when any field focused change. The arguments will let you know which field focused and the field configuration |
432
- | onMount | callback(TFormValues,TComponent, TField) | Will be called when some field mounted. Its called with the field that information that mounted. |
433
- | [DEPRECIATED] onStep | callback(TFormValues) | Called when a form step changed |
434
- | [DEPRECIATED] onLog | callback(TLoggingEvent) | Called on each log, if the logging is enabled |
435
- | [DEPRECIATED] onScopeChange | onScopeChange?(scope: TScope, namespace: string, key: string): void; | Called everything scope change with the changing information (namespace and key) and the changed scope |
436
- | onClick | onClick(TFieldEvent) | Callback function that runs on each component click |
437
- | onApiResponse | onApiResponse(TFieldEvent) | Callback function that runs on each component after api call. |
438
- | [DEPRECIATED] onFieldRehydrate | onFieldRehydrate?(values: TFormValues, component: TComponent, field: TField): void | This callback is called whenever some form field was rehydrated |
439
- | [DEPRECIATED] renderLoading | renderLoading?(): ReactElement; | Component to render while the schema has not rendered |
440
- | [DEPRECIATED] onFormMount | onFormMount?(values: TFormValues): void; | Called when the form finished mounted |
441
- | [DEPRECIATED] formattedDataDefaults | Object | Some default data to fields when they are undefined |
442
- | [DEPRECIATED] submitOnValidOnly | boolean | Boolean indicating if form can be submitted even if it is invalid |
443
- | [DEPRECIATED] renderFieldWrapper | renderFieldWrapper(component: TComponent, children: ReactElement[]) | Function that allows to insert a wrapper in place of a component or wrapping the component |
429
+ | index | string | Form identified. One will be generated as default if omitted |
430
+ | [DEPRECIATED] hooks | THooks | Provide functions to run on certain life-cycle events |
431
+ | iVars | Object | One object with internal variables to be used in form with data binding |
432
+ | initialValues | Object | Object with form initial values that will map to a field. |
433
+ | Schema | TSchema | Form Schema |
434
+ | [DEPRECIATED] autoComplete | string | HTML autocomplete |
435
+ | className | string | Allow to style form |
436
+ | onSubmit | callback(TFormValues) | Will be called when there is a submit action in the form |
437
+ | onData | callback(TFormData) | Will be called when any field data change. The arguments will let you know which field changed and the field configuration |
438
+ | onBlur | callback(TFieldEvent) | Will be called when any field blured. The arguments will let you know which field blured and the field configuration |
439
+ | onFocus | callback(TFieldEvent) | Will be called when any field focused change. The arguments will let you know which field focused and the field configuration |
440
+ | onMount | callback(TFormValues,TComponent, TField) | Will be called when some field mounted. Its called with the field that information that mounted. |
441
+ | [DEPRECIATED] onStep | callback(TFormValues) | Called when a form step changed |
442
+ | [DEPRECIATED] onLog | callback(TLoggingEvent) | Called on each log, if the logging is enabled |
443
+ | [DEPRECIATED] onScopeChange | onScopeChange?(scope: TScope, namespace: string, key: string): void; | Called everything scope change with the changing information (namespace and key) and the changed scope |
444
+ | onClick | onClick(TFieldEvent) | Callback function that runs on each component click |
445
+ | onApiResponse | onApiResponse(TFieldEvent) | Callback function that runs on each component after api call. |
446
+ | [DEPRECIATED] onFieldRehydrate | onFieldRehydrate?(values: TFormValues, component: TComponent, field: TField): void | This callback is called whenever some form field was rehydrated |
447
+ | [DEPRECIATED] renderLoading | renderLoading?(): ReactElement; | Component to render while the schema has not rendered |
448
+ | [DEPRECIATED] onFormMount | onFormMount?(values: TFormValues): void; | Called when the form finished mounted |
449
+ | [DEPRECIATED] formattedDataDefaults | Object | Some default data to fields when they are undefined |
450
+ | [DEPRECIATED] submitOnValidOnly | boolean | Boolean indicating if form can be submitted even if it is invalid |
451
+ | [DEPRECIATED] renderFieldWrapper | renderFieldWrapper(component: TComponent, children: ReactElement[]) | Function that allows to insert a wrapper in place of a component or wrapping the component |
452
+ | onApiRequest | onApiRequest(TFieldEvent) | Callback function that runs when an api call starts |
453
+ | onChange | onFieldChange(TFieldEvent) | Callback function that runs on each component value changes
454
+ | onKeyDown | onKeyDown(TFieldEvent) | Callback function that runs on each key down event |
455
+ | onKeyUp | onKeyUp(TFieldEvent) | Callback function that runs on each key up event |
456
+ | onCleared | onCleared(TFieldEvent) | Callback function that runs on a value that has been changed by resetValues event |
457
+ | onUnmount | onUnmount(TFieldEvent) | Callback function that runs when a field is unmounted or hidden by a visibility condition rule (use with caution) |
458
+
444
459
 
445
460
  ### Example
446
461
 
@@ -449,6 +464,7 @@ A simple example of rendering a basic form
449
464
  ```javascript
450
465
  <Form schema={schema} />
451
466
  ```
467
+
452
468
  <a id="submit-form"></a>
453
469
 
454
470
  ## **Submit Form**
@@ -515,15 +531,15 @@ have a `Form` component and event callback functions needs to be setted
515
531
 
516
532
  Schema is the structure of the form, it will contain the logic to be rendered and configurations of the fields to apply dynamic logic
517
533
 
518
- | Prop | Type | Description |
519
- | -------------- | ----------------------- | ----------------------------------------------------------------------- |
520
- | index | string | unique form id to handle multiple form on form group |
521
- | action? | string | WIP: HTML form native action property to handle native form submissions |
522
- | method? | string | WIP: HTML form native method property to handle native form submissions |
523
- | config? | TSchemaFormConfig | Optional configuration object to set api and events debounce time |
524
- | initialValues? | Record<string, unknown> | initial values to be loaded on the form |
525
- | iVars? | Record<string, unknown> | dynamic values that can be changed externally to be used onto the form |
526
- | components? | IComponentSchema[] | components to be rendered defined on the mappers |
534
+ | Prop | Type | Description |
535
+ | ----------------------------------------------------------------------------------------------------------- | ----------------------- | ----------------------------------------------------------------------- |
536
+ | [index](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#index) | string | unique form id to handle multiple form on form group |
537
+ | [action](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#action)? | string | WIP: HTML form native action property to handle native form submissions |
538
+ | [method](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#method)? | string | WIP: HTML form native method property to handle native form submissions |
539
+ | [config](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#config)? | TSchemaFormConfig | Optional configuration object to set api and events debounce time |
540
+ | [initialValues](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#initialvalues)? | Record<string, unknown> | initial values to be loaded on the form |
541
+ | [iVars](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#ivars)? | Record<string, unknown> | dynamic values that can be changed externally to be used onto the form |
542
+ | [components](../../docs/form-engine-core/src/interfaces/schema/interfaces/IFormSchema.md#components)? | IComponentSchema[] | components to be rendered defined on the mappers |
527
543
 
528
544
  this root configuration can be defined onto the `Form` component except the `components`
529
545
 
@@ -557,19 +573,19 @@ const schema: IFormSchema = {
557
573
 
558
574
  Schema components contains the information of the component that will be rendered and the configurations he will exectute
559
575
 
560
- | Prop | Type | Description |
561
- | --------------------- | -------------------- | ------------------------------------------------------------------------------------------- |
562
- | component | string | component name defined on schema to render the correspondent component |
563
- | props? | TProps | props of the component ex: label |
564
- | name | string | unique id to identify the field onto form-engine |
565
- | nameToSubmit? | string | dot notation to submit a custom path to the component value ex: 'person.profile.firstName' |
566
- | validations? | TValidations | validations configuration described below |
567
- | api? | TApiEvent | api configuration described below |
568
- | visibilityConditions? | TVisibility[] | visibilityConditions configuration described below |
569
- | resetValues? | TResetValueMethods[] | resetValues configuration described below |
570
- | formatters? | TFormatters | formatters configuration described below |
571
- | masks? | TMasks | masks configuration described below |
572
- | children? | IComponentSchema[] | nested components to be rendered (if the current parent component accepts child components) |
576
+ | Prop | Type | Description |
577
+ | ------------------------------------------------------------------------------------------------------------------------------ | -------------------- | ------------------------------------------------------------------------------------------- |
578
+ | [component](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#component) | string | component name defined on schema to render the correspondent component |
579
+ | [props](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#props)? | TProps | props of the component ex: label |
580
+ | [name](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#name) | string | unique id to identify the field onto form-engine |
581
+ | [nameToSubmit](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#nametosubmit)? | string | dot notation to submit a custom path to the component value ex: 'person.profile.firstName' |
582
+ | [validations](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#validations)? | TValidations | validations configuration described below |
583
+ | [api](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#api)? | TApiEvent | api configuration described below |
584
+ | [visibilityConditions](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#visibilityconditions)? | TVisibility[] | visibilityConditions configuration described below |
585
+ | [resetValues](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#resetvalues)? | TResetValueMethods[] | resetValues configuration described below |
586
+ | [formatters](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#formatters)? | TFormatters | formatters configuration described below |
587
+ | [masks](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#masks)? | TMasks | masks configuration described below |
588
+ | [children](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md#children)? | IComponentSchema[] | nested components to be rendered (if the current parent component accepts child components) |
573
589
 
574
590
  ### Example
575
591
 
@@ -621,25 +637,55 @@ Schema components contains the information of the component that will be rendere
621
637
  }]
622
638
  }
623
639
  ```
640
+
641
+ Check the [TSDocs](../../docs/form-engine-core/src/interfaces/schema/interfaces/IComponentSchema.md) from `IComponentSchema` on form-engine-core
642
+
624
643
  <a id="formatters"></a>
625
644
 
626
645
  ## **formatters**
627
646
 
628
- formatters are methods that will format the input inserted on any field, they will format a value, regardless the event type,
647
+ formatters are methods that will format the input inserted on any field, they will format a value, regardless the event type.
648
+
649
+ | Prop | Type | Description |
650
+ | ------------------------------------------------------------------------------------------------------------ | ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
651
+ | [callback](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#callback)? | (value) => void | Custom formatter callback function |
652
+ | [capitalize](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#capitalize)? | boolean | Capitalize the value |
653
+ | [dotEvery3chars](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#dotevery3chars)? | boolean | Add a dot every 3 characters |
654
+ | [gapsCreditCard](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#gapscreditcard) | string[] | Gaps to insert in credit card numbers |
655
+ | [maxLength](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#maxlength)? | number | Truncates the input value to a specified maximum length if necessary |
656
+ | [onlyFloatNumber](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#onlyfloatnumber)? | TCurrencyMask | Allow only float numbers with specific precision and decimal |
657
+ | [onlyLetters](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#onlyletters)? | boolean | Allow only letters |
658
+ | [onlyNumbers](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#onlynumbers)? | boolean | Allow only numbers |
659
+ | [regex](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#regex)? | string | Regular expression for formatting |
660
+ | [splitter](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#splitter)? | TSplitterFormatterValue[] | Splitter values for formatting |
661
+ | [trim](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#trim)? | boolean | Removes whitespace from both ends of this string and returns a new string, without modifying the original string |
662
+ | [uppercase](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md#uppercase)? | boolean | Convert the value to uppercase |
629
663
 
630
664
  ### Avaliable formatters
631
665
 
632
- Check the TSDocs from `TFormatters` on form-engine-core
666
+ Check the [TSDocs](../../docs/form-engine-core/src/types/schema/type-aliases/TFormatters.md) from `TFormatters` on form-engine-core
633
667
 
634
668
  <a id="masks"></a>
635
669
 
636
670
  ## **masks**
637
671
 
638
- masks are methods that will format the input inserted on any field, they will show to the user a formatted value, but the submission value will be the original input of the user
672
+ masks are methods that will format the input inserted on any field, they will show to the user a formatted value, but the submission value will be the original input of the user.
673
+
674
+ | Prop | Type | Description |
675
+ | --------------------------------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------ |
676
+ | [card](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#card)? | boolean | Mask for card values |
677
+ | [cardDate](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#carddate)? | boolean | Mask for card date values |
678
+ | [currency](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#currency)? | TCurrencyMask | Mask for currency values |
679
+ | [custom](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#custom) | string | Custom mask pattern |
680
+ | [fein](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#fein)? | boolean | Mask for FEIN (Federal Employer Identification Number) |
681
+ | [generic](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#generic)? | TMaskGeneric[] | Array of generic masks |
682
+ | [replaceAll](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#replaceall)? | string | Value to replace all matches |
683
+ | [secureCreditCard](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#securecreditcard)? | boolean | Mask for securing credit card values |
684
+ | [callback](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md#callback)? | (value, masks) => void | Custom mask callback function |
639
685
 
640
686
  ### Avaliable masks
641
687
 
642
- Check the TSDocs from `TMasks` on form-engine-core
688
+ Check the [TSDocs](../../docs/form-engine-core/src/types/schema/type-aliases/TMasks.md) from `TMasks` on form-engine-core
643
689
 
644
690
  ### From v2 to v3
645
691
 
@@ -659,6 +705,7 @@ const formatters = {
659
705
  upperCase: true,
660
706
  };
661
707
  ```
708
+
662
709
  <a id="nametosubmit"></a>
663
710
 
664
711
  ## **nameToSubmit**
@@ -686,6 +733,7 @@ when calling the `onSubmit` or `onData` the field section of this field will out
686
733
  }
687
734
  }
688
735
  ```
736
+
689
737
  <a id="props"></a>
690
738
 
691
739
  ## **props**
@@ -720,7 +768,7 @@ validations let you set rules in order to validate a field, then show errorMessa
720
768
 
721
769
  ### Avaliable validations
722
770
 
723
- Check the TSDocs from `TValidationMethods` on form-engine-core
771
+ Check the [TSDocs](../../docs/form-engine-core/src/types/schema/type-aliases/TValidationMethods.md) from `TValidationMethods` on form-engine-core
724
772
 
725
773
  ### From v2 to v3
726
774
 
@@ -807,17 +855,18 @@ The configuration is as it follows:
807
855
 
808
856
  Each config you opt to use, needs to be filled with an API configuration, the configuration is as it follows:
809
857
 
810
- | Prop | Type | Description |
811
- | ------------------------ | --------------------------------- | ------------------------------------------------------------------------------------- |
812
- | method | 'GET' or 'POST' | HTTP method (only GET or POST) |
813
- | url | string | Request url ex: http://mockapi.org |
814
- | body? | Record<string, unknown> | Request body (only POST requests) |
815
- | headers? | OutgoingHttpHeaders | Avaliable HTTP headers |
816
- | resultPath? | string | response dot notation path to the value needed from the response |
817
- | fallbackValue? | unknown | default value to return if the API returns error |
818
- | preConditions? | TSchemaValidation | validations to occur before the request is made (check validations section) |
819
- | blockRequestWhenInvalid? | boolean | flag to only request the api config if the field is valid |
820
- | transform? | { callback:(payload) => unknown } | custom function to be passed as callback to transform the request in any other format |
858
+ | Prop | Type | Description |
859
+ | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------- |
860
+ | [method](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#method) | 'GET' or 'POST' | HTTP method (only GET or POST) |
861
+ | [url](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#url) | string | Request url ex: http://mockapi.org |
862
+ | [body](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#body)? | Record<string, unknown> | Request body (only POST requests) |
863
+ | [headers](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#headers)? | OutgoingHttpHeaders | Avaliable HTTP headers |
864
+ | [queryParams](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#queryparams)? | Record<string,string> | url query params (to be appended to the already existing ones) |
865
+ | [resultPath](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#resultpath)? | string | response dot notation path to the value needed from the response |
866
+ | [fallbackValue](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#fallbackvalue)? | unknown | default value to return if the API returns error |
867
+ | [preConditions](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#preconditions)? | TSchemaValidation | validations to occur before the request is made (check validations section) |
868
+ | [blockRequestWhenInvalid](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#blockrequestwheninvalid)? | boolean | flag to only request the api config if the field is valid |
869
+ | [transform](../../docs/form-engine-core/src/types/schema/type-aliases/TApiConfig.md#transform)? | { callback:(payload) => unknown } | custom function to be passed as callback to transform the request in any other format |
821
870
 
822
871
  ### From v2 to v3
823
872
 
@@ -857,7 +906,7 @@ const api = {
857
906
  };
858
907
  ```
859
908
 
860
- the API result is commonly used with `templating`, check [templating](#markdown-templating) section
909
+ the API result is commonly used with `templating`, check [templating](#templating) section
861
910
 
862
911
  <a id="resetvalues"></a>
863
912
 
@@ -865,14 +914,14 @@ the API result is commonly used with `templating`, check [templating](#markdown-
865
914
 
866
915
  resetValues lets you change input values with the same rules as validations
867
916
 
868
- | Prop | Type | Description |
869
- | -------------- | -------------------- | ---------------------------------------------------------------------------------- |
870
- | validations | TSchemaValidation | validations rules to be validated to reset the value to the configuration provided |
871
- | fields | string[] or string | field or fields that will recieve the resettled value |
872
- | events | Partial<TEvents>[] | events that will trigger the validation |
873
- | resettledValue | unknown[] or unknown | value or values to be set on the specified fields |
917
+ | Prop | Type | Description |
918
+ | --------------------------------------------------------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------- |
919
+ | [validations](../../docs/form-engine-core/src/types/schema/type-aliases/TSchemaValidation.md) | TSchemaValidation | validations rules to be validated to reset the value to the configuration provided |
920
+ | fields | string[] or string | field or fields that will recieve the resettled value |
921
+ | events | Partial<TEvents>[] | events that will trigger the validation |
922
+ | resettledValue | unknown[] or unknown | value or values to be set on the specified fields |
874
923
 
875
- if the event occurs and all the validations returns `true` the resettled value will trigger and the `fields` specified will be filled with the `resettledValue` values
924
+ if the event occurs and all the validations returns `true` the resettled value will trigger and the `fields` specified will be filled with the `resettledValue` values, also, the event ON_FIELD_CLEARED is triggered on the fields that gets the resettled value instead of ON_FIELD_CHANGE.
876
925
 
877
926
  ### from v2 to v3
878
927
 
@@ -904,6 +953,7 @@ const resetValues = [
904
953
  },
905
954
  ];
906
955
  ```
956
+
907
957
  <a id="visibilityconditions"></a>
908
958
 
909
959
  ## **visibilityConditions**
@@ -952,6 +1002,58 @@ const visibilityConditions = [
952
1002
  ];
953
1003
  ```
954
1004
 
1005
+ <a id="resetpropertyvalues"></a>
1006
+
1007
+ ## **resetPropertyValues**
1008
+
1009
+ resetPropertyValues will change a property value based on validation rules
1010
+
1011
+ > WARNING: do not rely on this to make mutations on your properties, templating already is a powerful tool and with this you can destroy some schema configurations accidentaly, this is a last resort schema manipulation tool to solve some edge cases with API requests callbacks handling
1012
+
1013
+ | Prop | Type | Description |
1014
+ | -------------- | -------------------------------------------- | -------------------------------------------------------------- |
1015
+ | property | typeof ALLOWED_RESET_PROPS_MUTATIONS[number] | property to be changed, ex: api, resetValues, etc.. |
1016
+ | path | string | path where the property to be changed is located |
1017
+ | field | string | field that will recieve the property change |
1018
+ | resettledValue | unknown | value to be replaced onto the property |
1019
+ | validations | TSchemaValidation | validations rules to be validated to change the property value |
1020
+ | events | Partial<TEvents>[] | events to listen to apply this change |
1021
+
1022
+ example:
1023
+
1024
+ this will change the `api.named.chuck` property onto field `postalCode` when the `ON_FIELD_CHANGE` event occurs,
1025
+ will change the content to: `{ status: null, response: ''}`
1026
+
1027
+ ```typescript
1028
+ resetPropertyValues: [
1029
+ {
1030
+ property: 'api',
1031
+ path: 'named.chuck',
1032
+ events: ['ON_FIELD_CHANGE'],
1033
+ field: 'postalCode',
1034
+ resettledValue: {
1035
+ status: null,
1036
+ response: '',
1037
+ },
1038
+ validations: {
1039
+ bool: false,
1040
+ },
1041
+ },
1042
+ ];
1043
+ ```
1044
+
1045
+ <a id="visibility"></a>
1046
+
1047
+ ## **visibility**
1048
+
1049
+ visibility prop is used to initiate the component with an initial visibility flag, before visibilityConditions take place, used on SSR
1050
+
1051
+ <a id="persistValue"></a>
1052
+
1053
+ ## **persistValue**
1054
+
1055
+ persistValue is a flag that deremines if the field gets hidden, the moment it comes back visible, it will hold the previous value or not
1056
+
955
1057
  <a id="templating"></a>
956
1058
 
957
1059
  ## **templating**
@@ -1039,9 +1141,12 @@ The avalialbe callback methods are:
1039
1141
  | onFocus | TFieldEvent | same as above |
1040
1142
  | onKeyDown | TFieldEvent | same as above |
1041
1143
  | onKeyUp | TFieldEvent | same as above |
1042
- | onMount | TFieldEvent | same as above |
1043
- | onApiResponse | TFieldEvent | same as above |
1044
1144
  | onClick | TFieldEvent | same as above |
1145
+ | onApiResponse | TFieldEvent | event occuring when a api response is ready |
1146
+ | onApiRequest | TFieldEvent | event occuring when a api resquest is started |
1147
+ | onMount | TFieldEvent | event occuring when a field is mounted or set visible |
1148
+ | onUnmount | TFieldEvent | event occuring when a field is unmounted or hidden |
1149
+ | onCleared | TFieldEvent | event occuring when the field value is set with resetValues |
1045
1150
  | onFormMount | TFormValues<T> | event occuring on form mount |
1046
1151
  | onData | TFormData<T> | event occuring when a value is changing via input or logic |
1047
1152
  | onSubmit | TFormValues<T> | event occuring when pressing the submit button defined on the form |
@@ -1057,10 +1162,11 @@ useFormGroup({ ids: ['form1', 'form2'], onData: (payload) => console.log(payload
1057
1162
 
1058
1163
  As `useForm`, `useFormGroup` serves the same purpose, but the difference is that it handles multiple forms and has limited callback functions to set:
1059
1164
 
1060
- | method | payload | description |
1061
- | ------- | ------------------------------- | ---------------------------------------------------------- |
1062
- | onData | TFormGroupOnDataEventPayload<T> | event occuring when a value is changing via input or logic |
1063
- | onValid | TFormGroupOnValidEventPayload | event occuring when validation status changes on the form |
1165
+ | method | payload | description |
1166
+ | -------- | --------------------------------- | ----------------------------------------------------------- |
1167
+ | onData | TFormGroupOnDataEventPayload<T> | event occurring when a value is changing via input or logic |
1168
+ | onValid | TFormGroupOnValidEventPayload | event occurring when validation status changes on the form |
1169
+ | onSubmit | TFormGroupOnSubmitEventPayload<T> | event occurring when form submission is trigger |
1064
1170
 
1065
1171
  <a id="asformfield"></a>
1066
1172
 
@@ -1115,8 +1221,116 @@ Ex:
1115
1221
 
1116
1222
  Other than schema component properties like `validations`, `api`, etc.., it has additional properties to define the component, the associated form id and the name
1117
1223
 
1118
- | method | type | description |
1119
- | --------- | ---------- | --------------------------------------------------- |
1120
- | mapper | TMapper<T> | mapper configuration to define the component |
1121
- | name | string | field name to be identified on the form |
1122
- | formIndex | string | index of the form to be identified on the formGroup |
1224
+ | method | type | description |
1225
+ | --------- | ---------- | ------------------------------------------------------------------------------------------------------------------------ |
1226
+ | mapper | TMapper<T> | mapper configuration to define the component |
1227
+ | name | string | field name to be identified on the form |
1228
+ | formIndex | string | index of the form to be identified on the formGroup |
1229
+ | component | string | if mappers is provided from the formgroup context, you can assign the mapper by it's name instead of whole mapper config |
1230
+
1231
+ <a id="asformfieldrepeater"></a>
1232
+
1233
+ ## **AsFormFieldRepeater**
1234
+
1235
+ Component adapter to aid managing multiple forms that shares the same inputs
1236
+
1237
+ Props:
1238
+
1239
+ | Attr | Type | Description |
1240
+ | ----------------- | --------------------------------------------------------- | -------------------------------------------------------------------------- |
1241
+ | RepeaterComponent | ElementType<{ formIndex: string }> | Component with form schema or AsFormFieldBuilder elements |
1242
+ | addFieldName | string | name of the button in the RepeaterComponent to add forms |
1243
+ | removeFieldName | string | name of the button in the RepeaterComponent to remove forms |
1244
+ | existingElements | Record<string, unknown>[] | existing values emmitted from stateUpdater to restore previous used values |
1245
+ | initialElements | number | elements to be pre-rendered when the form is presented |
1246
+ | stateUpdater | (payload: TFormGroupOnDataEventPayload<unknown>) => void; | callback function that reacts to RepeaterComponet values changes |
1247
+ | formPrefix | string | prefix for form names ex, prefix: foo, forms: ["foo1","foo2","foo3"] |
1248
+ | RepeaterFooter | ElementType<{ formIndex: string }> | Component with a button to add forms on the last position |
1249
+
1250
+ Common use case for this Adapter is to manage multiple forms that collects the same data ex: multiple person personal data
1251
+
1252
+ # Example
1253
+
1254
+ ## RepeaterComponent
1255
+
1256
+ ```javascript
1257
+ const FormElement = ({ formIndex }: { formIndex: string }) => {
1258
+ return (
1259
+ <>
1260
+ <AsFormFieldBuilder formIndex={formIndex} name="foo" component="input" props={{ label: 'foo' }} />
1261
+ <AsFormFieldBuilder formIndex={formIndex} name="bar" component="input" props={{ label: 'bar' }} />
1262
+ <AsFormFieldBuilder
1263
+ formIndex={formIndex}
1264
+ name="addForm"
1265
+ component="button"
1266
+ props={{
1267
+ text: 'add element',
1268
+ }}
1269
+ />
1270
+ <AsFormFieldBuilder
1271
+ formIndex={formIndex}
1272
+ name="removeForm"
1273
+ component="button"
1274
+ props={{
1275
+ text: 'remove element',
1276
+ }}
1277
+ />
1278
+ </>
1279
+ );
1280
+ };
1281
+ ```
1282
+
1283
+ Important notes when developing this component is that it needs to receive an object with a key **formIndex**
1284
+
1285
+ Optionally, but to add form management functionality, add two buttons with **ON_FIELD_CLICK** event capture (can't be of type submit)
1286
+ both that Field button names will be needed on the next step
1287
+
1288
+ ## RepeaterFooter
1289
+
1290
+ Optionally, you can develop a footer component with a button that will be added the bottom of the repeated forms
1291
+ and when you press that button will add a form at the bottom of the list
1292
+
1293
+ It's props needs to be an objet with a **formIndex** key, the button needs to have **ON_FIELD_CLICK** event capture (can't be of type submit)
1294
+ Note: the button name needs to be different from the names you gave to the buttons you are passing on the RepeaterComponent
1295
+
1296
+ ```javascript
1297
+ const FormElementFooter = ({ formIndex }: { formIndex: string }) => {
1298
+ return (
1299
+ <AsFormFieldBuilder
1300
+ formIndex={formIndex}
1301
+ name="addFormBelow"
1302
+ component="button"
1303
+ props={{
1304
+ text: 'add element below',
1305
+ }}
1306
+ />
1307
+ );
1308
+ };
1309
+ ```
1310
+
1311
+ ## AsFormFieldRepeater
1312
+
1313
+ Set the AsFormFieldRepeater adapter with the element you created above and the names that you gave to the button fields
1314
+
1315
+ ```javascript
1316
+ <AsFormFieldRepeater
1317
+ RepeaterComponent={FormElement}
1318
+ RepeaterFooter={FormElementFooter}
1319
+ addFieldName="addForm"
1320
+ removeFieldName="removeForm"
1321
+ formPrefix="insured"
1322
+ stateUpdater={(payload) => {
1323
+ console.log(payload);
1324
+ }}
1325
+ />
1326
+ ```
1327
+
1328
+ **RepeaterComponent** and **RepeaterFooter** you set the elements created above
1329
+
1330
+ **addFieldName** you set the name to the button that will add a form on the position it's being clicked
1331
+
1332
+ **removeFieldName** you set the name to the button that will remove a form on the position it's being clicked
1333
+
1334
+ **formPrefix** the prefix for the forms emmited on **stateUpdater** enumerated
1335
+
1336
+ **stateUpdater** callback function that will receive the form values (similar to onData)