@ilife-tech/react-application-flow-renderer 1.0.17 → 1.0.19
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 +176 -30
- package/dist/example.js +13 -13
- package/dist/example.js.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -314,8 +314,7 @@ function App() {
|
|
|
314
314
|
storeVenderData: result,
|
|
315
315
|
questionGroups,
|
|
316
316
|
pageRules: Array.isArray(rawPageRules) ? rawPageRules : [],
|
|
317
|
-
pageRuleGroup:
|
|
318
|
-
Array.isArray(rawPageRuleGroup) ? rawPageRuleGroup : [],
|
|
317
|
+
pageRuleGroup: Array.isArray(rawPageRuleGroup) ? rawPageRuleGroup : [],
|
|
319
318
|
validationSchema: validationErrors,
|
|
320
319
|
actionSchema: actionButtons,
|
|
321
320
|
sectionSchema: sectionList || [],
|
|
@@ -777,20 +776,20 @@ async function getStatesByCountry(apiUrl, country) {
|
|
|
777
776
|
|
|
778
777
|
The `DynamicForm` component accepts the following props:
|
|
779
778
|
|
|
780
|
-
| Prop | Type | Required | Default | Description
|
|
781
|
-
| ------------------ | ---------- | -------- | ------- |
|
|
782
|
-
| `questionGroups` | `Array` | Yes | `[]` | Array of question groups defining form structure
|
|
783
|
-
| `actionSchema` | `Array` | No | `[]` | Array of action buttons configuration
|
|
784
|
-
| `onSubmit` | `Function` | No | - | Form submission handler
|
|
785
|
-
| `onApiTrigger` | `Function` | No | - | API trigger event handler
|
|
786
|
-
| `apiConfig` | `Object` | No | `{}` | API configuration options
|
|
787
|
-
| `theme` | `Object` | No | `{}` | Theme customization
|
|
788
|
-
| `validationSchema` | `Array` | No | `[]` | Additional validation rules
|
|
789
|
-
| `pageRules` | `Array` | No | `[]` | Page rules for conditional logic
|
|
779
|
+
| Prop | Type | Required | Default | Description |
|
|
780
|
+
| ------------------ | ---------- | -------- | ------- | ------------------------------------------------- |
|
|
781
|
+
| `questionGroups` | `Array` | Yes | `[]` | Array of question groups defining form structure |
|
|
782
|
+
| `actionSchema` | `Array` | No | `[]` | Array of action buttons configuration |
|
|
783
|
+
| `onSubmit` | `Function` | No | - | Form submission handler |
|
|
784
|
+
| `onApiTrigger` | `Function` | No | - | API trigger event handler |
|
|
785
|
+
| `apiConfig` | `Object` | No | `{}` | API configuration options |
|
|
786
|
+
| `theme` | `Object` | No | `{}` | Theme customization |
|
|
787
|
+
| `validationSchema` | `Array` | No | `[]` | Additional validation rules |
|
|
788
|
+
| `pageRules` | `Array` | No | `[]` | Page rules for conditional logic |
|
|
790
789
|
| `pageRuleGroup` | `Array` | No | `[]` | Page rule groups with complex boolean expressions |
|
|
791
|
-
| `debug` | `Boolean` | No | `false` | Enable debug mode
|
|
792
|
-
| `formApiRef` | `Object` | No | - | Ref object to access form API methods
|
|
793
|
-
| `toastConfig` | `Object` | No | `{}` | Toast configuration
|
|
790
|
+
| `debug` | `Boolean` | No | `false` | Enable debug mode |
|
|
791
|
+
| `formApiRef` | `Object` | No | - | Ref object to access form API methods |
|
|
792
|
+
| `toastConfig` | `Object` | No | `{}` | Toast configuration |
|
|
794
793
|
|
|
795
794
|
### Props Details
|
|
796
795
|
|
|
@@ -908,6 +907,157 @@ The package supports a wide range of field types to handle various input require
|
|
|
908
907
|
| `button` | `ButtonField` | Action button field |
|
|
909
908
|
| `spinner` | `SpinnerField` | Loading indicator field |
|
|
910
909
|
|
|
910
|
+
## Input Masking and Security
|
|
911
|
+
|
|
912
|
+
The React Dynamic Form Renderer includes advanced **dual masking system** for sensitive data fields, providing both input formatting and security masking capabilities.
|
|
913
|
+
|
|
914
|
+
### Dual Masking System
|
|
915
|
+
|
|
916
|
+
The package implements a sophisticated dual masking approach:
|
|
917
|
+
|
|
918
|
+
1. **Input Masking**: Real-time formatting during user input (e.g., `123-45-6789`)
|
|
919
|
+
2. **Security Masking**: Hide sensitive characters for privacy (e.g., `***-**-6789`)
|
|
920
|
+
|
|
921
|
+
### Supported Field Types
|
|
922
|
+
|
|
923
|
+
The following field types support dual masking:
|
|
924
|
+
|
|
925
|
+
| Field Type | Input Formatting | Security Masking | Eye Icon Toggle |
|
|
926
|
+
| ------------- | ---------------- | ---------------- | --------------- |
|
|
927
|
+
| `ssn` | ✅ | ✅ | ✅ |
|
|
928
|
+
| `itin` | ✅ | ✅ | ✅ |
|
|
929
|
+
| `phonenumber` | ✅ | ✅ | ✅ |
|
|
930
|
+
| `phone` | ✅ | ✅ | ✅ |
|
|
931
|
+
| `currency` | ✅ | ❌ | ❌ |
|
|
932
|
+
| `number` | ✅ | ❌ | ❌ |
|
|
933
|
+
| `percentage` | ✅ | ❌ | ❌ |
|
|
934
|
+
|
|
935
|
+
### Configuration Options
|
|
936
|
+
|
|
937
|
+
#### Input Masking
|
|
938
|
+
|
|
939
|
+
```javascript
|
|
940
|
+
{
|
|
941
|
+
"questionId": "ssn_field",
|
|
942
|
+
"label": "Social Security Number",
|
|
943
|
+
"questionType": "ssn",
|
|
944
|
+
"maskInput": "###-##-####", // Input formatting pattern
|
|
945
|
+
"required": true
|
|
946
|
+
}
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
#### Security Masking
|
|
950
|
+
|
|
951
|
+
```javascript
|
|
952
|
+
{
|
|
953
|
+
"questionId": "ssn_field",
|
|
954
|
+
"label": "Social Security Number",
|
|
955
|
+
"questionType": "ssn",
|
|
956
|
+
"maskInput": "###-##-####", // Input formatting
|
|
957
|
+
"maskingType": "prefix", // "prefix" or "suffix"
|
|
958
|
+
"maskingLength": 6, // Number of characters to mask
|
|
959
|
+
"required": true
|
|
960
|
+
}
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
### Masking Patterns
|
|
964
|
+
|
|
965
|
+
#### Common Patterns
|
|
966
|
+
|
|
967
|
+
| Field Type | Pattern | Example Input | Formatted | Security Masked |
|
|
968
|
+
| ---------- | ---------------- | ------------- | -------------- | ------------------ |
|
|
969
|
+
| SSN | `###-##-####` | 123456789 | 123-45-6789 | **\*-**-6789 |
|
|
970
|
+
| Phone | `(###) ###-####` | 1234567890 | (123) 456-7890 | (123) 456-\*\*\*\* |
|
|
971
|
+
| ITIN | `###-##-####` | 912456789 | 912-45-6789 | **\*-**-6789 |
|
|
972
|
+
|
|
973
|
+
#### Custom Patterns
|
|
974
|
+
|
|
975
|
+
You can define custom masking patterns using:
|
|
976
|
+
|
|
977
|
+
- `#` for digits (0-9)
|
|
978
|
+
- `*` for any character
|
|
979
|
+
- Special characters (hyphens, parentheses, etc.) are preserved
|
|
980
|
+
|
|
981
|
+
### Eye Icon Toggle
|
|
982
|
+
|
|
983
|
+
Fields with security masking automatically display an eye icon (👁️/🙈) that allows users to toggle between:
|
|
984
|
+
|
|
985
|
+
- **Masked View**: Shows security masked value (e.g., `***-**-6789`)
|
|
986
|
+
- **Original View**: Shows formatted value (e.g., `123-45-6789`)
|
|
987
|
+
|
|
988
|
+
#### Accessibility Features
|
|
989
|
+
|
|
990
|
+
- **Keyboard Navigation**: Eye icon supports Tab navigation
|
|
991
|
+
- **Keyboard Activation**: Toggle with Enter or Space keys
|
|
992
|
+
- **Screen Reader Support**: Proper ARIA labels and descriptions
|
|
993
|
+
- **Focus Management**: Clear focus indicators
|
|
994
|
+
|
|
995
|
+
### Advanced Configuration
|
|
996
|
+
|
|
997
|
+
#### Prefix vs Suffix Masking
|
|
998
|
+
|
|
999
|
+
```javascript
|
|
1000
|
+
// Prefix masking (mask first N characters)
|
|
1001
|
+
{
|
|
1002
|
+
"maskingType": "prefix",
|
|
1003
|
+
"maskingLength": 6,
|
|
1004
|
+
// "123-45-6789" → "***-**-6789"
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Suffix masking (mask last N characters)
|
|
1008
|
+
{
|
|
1009
|
+
"maskingType": "suffix",
|
|
1010
|
+
"maskingLength": 4,
|
|
1011
|
+
// "123-45-6789" → "123-45-****"
|
|
1012
|
+
}
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
#### Validation with Masking
|
|
1016
|
+
|
|
1017
|
+
The masking system integrates seamlessly with validation:
|
|
1018
|
+
|
|
1019
|
+
```javascript
|
|
1020
|
+
{
|
|
1021
|
+
"questionId": "ssn_field",
|
|
1022
|
+
"maskInput": "###-##-####",
|
|
1023
|
+
"maskingType": "prefix",
|
|
1024
|
+
"maskingLength": 6,
|
|
1025
|
+
"minLength": 9, // Validates unmasked length
|
|
1026
|
+
"maxLength": 9, // Validates unmasked length
|
|
1027
|
+
"required": true,
|
|
1028
|
+
"validation": {
|
|
1029
|
+
"pattern": "^\\d{9}$", // Validates digits only
|
|
1030
|
+
"message": "Please enter a valid 9-digit SSN"
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
```
|
|
1034
|
+
|
|
1035
|
+
### Implementation Notes
|
|
1036
|
+
|
|
1037
|
+
- **Real-time Processing**: Masking is applied during user input, not just on blur
|
|
1038
|
+
- **Form Integration**: Masked values are properly integrated with form state
|
|
1039
|
+
- **Performance**: Optimized for large forms with multiple masked fields
|
|
1040
|
+
- **Browser Compatibility**: Works across all modern browsers
|
|
1041
|
+
- **Mobile Support**: Touch-friendly eye icon and responsive design
|
|
1042
|
+
|
|
1043
|
+
### Troubleshooting
|
|
1044
|
+
|
|
1045
|
+
#### Common Issues
|
|
1046
|
+
|
|
1047
|
+
1. **Masking Not Applied**: Ensure `maskInput` pattern is correctly formatted
|
|
1048
|
+
2. **Eye Icon Missing**: Verify both `maskingType` and `maskingLength` are set
|
|
1049
|
+
3. **Validation Errors**: Check that validation patterns match unmasked values
|
|
1050
|
+
4. **Performance Issues**: Avoid overly complex masking patterns in large forms
|
|
1051
|
+
|
|
1052
|
+
#### Debug Tips
|
|
1053
|
+
|
|
1054
|
+
```javascript
|
|
1055
|
+
// Enable console logging for masking operations
|
|
1056
|
+
console.log('Masked Value:', maskedValue);
|
|
1057
|
+
console.log('Display Value:', displayValue);
|
|
1058
|
+
console.log('Mask Config:', maskConfig);
|
|
1059
|
+
```
|
|
1060
|
+
|
|
911
1061
|
## Conditional Logic
|
|
912
1062
|
|
|
913
1063
|
The Dynamic Form Renderer provides powerful conditional logic capabilities through the `pageRules` and `pageRuleGroup` props.
|
|
@@ -919,12 +1069,12 @@ Page rules define individual conditions and actions for dynamic form behavior:
|
|
|
919
1069
|
```javascript
|
|
920
1070
|
const pageRules = [
|
|
921
1071
|
{
|
|
922
|
-
ruleId:
|
|
923
|
-
triggerQuestionIds: [
|
|
924
|
-
comparison:
|
|
925
|
-
compareValue:
|
|
926
|
-
action:
|
|
927
|
-
targetQuestionIds: [
|
|
1072
|
+
ruleId: 'rule1',
|
|
1073
|
+
triggerQuestionIds: ['101'],
|
|
1074
|
+
comparison: 'equals',
|
|
1075
|
+
compareValue: 'yes',
|
|
1076
|
+
action: 'showquestion',
|
|
1077
|
+
targetQuestionIds: ['201'],
|
|
928
1078
|
},
|
|
929
1079
|
// more rules...
|
|
930
1080
|
];
|
|
@@ -938,13 +1088,13 @@ The enhanced `pageRuleGroup` feature provides sophisticated boolean expressions
|
|
|
938
1088
|
// New array-based format with complex boolean expressions
|
|
939
1089
|
const pageRuleGroup = [
|
|
940
1090
|
{
|
|
941
|
-
questionId:
|
|
942
|
-
evaluationExpression:
|
|
1091
|
+
questionId: '40374',
|
|
1092
|
+
evaluationExpression: 'rule1 AND rule2',
|
|
943
1093
|
},
|
|
944
1094
|
{
|
|
945
|
-
questionId:
|
|
946
|
-
evaluationExpression:
|
|
947
|
-
}
|
|
1095
|
+
questionId: '40555',
|
|
1096
|
+
evaluationExpression: '(rule1 AND rule2) OR rule3',
|
|
1097
|
+
},
|
|
948
1098
|
];
|
|
949
1099
|
```
|
|
950
1100
|
|
|
@@ -1705,13 +1855,11 @@ const DynamicApiForm = ({ formId }) => {
|
|
|
1705
1855
|
### Security Best Practices
|
|
1706
1856
|
|
|
1707
1857
|
1. **API Key Management**:
|
|
1708
|
-
|
|
1709
1858
|
- Never hardcode API keys in your JavaScript code
|
|
1710
1859
|
- Use environment variables for all sensitive credentials
|
|
1711
1860
|
- Consider using token exchange services for third-party APIs
|
|
1712
1861
|
|
|
1713
1862
|
2. **Sensitive Data Handling**:
|
|
1714
|
-
|
|
1715
1863
|
- Use the built-in masking features for fields like SSN and credit card numbers
|
|
1716
1864
|
- Avoid storing sensitive data in localStorage or sessionStorage
|
|
1717
1865
|
- Clear sensitive form data after submission
|
|
@@ -1724,13 +1872,11 @@ const DynamicApiForm = ({ formId }) => {
|
|
|
1724
1872
|
### Accessibility Guidelines
|
|
1725
1873
|
|
|
1726
1874
|
1. **Screen Reader Support**:
|
|
1727
|
-
|
|
1728
1875
|
- All form fields include proper ARIA attributes
|
|
1729
1876
|
- Error messages are announced to screen readers
|
|
1730
1877
|
- Focus management follows a logical flow
|
|
1731
1878
|
|
|
1732
1879
|
2. **Keyboard Navigation**:
|
|
1733
|
-
|
|
1734
1880
|
- All interactive elements are focusable
|
|
1735
1881
|
- Tab order follows a logical sequence
|
|
1736
1882
|
- Custom components support keyboard interactions
|