@acvl/frontend-components 0.0.34 → 0.0.35
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/cjs/index.js +66 -37
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/v1/forms/utils.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/theme/compStyleOverride.d.ts +15 -12
- package/dist/esm/index.js +66 -37
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/v1/forms/utils.d.ts +1 -1
- package/dist/esm/types/src/components/v1/theme/compStyleOverride.d.ts +15 -12
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -14,5 +14,5 @@ export interface JSONFormProps {
|
|
|
14
14
|
useLabel?: boolean;
|
|
15
15
|
props?: JSONParserProps;
|
|
16
16
|
}
|
|
17
|
-
export declare const formParser: ({ type, submitData, data, useLabel, props
|
|
17
|
+
export declare const formParser: ({ type, submitData, data, useLabel, props }: JSONFormProps) => any;
|
|
18
18
|
export declare const setErrors: (form: any, error: any) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cambia el diseño default de ciertos componentes de Material UI
|
|
3
|
-
**/
|
|
3
|
+
**/
|
|
4
4
|
export default function componentStyleOverrides(theme: any): {
|
|
5
5
|
MuiAlert: {
|
|
6
6
|
defaultProps: {
|
|
@@ -10,12 +10,12 @@ export default function componentStyleOverrides(theme: any): {
|
|
|
10
10
|
MuiListItemButton: {
|
|
11
11
|
styleOverrides: {
|
|
12
12
|
root: {
|
|
13
|
-
|
|
13
|
+
"&:hover": {
|
|
14
14
|
backgroundColor: string;
|
|
15
|
-
|
|
15
|
+
"& .MuiTypography-root": {
|
|
16
16
|
color: string;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
"& .MuiSvgIcon-root": {
|
|
19
19
|
color: string;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
@@ -25,35 +25,38 @@ export default function componentStyleOverrides(theme: any): {
|
|
|
25
25
|
MuiDataGrid: {
|
|
26
26
|
styleOverrides: {
|
|
27
27
|
columnHeader: {
|
|
28
|
-
|
|
28
|
+
"& .MuiDataGrid-columnHeaderTitle": {
|
|
29
29
|
fontWeight: string;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
"&:focus": {
|
|
32
32
|
outline: string;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
row: {
|
|
36
|
+
"&.row-error": {
|
|
37
|
+
backgroundColor: "#ffcdd2";
|
|
38
|
+
};
|
|
36
39
|
"&.even": {
|
|
37
40
|
backgroundColor: "#fafafa";
|
|
38
41
|
};
|
|
39
|
-
|
|
42
|
+
"&:hover": {
|
|
40
43
|
backgroundColor: string;
|
|
41
|
-
|
|
44
|
+
"@media (hover: none)": {
|
|
42
45
|
backgroundColor: string;
|
|
43
46
|
};
|
|
44
47
|
};
|
|
45
48
|
};
|
|
46
49
|
cell: {
|
|
47
|
-
|
|
50
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
48
51
|
border: string;
|
|
49
52
|
};
|
|
50
|
-
|
|
53
|
+
"&.MuiDataGrid-cell--editing": {
|
|
51
54
|
backgroundColor: string;
|
|
52
|
-
|
|
55
|
+
"& .MuiInputBase-root": {
|
|
53
56
|
height: string;
|
|
54
57
|
};
|
|
55
58
|
};
|
|
56
|
-
|
|
59
|
+
"& .Mui-error": {
|
|
57
60
|
backgroundColor: string;
|
|
58
61
|
color: string;
|
|
59
62
|
fontWeight: string;
|
package/dist/esm/index.js
CHANGED
|
@@ -25757,7 +25757,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25757
25757
|
break;
|
|
25758
25758
|
}
|
|
25759
25759
|
};
|
|
25760
|
-
const formParser = ({ type, submitData, data, useLabel, props
|
|
25760
|
+
const formParser = ({ type, submitData, data, useLabel, props }) => {
|
|
25761
25761
|
const t = type || "json";
|
|
25762
25762
|
const response = t === "json" ? {} : new FormData();
|
|
25763
25763
|
Object.entries(submitData).forEach(([key, value]) => {
|
|
@@ -25778,9 +25778,27 @@ const formParser = ({ type, submitData, data, useLabel, props, }) => {
|
|
|
25778
25778
|
};
|
|
25779
25779
|
// ==============================|| ERRORS ||============================== //
|
|
25780
25780
|
const setErrors = (form, error) => {
|
|
25781
|
+
const iterateDeep = (obj) => {
|
|
25782
|
+
if (Array.isArray(obj.reason)) {
|
|
25783
|
+
if (obj.reason.every((item) => typeof item === "object" && item !== null && !Array.isArray(item))) {
|
|
25784
|
+
obj.reason.forEach((obj2, index) => {
|
|
25785
|
+
Object.entries(obj2).forEach(([key3, val3]) => {
|
|
25786
|
+
form.setError(`${obj.name}.${index}.${key3}`, { message: val3.join(", ") });
|
|
25787
|
+
});
|
|
25788
|
+
});
|
|
25789
|
+
}
|
|
25790
|
+
else {
|
|
25791
|
+
form.setError(obj.name, { message: obj.reason.join(", ") });
|
|
25792
|
+
}
|
|
25793
|
+
}
|
|
25794
|
+
else {
|
|
25795
|
+
form.setError(obj.name, { message: obj.reason });
|
|
25796
|
+
}
|
|
25797
|
+
};
|
|
25781
25798
|
if ("invalid_params" in error.data) {
|
|
25782
25799
|
Object.values(error.data.invalid_params).forEach((entry) => {
|
|
25783
|
-
|
|
25800
|
+
iterateDeep(entry);
|
|
25801
|
+
// form.setError(entry.name, { message: entry.reason.join(", ") });
|
|
25784
25802
|
});
|
|
25785
25803
|
}
|
|
25786
25804
|
};
|
|
@@ -28089,12 +28107,11 @@ const EditToolbar = (props) => {
|
|
|
28089
28107
|
const FieldArrayField = (props) => {
|
|
28090
28108
|
const detail = useMemo(() => props.pageType === "detail", [props.pageType]);
|
|
28091
28109
|
const { fields, append, remove, update } = useFieldArray({
|
|
28092
|
-
control: props.form
|
|
28110
|
+
control: props.form?.control,
|
|
28093
28111
|
name: props.name,
|
|
28094
28112
|
keyName: "_id",
|
|
28095
28113
|
});
|
|
28096
|
-
|
|
28097
|
-
// console.log(fields);
|
|
28114
|
+
const errors = props.form.formState.errors;
|
|
28098
28115
|
const getIndex = useCallback((id) => findIndex(fields, function (field) {
|
|
28099
28116
|
return field._id == id;
|
|
28100
28117
|
}), [fields]);
|
|
@@ -28150,9 +28167,18 @@ const FieldArrayField = (props) => {
|
|
|
28150
28167
|
},
|
|
28151
28168
|
},
|
|
28152
28169
|
getRowId: (row) => row._id,
|
|
28153
|
-
getRowClassName: (params) =>
|
|
28170
|
+
getRowClassName: (params) => {
|
|
28171
|
+
const hasError = !!(errors &&
|
|
28172
|
+
props.name in errors &&
|
|
28173
|
+
errors[props.name][getIndex(params.row._id)]);
|
|
28174
|
+
return hasError
|
|
28175
|
+
? "row-error"
|
|
28176
|
+
: params.indexRelativeToCurrentPage % 2 === 0
|
|
28177
|
+
? "even"
|
|
28178
|
+
: "odd";
|
|
28179
|
+
},
|
|
28154
28180
|
density: "compact",
|
|
28155
|
-
onRowClick: props.pageType
|
|
28181
|
+
onRowClick: props.pageType != "detail" ? handleRowClick : undefined,
|
|
28156
28182
|
}, props.dataGridProps);
|
|
28157
28183
|
return (jsxs(Fragment, { children: [jsx(MainDrawer, { open: drawer.open, drawerToggle: handleCancel, title: "Trailer", slots: {
|
|
28158
28184
|
button: (jsx(SaveCancelButton, { slotProps: {
|
|
@@ -28710,67 +28736,70 @@ function themeTypography() {
|
|
|
28710
28736
|
// ==============================|| PERSONALIZADO DE COMPONENTES DE MUI ||============================== //
|
|
28711
28737
|
/**
|
|
28712
28738
|
* Cambia el diseño default de ciertos componentes de Material UI
|
|
28713
|
-
**/
|
|
28739
|
+
**/
|
|
28714
28740
|
function componentStyleOverrides(theme) {
|
|
28715
28741
|
return {
|
|
28716
28742
|
MuiAlert: {
|
|
28717
28743
|
defaultProps: {
|
|
28718
|
-
variant:
|
|
28744
|
+
variant: "filled",
|
|
28719
28745
|
},
|
|
28720
28746
|
},
|
|
28721
28747
|
MuiListItemButton: {
|
|
28722
28748
|
styleOverrides: {
|
|
28723
28749
|
root: {
|
|
28724
|
-
|
|
28750
|
+
"&:hover": {
|
|
28725
28751
|
backgroundColor: `${theme.palette.primary.main} !important`,
|
|
28726
|
-
|
|
28727
|
-
color:
|
|
28752
|
+
"& .MuiTypography-root": {
|
|
28753
|
+
color: "white !important",
|
|
28728
28754
|
},
|
|
28729
|
-
|
|
28730
|
-
color:
|
|
28731
|
-
}
|
|
28732
|
-
}
|
|
28733
|
-
}
|
|
28734
|
-
}
|
|
28755
|
+
"& .MuiSvgIcon-root": {
|
|
28756
|
+
color: "white !important",
|
|
28757
|
+
},
|
|
28758
|
+
},
|
|
28759
|
+
},
|
|
28760
|
+
},
|
|
28735
28761
|
},
|
|
28736
28762
|
MuiDataGrid: {
|
|
28737
28763
|
styleOverrides: {
|
|
28738
28764
|
columnHeader: {
|
|
28739
|
-
|
|
28740
|
-
fontWeight:
|
|
28765
|
+
"& .MuiDataGrid-columnHeaderTitle": {
|
|
28766
|
+
fontWeight: "bold",
|
|
28741
28767
|
},
|
|
28742
|
-
|
|
28743
|
-
outline:
|
|
28768
|
+
"&:focus": {
|
|
28769
|
+
outline: "none",
|
|
28744
28770
|
},
|
|
28745
28771
|
},
|
|
28746
28772
|
row: {
|
|
28773
|
+
[`&.row-error`]: {
|
|
28774
|
+
backgroundColor: red[100],
|
|
28775
|
+
},
|
|
28747
28776
|
[`&.even`]: {
|
|
28748
28777
|
backgroundColor: grey[50],
|
|
28749
28778
|
},
|
|
28750
|
-
|
|
28779
|
+
"&:hover": {
|
|
28751
28780
|
backgroundColor: alpha$1(theme.palette.primary.main, 0.2),
|
|
28752
|
-
|
|
28753
|
-
backgroundColor:
|
|
28781
|
+
"@media (hover: none)": {
|
|
28782
|
+
backgroundColor: "transparent",
|
|
28754
28783
|
},
|
|
28755
|
-
}
|
|
28784
|
+
},
|
|
28756
28785
|
},
|
|
28757
28786
|
cell: {
|
|
28758
|
-
|
|
28759
|
-
border:
|
|
28787
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
28788
|
+
border: "none",
|
|
28760
28789
|
},
|
|
28761
|
-
|
|
28762
|
-
backgroundColor:
|
|
28763
|
-
|
|
28764
|
-
height:
|
|
28790
|
+
"&.MuiDataGrid-cell--editing": {
|
|
28791
|
+
backgroundColor: "rgb(217 243 190)",
|
|
28792
|
+
"& .MuiInputBase-root": {
|
|
28793
|
+
height: "100%",
|
|
28765
28794
|
},
|
|
28766
28795
|
},
|
|
28767
|
-
|
|
28768
|
-
backgroundColor:
|
|
28769
|
-
color:
|
|
28770
|
-
fontWeight:
|
|
28796
|
+
"& .Mui-error": {
|
|
28797
|
+
backgroundColor: "rgba(234,27,43,0.2)",
|
|
28798
|
+
color: "#ef1a2b",
|
|
28799
|
+
fontWeight: "bold",
|
|
28771
28800
|
},
|
|
28772
28801
|
},
|
|
28773
|
-
}
|
|
28802
|
+
},
|
|
28774
28803
|
},
|
|
28775
28804
|
};
|
|
28776
28805
|
}
|