@ilife-tech/react-application-flow-renderer 1.2.98 → 1.2.99
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 +66 -27
- package/dist/example.js +19 -19
- package/dist/example.js.LICENSE.txt +3 -3
- package/dist/example.js.map +1 -1
- package/dist/index.js +19 -19
- package/dist/index.js.LICENSE.txt +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# React Dynamic Form Renderer
|
|
2
2
|
|
|
3
|
-
A powerful and flexible React package for rendering dynamic forms with advanced validation,
|
|
3
|
+
A powerful and flexible React package for rendering dynamic forms with advanced validation,
|
|
4
|
+
conditional logic, and third-party API integration capabilities.
|
|
4
5
|
|
|
5
6
|
[](https://www.npmjs.com/package/@ilife-tech/react-application-flow-renderer)
|
|
6
7
|
[](https://github.com/ilife-technologies/react-dynamic-form-renderer/blob/main/LICENSE)
|
|
7
8
|
|
|
8
9
|
## Table of Contents
|
|
9
10
|
|
|
11
|
+
- [Folder structure](#folder-structure)
|
|
10
12
|
- [Features](#features)
|
|
11
13
|
- [Prerequisites](#prerequisites)
|
|
12
14
|
- [Installation](#installation)
|
|
@@ -20,6 +22,12 @@ A powerful and flexible React package for rendering dynamic forms with advanced
|
|
|
20
22
|
- [Troubleshooting](#troubleshooting)
|
|
21
23
|
- [Examples & Best Practices](#examples--best-practices)
|
|
22
24
|
|
|
25
|
+
## Folder structure
|
|
26
|
+
|
|
27
|
+
This package uses a **layer-only** structure (components, context, hooks, utils, theme, etc.). For
|
|
28
|
+
the full layout and where to place new modules, see
|
|
29
|
+
[docs/coding-standards/folder-structure.md](docs/coding-standards/folder-structure.md).
|
|
30
|
+
|
|
23
31
|
## Features
|
|
24
32
|
|
|
25
33
|
### Core Capabilities
|
|
@@ -104,7 +112,8 @@ const App = () => {
|
|
|
104
112
|
|
|
105
113
|
### Real-World Example
|
|
106
114
|
|
|
107
|
-
Below is a comprehensive real-world implementation showcasing advanced features like API
|
|
115
|
+
Below is a comprehensive real-world implementation showcasing advanced features like API
|
|
116
|
+
integration, state management, and theming:
|
|
108
117
|
|
|
109
118
|
```jsx
|
|
110
119
|
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
@@ -451,7 +460,8 @@ export default App;
|
|
|
451
460
|
|
|
452
461
|
## Form Schema Structure
|
|
453
462
|
|
|
454
|
-
The form structure is defined by a JSON schema that specifies question groups and their fields. Each
|
|
463
|
+
The form structure is defined by a JSON schema that specifies question groups and their fields. Each
|
|
464
|
+
form consists of one or more question groups, each containing multiple field definitions.
|
|
455
465
|
|
|
456
466
|
### Question Group Structure
|
|
457
467
|
|
|
@@ -503,11 +513,13 @@ The action schema defines form buttons and their behaviors:
|
|
|
503
513
|
|
|
504
514
|
## API Integration
|
|
505
515
|
|
|
506
|
-
The package provides robust third-party API integration capabilities, allowing forms to fetch data,
|
|
516
|
+
The package provides robust third-party API integration capabilities, allowing forms to fetch data,
|
|
517
|
+
populate options, and submit data to external services.
|
|
507
518
|
|
|
508
519
|
### Basic API Integration
|
|
509
520
|
|
|
510
|
-
API integration is handled through the `onApiTrigger` prop, which receives API trigger events from
|
|
521
|
+
API integration is handled through the `onApiTrigger` prop, which receives API trigger events from
|
|
522
|
+
form fields:
|
|
511
523
|
|
|
512
524
|
```jsx
|
|
513
525
|
import React from 'react';
|
|
@@ -570,7 +582,8 @@ export default MyForm;
|
|
|
570
582
|
|
|
571
583
|
### Implementing the API Handler
|
|
572
584
|
|
|
573
|
-
The API handler function processes API triggers and returns updates to the form. Here's a practical
|
|
585
|
+
The API handler function processes API triggers and returns updates to the form. Here's a practical
|
|
586
|
+
example based on the package's example implementation:
|
|
574
587
|
|
|
575
588
|
```javascript
|
|
576
589
|
// services/apiService.js
|
|
@@ -681,7 +694,8 @@ export const createApiResponse = (updates = {}) => {
|
|
|
681
694
|
|
|
682
695
|
### Advanced API Integration Example
|
|
683
696
|
|
|
684
|
-
Here's a more comprehensive example showing how to handle complex API integration with request
|
|
697
|
+
Here's a more comprehensive example showing how to handle complex API integration with request
|
|
698
|
+
queuing and response mapping:
|
|
685
699
|
|
|
686
700
|
```javascript
|
|
687
701
|
// services/api/handlers/dropdownApiHandler.js
|
|
@@ -796,7 +810,8 @@ The `DynamicForm` component accepts the following props:
|
|
|
796
810
|
|
|
797
811
|
#### `questionGroups`
|
|
798
812
|
|
|
799
|
-
An array of question group objects that defines the form structure. Each group contains questions
|
|
813
|
+
An array of question group objects that defines the form structure. Each group contains questions
|
|
814
|
+
(fields) to render.
|
|
800
815
|
|
|
801
816
|
```javascript
|
|
802
817
|
const questionGroups = [
|
|
@@ -823,7 +838,8 @@ const actionSchema = [
|
|
|
823
838
|
|
|
824
839
|
#### `onSubmit`
|
|
825
840
|
|
|
826
|
-
Callback function called when a form action is triggered. Receives the form state and action
|
|
841
|
+
Callback function called when a form action is triggered. Receives the form state and action
|
|
842
|
+
identifier.
|
|
827
843
|
|
|
828
844
|
```javascript
|
|
829
845
|
const handleSubmit = (formState, action) => {
|
|
@@ -910,7 +926,8 @@ The package supports a wide range of field types to handle various input require
|
|
|
910
926
|
|
|
911
927
|
## Input Masking and Security
|
|
912
928
|
|
|
913
|
-
The React Dynamic Form Renderer includes advanced **dual masking system** for sensitive data fields,
|
|
929
|
+
The React Dynamic Form Renderer includes advanced **dual masking system** for sensitive data fields,
|
|
930
|
+
providing both input formatting and security masking capabilities.
|
|
914
931
|
|
|
915
932
|
### Dual Masking System
|
|
916
933
|
|
|
@@ -981,7 +998,8 @@ You can define custom masking patterns using:
|
|
|
981
998
|
|
|
982
999
|
### Eye Icon Toggle
|
|
983
1000
|
|
|
984
|
-
Fields with security masking automatically display an eye icon (👁️/🙈) that allows users to toggle
|
|
1001
|
+
Fields with security masking automatically display an eye icon (👁️/🙈) that allows users to toggle
|
|
1002
|
+
between:
|
|
985
1003
|
|
|
986
1004
|
- **Masked View**: Shows security masked value (e.g., `***-**-6789`)
|
|
987
1005
|
- **Original View**: Shows formatted value (e.g., `123-45-6789`)
|
|
@@ -1061,7 +1079,8 @@ console.log('Mask Config:', maskConfig);
|
|
|
1061
1079
|
|
|
1062
1080
|
## Conditional Logic
|
|
1063
1081
|
|
|
1064
|
-
The Dynamic Form Renderer provides powerful conditional logic capabilities through the `pageRules`
|
|
1082
|
+
The Dynamic Form Renderer provides powerful conditional logic capabilities through the `pageRules`
|
|
1083
|
+
and `pageRuleGroup` props.
|
|
1065
1084
|
|
|
1066
1085
|
### PageRules
|
|
1067
1086
|
|
|
@@ -1083,7 +1102,8 @@ const pageRules = [
|
|
|
1083
1102
|
|
|
1084
1103
|
### Enhanced PageRuleGroup
|
|
1085
1104
|
|
|
1086
|
-
The enhanced `pageRuleGroup` feature provides sophisticated boolean expressions for complex
|
|
1105
|
+
The enhanced `pageRuleGroup` feature provides sophisticated boolean expressions for complex
|
|
1106
|
+
conditional logic:
|
|
1087
1107
|
|
|
1088
1108
|
```javascript
|
|
1089
1109
|
// New array-based format with complex boolean expressions
|
|
@@ -1127,7 +1147,9 @@ const pageRuleGroup = [
|
|
|
1127
1147
|
}
|
|
1128
1148
|
```
|
|
1129
1149
|
|
|
1130
|
-
For detailed documentation on the enhanced pageRuleGroup feature, see the
|
|
1150
|
+
For detailed documentation on the enhanced pageRuleGroup feature, see the
|
|
1151
|
+
[page-rule-group-enhancement.md](docs/page-rule-group-implementation/page-rule-group-enhancement.md)
|
|
1152
|
+
file.
|
|
1131
1153
|
|
|
1132
1154
|
## Advanced Configuration
|
|
1133
1155
|
|
|
@@ -1161,15 +1183,18 @@ import DynamicFormInner from '@ilife-tech/react-application-flow-renderer/src/co
|
|
|
1161
1183
|
</FormProvider>;
|
|
1162
1184
|
```
|
|
1163
1185
|
|
|
1164
|
-
Note: The top-level `DynamicForm` abstraction may not expose these knobs directly. Use
|
|
1186
|
+
Note: The top-level `DynamicForm` abstraction may not expose these knobs directly. Use
|
|
1187
|
+
`FormProvider` for fine-grained control.
|
|
1165
1188
|
|
|
1166
1189
|
### Toast Notifications
|
|
1167
1190
|
|
|
1168
|
-
The Dynamic Form Renderer uses react-toastify for displaying notifications such as error messages,
|
|
1191
|
+
The Dynamic Form Renderer uses react-toastify for displaying notifications such as error messages,
|
|
1192
|
+
warnings, and success confirmations.
|
|
1169
1193
|
|
|
1170
1194
|
#### Toast Configuration
|
|
1171
1195
|
|
|
1172
|
-
The form renderer integrates with your application's react-toastify setup. **Important: Your host
|
|
1196
|
+
The form renderer integrates with your application's react-toastify setup. **Important: Your host
|
|
1197
|
+
application MUST include a `<ToastContainer />` component** for notifications to appear.
|
|
1173
1198
|
|
|
1174
1199
|
```jsx
|
|
1175
1200
|
// Required: Import react-toastify in your host application
|
|
@@ -1198,7 +1223,8 @@ const App = () => {
|
|
|
1198
1223
|
|
|
1199
1224
|
#### API Response Format for Toast Notifications
|
|
1200
1225
|
|
|
1201
|
-
When implementing the `onApiTrigger` handler, you can return success and error messages that will be
|
|
1226
|
+
When implementing the `onApiTrigger` handler, you can return success and error messages that will be
|
|
1227
|
+
displayed as toast notifications:
|
|
1202
1228
|
|
|
1203
1229
|
```javascript
|
|
1204
1230
|
// Example of API trigger handler with toast notifications
|
|
@@ -1236,11 +1262,13 @@ If your application already uses react-toastify, the renderer will:
|
|
|
1236
1262
|
1. Use your application's react-toastify instance
|
|
1237
1263
|
2. Respect your toast styling and configuration
|
|
1238
1264
|
|
|
1239
|
-
**Important:** Only one `<ToastContainer />` should be rendered in your application tree. The
|
|
1265
|
+
**Important:** Only one `<ToastContainer />` should be rendered in your application tree. The
|
|
1266
|
+
package will not render its own ToastContainer - this must be provided by the host application.
|
|
1240
1267
|
|
|
1241
1268
|
### Toast Configuration
|
|
1242
1269
|
|
|
1243
|
-
The Dynamic Form Renderer uses react-toastify for displaying notifications. You can configure toast
|
|
1270
|
+
The Dynamic Form Renderer uses react-toastify for displaying notifications. You can configure toast
|
|
1271
|
+
behavior using the `toastConfig` prop:
|
|
1244
1272
|
|
|
1245
1273
|
```jsx
|
|
1246
1274
|
<DynamicForm
|
|
@@ -1278,7 +1306,8 @@ To properly display toast notifications:
|
|
|
1278
1306
|
|
|
1279
1307
|
#### API Response Format for Toast Messages
|
|
1280
1308
|
|
|
1281
|
-
When implementing custom API triggers with `onApiTrigger`, your handler should return a promise that
|
|
1309
|
+
When implementing custom API triggers with `onApiTrigger`, your handler should return a promise that
|
|
1310
|
+
resolves to an object with the following structure to properly display toast notifications:
|
|
1282
1311
|
|
|
1283
1312
|
```javascript
|
|
1284
1313
|
const handleApiTrigger = async (triggerData) => {
|
|
@@ -1318,8 +1347,10 @@ const handleApiTrigger = async (triggerData) => {
|
|
|
1318
1347
|
|
|
1319
1348
|
#### Troubleshooting
|
|
1320
1349
|
|
|
1321
|
-
- **No toasts appear**: Ensure your application has a `<ToastContainer />` component and has
|
|
1322
|
-
|
|
1350
|
+
- **No toasts appear**: Ensure your application has a `<ToastContainer />` component and has
|
|
1351
|
+
imported the CSS
|
|
1352
|
+
- **\_useSyncExternalStore error**: This usually indicates a version compatibility issue between
|
|
1353
|
+
React and react-toastify. For React 17, use react-toastify v9.1.x
|
|
1323
1354
|
- **Multiple toasts appear**: Ensure you only have one `<ToastContainer />` in your application
|
|
1324
1355
|
|
|
1325
1356
|
### Theme Customization
|
|
@@ -1502,7 +1533,8 @@ const validationSchema = [
|
|
|
1502
1533
|
|
|
1503
1534
|
### CardList Configuration
|
|
1504
1535
|
|
|
1505
|
-
The `CardListField` component enables dynamic form arrays with complete validation and state
|
|
1536
|
+
The `CardListField` component enables dynamic form arrays with complete validation and state
|
|
1537
|
+
management:
|
|
1506
1538
|
|
|
1507
1539
|
```javascript
|
|
1508
1540
|
const cardListQuestion = {
|
|
@@ -1921,8 +1953,15 @@ const DynamicApiForm = ({ formId }) => {
|
|
|
1921
1953
|
|
|
1922
1954
|
## Conclusion
|
|
1923
1955
|
|
|
1924
|
-
The React Dynamic Form Renderer package provides a comprehensive solution for creating dynamic,
|
|
1956
|
+
The React Dynamic Form Renderer package provides a comprehensive solution for creating dynamic,
|
|
1957
|
+
interactive forms with advanced validation, conditional logic, and third-party API integration. By
|
|
1958
|
+
leveraging the JSON schema approach, you can rapidly develop complex forms without sacrificing
|
|
1959
|
+
flexibility or control.
|
|
1925
1960
|
|
|
1926
|
-
For more detailed documentation, refer to the [developer user guide](./docs/developer-user-guide.md)
|
|
1961
|
+
For more detailed documentation, refer to the [developer user guide](./docs/developer-user-guide.md)
|
|
1962
|
+
or check out the [example implementations](./example) included with the package. Contributors: see
|
|
1963
|
+
[contributing](./docs/contributing.md), [running](./docs/running.md), and
|
|
1964
|
+
[folder structure](./docs/coding-standards/folder-structure.md) for setup and development workflow.
|
|
1927
1965
|
|
|
1928
|
-
We welcome contributions and feedback! Please file issues or submit pull requests on our
|
|
1966
|
+
We welcome contributions and feedback! Please file issues or submit pull requests on our
|
|
1967
|
+
[GitHub repository](https://github.com/ilife-technologies/react-dynamic-form-renderer).
|