@asaleh37/ui-base 25.9.5-1 → 25.9.5-3
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +3 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField.tsx +1 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +17 -16
package/package.json
CHANGED
|
@@ -50,7 +50,6 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
50
50
|
fullWidth
|
|
51
51
|
type={fieldType}
|
|
52
52
|
disabled={element.disabledFields.includes(fieldName)}
|
|
53
|
-
hidden={element.hiddenFields.includes(fieldName)}
|
|
54
53
|
label={getFieldLabel()}
|
|
55
54
|
value={formValues[fieldName]}
|
|
56
55
|
onChange={(event) => {
|
|
@@ -81,6 +80,9 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
81
80
|
height: "100% !important", // forces full height usage
|
|
82
81
|
},
|
|
83
82
|
...props?.formProps?.style,
|
|
83
|
+
display: element.hiddenFields.includes(fieldName)
|
|
84
|
+
? "none"
|
|
85
|
+
: undefined,
|
|
84
86
|
}}
|
|
85
87
|
error={formManager.formState.errors[fieldName] != undefined}
|
|
86
88
|
helperText={formManager?.formState?.errors[
|
|
@@ -8,6 +8,7 @@ const TemplateTextField: React.FC<Omit<TextFieldProps, "outlined">> = (
|
|
|
8
8
|
return (
|
|
9
9
|
<TextField
|
|
10
10
|
{...props}
|
|
11
|
+
hidden={true}
|
|
11
12
|
slotProps={{ inputLabel: { shrink: true, sx: { fontWeight: "bold" } } }}
|
|
12
13
|
label={<>{props?.label ? t(props.label) : ""}</>}
|
|
13
14
|
helperText={props?.helperText ? t(props.helperText) : undefined}
|
|
@@ -46,22 +46,9 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
46
46
|
useState<boolean>(true);
|
|
47
47
|
const { t } = useTranslation();
|
|
48
48
|
const fields = getAllFields(props.elements);
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
if (field?.hidden) {
|
|
53
|
-
initiallyHiddenFields.push(field.fieldName);
|
|
54
|
-
}
|
|
55
|
-
if (field?.disabled) {
|
|
56
|
-
initiallyDisabledFields.push(field.fieldName);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const [disabledFields, setDisabledFields] = useState<string[]>(
|
|
60
|
-
initiallyDisabledFields
|
|
61
|
-
);
|
|
62
|
-
const [hiddenFields, setHiddenFields] = useState<string[]>(
|
|
63
|
-
initiallyHiddenFields
|
|
64
|
-
);
|
|
49
|
+
|
|
50
|
+
const [disabledFields, setDisabledFields] = useState<string[]>([]);
|
|
51
|
+
const [hiddenFields, setHiddenFields] = useState<string[]>([]);
|
|
65
52
|
const initialValues: any = {};
|
|
66
53
|
for (const element of props.elements) {
|
|
67
54
|
if (
|
|
@@ -186,6 +173,20 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
186
173
|
},
|
|
187
174
|
};
|
|
188
175
|
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
const initiallyHiddenFields = [];
|
|
178
|
+
const initiallyDisabledFields = [];
|
|
179
|
+
for (const field of fields) {
|
|
180
|
+
if (field?.hidden) {
|
|
181
|
+
initiallyHiddenFields.push(field.fieldName);
|
|
182
|
+
}
|
|
183
|
+
if (field?.disabled) {
|
|
184
|
+
initiallyDisabledFields.push(field.fieldName);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
setHiddenFields(initiallyHiddenFields);
|
|
188
|
+
setDisabledFields(initiallyDisabledFields);
|
|
189
|
+
}, [props.elements]);
|
|
189
190
|
useEffect(() => {
|
|
190
191
|
loadRecord();
|
|
191
192
|
}, [props?.recordIdToEdit]);
|