tee3apps-cms-sdk-react 0.0.12 → 0.0.13
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/PageFormComponents/PageForm.tsx +15 -3
package/package.json
CHANGED
|
@@ -43,6 +43,15 @@ const PageForm: React.FC<PageFormProps> = ({ jsonData, onSubmit, isUrl = false,
|
|
|
43
43
|
return component.props.name?.all || component.name;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
// Function to normalize field name: convert to lowercase and replace spaces/special characters with underscores
|
|
47
|
+
const normalizeFieldName = (name: string): string => {
|
|
48
|
+
return name
|
|
49
|
+
.toLowerCase()
|
|
50
|
+
.trim()
|
|
51
|
+
.replace(/[^a-z0-9]+/g, '_') // Replace any sequence of non-alphanumeric characters with single underscore
|
|
52
|
+
.replace(/^_+|_+$/g, ''); // Remove leading/trailing underscores
|
|
53
|
+
};
|
|
54
|
+
|
|
46
55
|
// Function to create a mapping of field codes to field names
|
|
47
56
|
const getFieldCodeToNameMap = useCallback(() => {
|
|
48
57
|
const codeToNameMap: Record<string, string> = {};
|
|
@@ -93,10 +102,13 @@ const PageForm: React.FC<PageFormProps> = ({ jsonData, onSubmit, isUrl = false,
|
|
|
93
102
|
Object.keys(formValues).forEach((code) => {
|
|
94
103
|
const fieldName = codeToNameMap[code];
|
|
95
104
|
if (fieldName) {
|
|
96
|
-
|
|
105
|
+
// Normalize field name: convert to lowercase and replace spaces/special characters with underscores
|
|
106
|
+
const normalizedName = normalizeFieldName(fieldName);
|
|
107
|
+
transformedData[normalizedName] = formValues[code];
|
|
97
108
|
} else {
|
|
98
|
-
// If no mapping found,
|
|
99
|
-
|
|
109
|
+
// If no mapping found, normalize the code as well
|
|
110
|
+
const normalizedCode = normalizeFieldName(code);
|
|
111
|
+
transformedData[normalizedCode] = formValues[code];
|
|
100
112
|
}
|
|
101
113
|
});
|
|
102
114
|
|