@acvl/frontend-components 0.0.31 → 0.0.33
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 +136 -142
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/v1/buttons/MoreOptions/index.d.ts +10 -0
- package/dist/cjs/types/src/components/v1/buttons/index.d.ts +7 -6
- package/dist/cjs/types/src/components/v1/forms/utils.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/inputs/controlled/ControlledFileField/index.d.ts +15 -0
- package/dist/cjs/types/src/components/v1/inputs/controlled/index.d.ts +13 -13
- package/dist/cjs/types/src/components/v1/layout/pages/DetailPage/index.d.ts +3 -1
- package/dist/esm/index.js +142 -148
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/v1/buttons/MoreOptions/index.d.ts +10 -0
- package/dist/esm/types/src/components/v1/buttons/index.d.ts +7 -6
- package/dist/esm/types/src/components/v1/forms/utils.d.ts +2 -2
- package/dist/esm/types/src/components/v1/inputs/controlled/ControlledFileField/index.d.ts +15 -0
- package/dist/esm/types/src/components/v1/inputs/controlled/index.d.ts +13 -13
- package/dist/esm/types/src/components/v1/layout/pages/DetailPage/index.d.ts +3 -1
- package/dist/index.d.ts +24 -5
- package/package.json +1 -1
- package/dist/cjs/types/src/components/v1/inputs/controlled/ControlledPhotoField/index.d.ts +0 -6
- package/dist/esm/types/src/components/v1/inputs/controlled/ControlledPhotoField/index.d.ts +0 -6
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { useTheme, useMediaQuery, Tooltip, IconButton, Button, Grid, FormGroup, FormHelperText as FormHelperText$1, Drawer, Box, Stack, CircularProgress, Typography as Typography$1, List as List$1, ListItem as ListItem$1, ListSubheader, styled as styled$1, LinearProgress, Autocomplete, Checkbox, Slider, Switch, InputAdornment as InputAdornment$1, ToggleButtonGroup, ToggleButton, Dialog, DialogTitle, DialogContent as DialogContent$1, DialogContentText, DialogActions as DialogActions$1, ButtonGroup, Menu, ListItemIcon, Link, Card, CardHeader, Avatar, CardContent, Divider as Divider$1, Popper, Grow as Grow$1, Paper, ClickAwayListener, Badge, TablePagination, NoSsr, tooltipClasses, Collapse, Fade as Fade$1, Slide, Zoom, Snackbar, alpha as alpha$1, lighten, createTheme as createTheme$1, responsiveFontSizes } from '@mui/material';
|
|
3
|
+
import { useTheme, useMediaQuery, Tooltip, IconButton, Button, Grid, FormGroup, FormHelperText as FormHelperText$1, Drawer, Box, Stack, CircularProgress, Typography as Typography$1, List as List$1, ListItem as ListItem$1, ListSubheader, styled as styled$1, LinearProgress, Autocomplete, Checkbox, Slider, Switch, InputAdornment as InputAdornment$1, ToggleButtonGroup, ToggleButton, Dialog, DialogTitle, DialogContent as DialogContent$1, DialogContentText, DialogActions as DialogActions$1, ButtonGroup, Menu, ListItemIcon, MenuItem as MenuItem$1, Link, Card, CardHeader, Avatar, CardContent, Divider as Divider$1, Popper, Grow as Grow$1, Paper, ClickAwayListener, Badge, TablePagination, NoSsr, tooltipClasses, Collapse, Fade as Fade$1, Slide, Zoom, Snackbar, alpha as alpha$1, lighten, createTheme as createTheme$1, responsiveFontSizes } from '@mui/material';
|
|
4
4
|
import EditIcon from '@mui/icons-material/Edit';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { useCallback, useEffect, isValidElement, cloneElement, Children, createContext, useContext, useState, useMemo, useRef, useImperativeHandle, useLayoutEffect, Suspense, forwardRef } from 'react';
|
|
@@ -41,15 +41,12 @@ import BaseFocusTrap from '@mui/material/Unstable_TrapFocus';
|
|
|
41
41
|
import DialogContent from '@mui/material/DialogContent';
|
|
42
42
|
import MuiDialog, { dialogClasses } from '@mui/material/Dialog';
|
|
43
43
|
import debounce from 'lodash/debounce';
|
|
44
|
-
import { get,
|
|
44
|
+
import { get, map, find, groupBy, forEach, findIndex, mergeWith, isArray, omit, set as set$1, every, includes, merge as merge$2, countBy, isNumber, isEmpty as isEmpty$1, isBoolean, isEqual as isEqual$1, debounce as debounce$1, some } from 'lodash';
|
|
45
45
|
import { produce } from 'immer';
|
|
46
46
|
import set from 'lodash/set';
|
|
47
47
|
import get$1 from 'lodash/get';
|
|
48
48
|
import isEmpty from 'lodash/isEmpty';
|
|
49
|
-
import isNull from 'lodash/isNull';
|
|
50
49
|
import isEqual from 'lodash/isEqual';
|
|
51
|
-
import forEach from 'lodash/forEach';
|
|
52
|
-
import includes from 'lodash/includes';
|
|
53
50
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
54
51
|
import HistoryIcon from '@mui/icons-material/History';
|
|
55
52
|
import { Timeline, TimelineItem, TimelineSeparator, TimelineDot, TimelineConnector, TimelineContent, timelineItemClasses } from '@mui/lab';
|
|
@@ -69,20 +66,21 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
|
|
69
66
|
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
|
70
67
|
import { Visibility, VisibilityOff } from '@mui/icons-material';
|
|
71
68
|
import merge$1 from 'lodash/merge';
|
|
69
|
+
import UploadFileIcon from '@mui/icons-material/UploadFile';
|
|
70
|
+
import ClearIcon$1 from '@mui/icons-material/Clear';
|
|
72
71
|
import SaveIcon from '@mui/icons-material/Save';
|
|
73
72
|
import AddIcon from '@mui/icons-material/Add';
|
|
74
73
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
|
75
74
|
import LinearProgress$1 from '@mui/material/LinearProgress';
|
|
76
75
|
import AttachFileIcon from '@mui/icons-material/AttachFile';
|
|
76
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
77
77
|
import { useGridApiContext, ToolbarButton, QuickFilter, QuickFilterTrigger, QuickFilterControl, QuickFilterClear, ColumnsPanelTrigger, Toolbar, useGridSelector, gridPaginationSelector, GridRow, GridRowEditStartReasons, GridRowModes, GridActionsCellItem, useGridApiRef, DataGrid, GridRowEditStopReasons, GridEditSingleSelectCell, GridEditInputCell, GridEditBooleanCell, GridActionsCell } from '@mui/x-data-grid';
|
|
78
78
|
import Tooltip$1 from '@mui/material/Tooltip';
|
|
79
79
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
80
80
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
81
81
|
import Menu$1 from '@mui/material/Menu';
|
|
82
|
-
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
83
82
|
import SearchIcon from '@mui/icons-material/Search';
|
|
84
83
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
85
|
-
import ClearIcon$1 from '@mui/icons-material/Clear';
|
|
86
84
|
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
|
87
85
|
import FilterNoneIcon from '@mui/icons-material/FilterNone';
|
|
88
86
|
import CheckIcon from '@mui/icons-material/Check';
|
|
@@ -25648,68 +25646,65 @@ dayjs.locale(es);
|
|
|
25648
25646
|
dayjs.extend(duration);
|
|
25649
25647
|
|
|
25650
25648
|
// ==============================|| JSON ||============================== //
|
|
25649
|
+
const setValue = (formType, form, key, value) => {
|
|
25650
|
+
if (formType === "json")
|
|
25651
|
+
set(form, key, value);
|
|
25652
|
+
else
|
|
25653
|
+
form.append(key, value);
|
|
25654
|
+
};
|
|
25651
25655
|
const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, data, props, formType, }) => {
|
|
25652
25656
|
const ignore = get$1(props, `${base_key}.ignore`, false);
|
|
25653
25657
|
if (ignore || ["obj_permissions", "has_history"].includes(base_key))
|
|
25654
25658
|
return;
|
|
25655
|
-
const altered_key =
|
|
25659
|
+
const altered_key = props?.[base_key]?.alter_key?.(base_key);
|
|
25656
25660
|
const key = altered_key || base_key;
|
|
25657
|
-
const altered_obj =
|
|
25661
|
+
const altered_obj = props?.[base_key]?.alter_value?.(base_object, submitData);
|
|
25658
25662
|
const object = altered_obj || base_object;
|
|
25659
|
-
const setValue = (form, key, value) => {
|
|
25660
|
-
if (formType === "json") {
|
|
25661
|
-
set(form, key, value);
|
|
25662
|
-
}
|
|
25663
|
-
else if (formType === "formData") {
|
|
25664
|
-
form.append(key, value);
|
|
25665
|
-
}
|
|
25666
|
-
};
|
|
25667
25663
|
switch (typeof object) {
|
|
25668
25664
|
case "string":
|
|
25669
|
-
if (
|
|
25665
|
+
if (props?.[base_key]?.extra_validation?.(object))
|
|
25670
25666
|
return;
|
|
25671
|
-
setValue(response, key, isEmpty(object) ? "" : object);
|
|
25667
|
+
setValue(formType, response, key, isEmpty(object) ? "" : object);
|
|
25672
25668
|
break;
|
|
25673
25669
|
case "number":
|
|
25674
|
-
setValue(response, key, object);
|
|
25670
|
+
setValue(formType, response, key, object);
|
|
25675
25671
|
break;
|
|
25676
25672
|
case "boolean":
|
|
25677
|
-
setValue(response, key, object);
|
|
25673
|
+
setValue(formType, response, key, object);
|
|
25678
25674
|
break;
|
|
25679
25675
|
case "object":
|
|
25680
|
-
if (
|
|
25681
|
-
if (includes(
|
|
25682
|
-
setValue(response, key, "");
|
|
25676
|
+
if (object === null || isEmpty(object)) {
|
|
25677
|
+
if (key.includes("after") || key.includes("before"))
|
|
25678
|
+
setValue(formType, response, key, "");
|
|
25683
25679
|
else
|
|
25684
|
-
setValue(response, key, object);
|
|
25680
|
+
setValue(formType, response, key, object);
|
|
25685
25681
|
}
|
|
25686
25682
|
else if (object instanceof File) {
|
|
25687
|
-
setValue(response, key, object);
|
|
25683
|
+
setValue(formType, response, key, object);
|
|
25688
25684
|
}
|
|
25689
25685
|
else if (dayjs.isDayjs(object)) {
|
|
25690
|
-
setValue(response, key, object.format(get$1(props, `${key}.format`, "YYYY-MM-DD")));
|
|
25686
|
+
setValue(formType, response, key, object.format(get$1(props, `${key}.format`, "YYYY-MM-DD")));
|
|
25691
25687
|
}
|
|
25692
25688
|
else if ("label" in object && "value" in object) {
|
|
25693
25689
|
if (useLabel)
|
|
25694
|
-
setValue(response, key, object["label"]);
|
|
25690
|
+
setValue(formType, response, key, object["label"]);
|
|
25695
25691
|
else
|
|
25696
|
-
setValue(response, key, object["value"]);
|
|
25692
|
+
setValue(formType, response, key, object["value"]);
|
|
25697
25693
|
}
|
|
25698
25694
|
else if (Array.isArray(object)) {
|
|
25699
|
-
// it is an array
|
|
25700
25695
|
if (object.length &&
|
|
25701
|
-
typeof object[0]
|
|
25696
|
+
typeof object[0] === "object" &&
|
|
25702
25697
|
!Array.isArray(object[0]) &&
|
|
25703
25698
|
"value" in object[0] &&
|
|
25704
|
-
object[0]["value"]
|
|
25699
|
+
object[0]["value"] === "all") {
|
|
25705
25700
|
// for data grid filters
|
|
25706
|
-
setValue(response, key, "");
|
|
25701
|
+
setValue(formType, response, key, "");
|
|
25707
25702
|
}
|
|
25708
25703
|
else {
|
|
25709
|
-
forEach(
|
|
25710
|
-
if (typeof arrayItem
|
|
25704
|
+
object.forEach((arrayItem, idx) => {
|
|
25705
|
+
if (typeof arrayItem === "object") {
|
|
25711
25706
|
if ("label" in arrayItem) {
|
|
25712
|
-
setValue(response, `${key}.${idx}`, function (item) {
|
|
25707
|
+
setValue(formType, response, `${key}.${idx}`, function (item) {
|
|
25713
25708
|
if (useLabel)
|
|
25714
25709
|
return item.label;
|
|
25715
25710
|
else
|
|
@@ -25718,7 +25713,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25718
25713
|
}
|
|
25719
25714
|
typeSwitch({
|
|
25720
25715
|
base_object: arrayItem,
|
|
25721
|
-
base_key: `${key}.${idx}`,
|
|
25716
|
+
base_key: formType === "json" ? `${key}.${idx}` : `${key}[${idx}]`,
|
|
25722
25717
|
response: response,
|
|
25723
25718
|
useLabel: useLabel,
|
|
25724
25719
|
data: data,
|
|
@@ -25732,21 +25727,21 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25732
25727
|
if (keyArray)
|
|
25733
25728
|
keyArray.push(arrayItem);
|
|
25734
25729
|
else
|
|
25735
|
-
setValue(response, key, [arrayItem]);
|
|
25730
|
+
setValue(formType, response, key, [arrayItem]);
|
|
25736
25731
|
}
|
|
25737
25732
|
});
|
|
25738
25733
|
}
|
|
25739
25734
|
}
|
|
25740
25735
|
else if (object instanceof Set) {
|
|
25741
|
-
setValue(response, key, Array.from(object));
|
|
25736
|
+
setValue(formType, response, key, Array.from(object));
|
|
25742
25737
|
}
|
|
25743
25738
|
else {
|
|
25744
|
-
forEach(
|
|
25739
|
+
Object.entries(object).forEach(([key2, value]) => {
|
|
25745
25740
|
if (key2 !== "id" && isEqual(get$1(data, `${key}.${key2}`), value))
|
|
25746
25741
|
return;
|
|
25747
25742
|
typeSwitch({
|
|
25748
25743
|
base_object: value,
|
|
25749
|
-
base_key: `${key}.${key2}`,
|
|
25744
|
+
base_key: formType === "json" ? `${key}.${key2}` : `${key}${key2}`,
|
|
25750
25745
|
response: response,
|
|
25751
25746
|
useLabel: useLabel,
|
|
25752
25747
|
data: data,
|
|
@@ -25758,14 +25753,15 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25758
25753
|
}
|
|
25759
25754
|
break;
|
|
25760
25755
|
default:
|
|
25761
|
-
setValue(response, key, object);
|
|
25756
|
+
setValue(formType, response, key, object);
|
|
25762
25757
|
break;
|
|
25763
25758
|
}
|
|
25764
25759
|
};
|
|
25765
|
-
const
|
|
25766
|
-
const
|
|
25767
|
-
|
|
25768
|
-
|
|
25760
|
+
const formParser = ({ type, submitData, data, useLabel, props }) => {
|
|
25761
|
+
const t = type || "json";
|
|
25762
|
+
const response = t === "json" ? {} : new FormData();
|
|
25763
|
+
Object.entries(submitData).forEach(([key, value]) => {
|
|
25764
|
+
if (key !== "id" && isEqual(get$1(data, key), value))
|
|
25769
25765
|
return;
|
|
25770
25766
|
typeSwitch({
|
|
25771
25767
|
base_object: value,
|
|
@@ -25775,29 +25771,11 @@ const jsonForm = ({ submitData, data, useLabel, props }) => {
|
|
|
25775
25771
|
data: data,
|
|
25776
25772
|
props: props,
|
|
25777
25773
|
submitData: submitData,
|
|
25778
|
-
formType:
|
|
25774
|
+
formType: t,
|
|
25779
25775
|
});
|
|
25780
25776
|
});
|
|
25781
25777
|
return response;
|
|
25782
25778
|
};
|
|
25783
|
-
const formDataForm = ({ submitData, data, useLabel, props }) => {
|
|
25784
|
-
const formData = new FormData();
|
|
25785
|
-
forEach(submitData, function (value, key) {
|
|
25786
|
-
if (key != "id" && isEqual(get$1(data, key), value))
|
|
25787
|
-
return;
|
|
25788
|
-
typeSwitch({
|
|
25789
|
-
base_object: value,
|
|
25790
|
-
base_key: key,
|
|
25791
|
-
response: formData,
|
|
25792
|
-
useLabel: useLabel,
|
|
25793
|
-
data: data,
|
|
25794
|
-
props: props,
|
|
25795
|
-
submitData: submitData,
|
|
25796
|
-
formType: "formData",
|
|
25797
|
-
});
|
|
25798
|
-
});
|
|
25799
|
-
return formData;
|
|
25800
|
-
};
|
|
25801
25779
|
// ==============================|| ERRORS ||============================== //
|
|
25802
25780
|
const setErrors = (form, error) => {
|
|
25803
25781
|
if ("invalid_params" in error.data) {
|
|
@@ -25934,7 +25912,7 @@ const FileBox = (props) => {
|
|
|
25934
25912
|
return (jsxs(Box, { bgcolor: grey[200], borderRadius: '12px', p: 2, display: 'flex', children: [jsx(Box, { flexGrow: 0.8, display: 'flex', justifyContent: 'left', alignItems: 'center', children: jsx(Typography$1, { fontWeight: 'bold', children: props.file.name.split('.')[0] }) }), jsx(Box, { flexGrow: 0.2, display: 'flex', justifyContent: 'right', alignItems: 'center', children: props.loadingRemove ? (jsx(CircularProgress, { size: '18px' })) : (jsx(Tooltip, { title: 'Remove', children: jsx(IconButton, { color: 'error', sx: { p: 0 }, onClick: props.handleRemove, children: jsx(DeleteIcon, {}) }) })) })] }));
|
|
25935
25913
|
};
|
|
25936
25914
|
|
|
25937
|
-
const VisuallyHiddenInput = styled$1("input")({
|
|
25915
|
+
const VisuallyHiddenInput$1 = styled$1("input")({
|
|
25938
25916
|
clipPath: "inset(50%)",
|
|
25939
25917
|
height: 1,
|
|
25940
25918
|
overflow: "hidden",
|
|
@@ -25953,7 +25931,7 @@ const FileUploadBox = (props) => {
|
|
|
25953
25931
|
const Dropzone = ({ onChange, value }) => {
|
|
25954
25932
|
const onDrop = useCallback((acceptedFiles) => {
|
|
25955
25933
|
acceptedFiles.map((file) => {
|
|
25956
|
-
const data =
|
|
25934
|
+
const data = formParser({ type: "formData", submitData: { archivo: file } });
|
|
25957
25935
|
validarCSV({
|
|
25958
25936
|
endpoint: props.csvProps.endpoint || "",
|
|
25959
25937
|
data: data,
|
|
@@ -26004,7 +25982,7 @@ const FileUploadBox = (props) => {
|
|
|
26004
25982
|
return;
|
|
26005
25983
|
return Object.entries(rows).map(([row, errors]) => (jsx(RowErrors, { row: row, data: errors }, row)));
|
|
26006
25984
|
};
|
|
26007
|
-
return (jsx(Box$1, { width: 1, children: jsxs(Stack, { spacing: 2, children: [!file && !isLoading && (jsxs(Box$1, { component: "div", width: 1, display: "flex", justifyContent: "center", alignItems: "center", border: "1.5px dashed", borderRadius: "12px", py: 4, px: 2, borderColor: grey[800], bgcolor: grey[50], ...getRootProps(), children: [jsx(VisuallyHiddenInput, { id: "file-upload", type: "file", ...getInputProps() }), jsx(FileUploadIcon, { sx: {
|
|
25985
|
+
return (jsx(Box$1, { width: 1, children: jsxs(Stack, { spacing: 2, children: [!file && !isLoading && (jsxs(Box$1, { component: "div", width: 1, display: "flex", justifyContent: "center", alignItems: "center", border: "1.5px dashed", borderRadius: "12px", py: 4, px: 2, borderColor: grey[800], bgcolor: grey[50], ...getRootProps(), children: [jsx(VisuallyHiddenInput$1, { id: "file-upload", type: "file", ...getInputProps() }), jsx(FileUploadIcon, { sx: {
|
|
26008
25986
|
color: grey[800],
|
|
26009
25987
|
pr: 1,
|
|
26010
25988
|
} }), jsx(Typography, { variant: "body2", sx: { color: grey[800] }, children: isDragActive
|
|
@@ -26040,7 +26018,7 @@ const CSVUpload = (props) => {
|
|
|
26040
26018
|
};
|
|
26041
26019
|
const tag = useMemo(() => endpoint.split("/").at(-1), [endpoint]);
|
|
26042
26020
|
const onSubmitHandler = (submitData) => {
|
|
26043
|
-
const data =
|
|
26021
|
+
const data = formParser({ type: "formData", submitData });
|
|
26044
26022
|
subirCSV({ endpoint, tagType: tag, data, custom: props.data?.custom })
|
|
26045
26023
|
.unwrap()
|
|
26046
26024
|
.then((response) => {
|
|
@@ -26091,10 +26069,10 @@ const mergeSettings = (baseSettings, mergingSettings) => {
|
|
|
26091
26069
|
};
|
|
26092
26070
|
const val = (value) => {
|
|
26093
26071
|
if (Array.isArray(value)) {
|
|
26094
|
-
return value.join(
|
|
26072
|
+
return value.join(",");
|
|
26095
26073
|
}
|
|
26096
|
-
else if (typeof value ==
|
|
26097
|
-
return value ?
|
|
26074
|
+
else if (typeof value == "boolean") {
|
|
26075
|
+
return value ? "true" : "false";
|
|
26098
26076
|
}
|
|
26099
26077
|
else {
|
|
26100
26078
|
return value;
|
|
@@ -26104,20 +26082,21 @@ const filterQuery = ({ filters }) => {
|
|
|
26104
26082
|
if (!filters)
|
|
26105
26083
|
return [];
|
|
26106
26084
|
const queryParams = [];
|
|
26107
|
-
forEach
|
|
26085
|
+
forEach(filters, function (value, key) {
|
|
26108
26086
|
queryParams.push(`${key}=${val(value)}`);
|
|
26109
26087
|
});
|
|
26110
26088
|
return queryParams;
|
|
26111
26089
|
};
|
|
26112
26090
|
const filterGrid = ({ page, pageSize, filterModel, sortModel, ignoreSort }) => {
|
|
26091
|
+
//GridArgs
|
|
26113
26092
|
const queryParams = [];
|
|
26114
26093
|
if (page)
|
|
26115
26094
|
queryParams.push(`page=${page + 1}`);
|
|
26116
26095
|
if (pageSize)
|
|
26117
26096
|
queryParams.push(`page_size=${pageSize}`);
|
|
26118
26097
|
if (filterModel.items) {
|
|
26119
|
-
const jsonFilters =
|
|
26120
|
-
forEach
|
|
26098
|
+
const jsonFilters = formParser({ submitData: filterModel.items });
|
|
26099
|
+
forEach(jsonFilters, function (value, key) {
|
|
26121
26100
|
queryParams.push(`${key}=${val(value)}`);
|
|
26122
26101
|
});
|
|
26123
26102
|
}
|
|
@@ -26125,28 +26104,28 @@ const filterGrid = ({ page, pageSize, filterModel, sortModel, ignoreSort }) => {
|
|
|
26125
26104
|
queryParams.push(`search=${filterModel.quickFilterValues}`);
|
|
26126
26105
|
}
|
|
26127
26106
|
if (sortModel.length && !ignoreSort) {
|
|
26128
|
-
const val = `${sortModel[0]?.sort ==
|
|
26107
|
+
const val = `${sortModel[0]?.sort == "asc" ? "" : "-"}${sortModel[0]?.field}`;
|
|
26129
26108
|
queryParams.push(`ordering=${val}`);
|
|
26130
26109
|
}
|
|
26131
26110
|
return queryParams;
|
|
26132
26111
|
};
|
|
26133
26112
|
const query = (data, url, type) => {
|
|
26134
26113
|
switch (type) {
|
|
26135
|
-
case
|
|
26136
|
-
return `${url}?${filterGrid(data).join(
|
|
26137
|
-
case
|
|
26138
|
-
return `${url}?${filterQuery(data).join(
|
|
26139
|
-
case
|
|
26114
|
+
case "grid":
|
|
26115
|
+
return `${url}?${filterGrid(data).join("&")}`;
|
|
26116
|
+
case "simpleFilter":
|
|
26117
|
+
return `${url}?${filterQuery(data).join("&")}`;
|
|
26118
|
+
case "single":
|
|
26140
26119
|
return `${url}/${data.id}`;
|
|
26141
26120
|
}
|
|
26142
26121
|
};
|
|
26143
26122
|
const tags = (result, type, invalidate) => {
|
|
26144
26123
|
if (result) {
|
|
26145
26124
|
if (!invalidate) {
|
|
26146
|
-
if (
|
|
26125
|
+
if ("results" in result) {
|
|
26147
26126
|
return [
|
|
26148
26127
|
...result.results.map(({ id }) => ({ type: type, id })),
|
|
26149
|
-
{ type: type, id:
|
|
26128
|
+
{ type: type, id: "LIST" },
|
|
26150
26129
|
];
|
|
26151
26130
|
}
|
|
26152
26131
|
else {
|
|
@@ -26154,14 +26133,12 @@ const tags = (result, type, invalidate) => {
|
|
|
26154
26133
|
}
|
|
26155
26134
|
}
|
|
26156
26135
|
else {
|
|
26157
|
-
return invalidate.request ==
|
|
26158
|
-
[{ type: type, id: 'LIST' }] :
|
|
26159
|
-
[]; // { type: type, id: result.id }
|
|
26136
|
+
return invalidate.request == "post" ? [{ type: type, id: "LIST" }] : []; // { type: type, id: result.id }
|
|
26160
26137
|
}
|
|
26161
26138
|
}
|
|
26162
26139
|
else {
|
|
26163
26140
|
if (!invalidate) {
|
|
26164
|
-
return [{ type: type, id:
|
|
26141
|
+
return [{ type: type, id: "LIST" }];
|
|
26165
26142
|
}
|
|
26166
26143
|
else {
|
|
26167
26144
|
return [];
|
|
@@ -26172,15 +26149,15 @@ async function manualCacheRefresh(api, id, dispatch, queryFulfilled, endpoints)
|
|
|
26172
26149
|
try {
|
|
26173
26150
|
const { data } = await queryFulfilled;
|
|
26174
26151
|
if (endpoints.single) {
|
|
26175
|
-
dispatch(api.util.updateQueryData(endpoints.single, { id: id.toString(), type:
|
|
26176
|
-
Object.assign(draft, data[
|
|
26152
|
+
dispatch(api.util.updateQueryData(endpoints.single, { id: id.toString(), type: "single" }, (draft) => {
|
|
26153
|
+
Object.assign(draft, data["detail"]);
|
|
26177
26154
|
}));
|
|
26178
26155
|
}
|
|
26179
26156
|
if (endpoints.multiple) {
|
|
26180
|
-
dispatch(api.util.updateQueryData(endpoints.multiple, { type:
|
|
26181
|
-
const index = findIndex(draft.results, [
|
|
26157
|
+
dispatch(api.util.updateQueryData(endpoints.multiple, { type: "all" }, (draft) => {
|
|
26158
|
+
const index = findIndex(draft.results, ["id", id]);
|
|
26182
26159
|
if (index > -1)
|
|
26183
|
-
Object.assign(draft.results[index], data[
|
|
26160
|
+
Object.assign(draft.results[index], data["list"]);
|
|
26184
26161
|
}));
|
|
26185
26162
|
}
|
|
26186
26163
|
}
|
|
@@ -26510,10 +26487,23 @@ const ControlledTimePicker = (props) => {
|
|
|
26510
26487
|
} }));
|
|
26511
26488
|
};
|
|
26512
26489
|
|
|
26513
|
-
const
|
|
26514
|
-
|
|
26490
|
+
const VisuallyHiddenInput = styled$1("input")({
|
|
26491
|
+
clip: "rect(0 0 0 0)",
|
|
26492
|
+
clipPath: "inset(50%)",
|
|
26493
|
+
height: 1,
|
|
26494
|
+
overflow: "hidden",
|
|
26495
|
+
position: "absolute",
|
|
26496
|
+
bottom: 0,
|
|
26497
|
+
left: 0,
|
|
26498
|
+
whiteSpace: "nowrap",
|
|
26499
|
+
width: 1,
|
|
26500
|
+
});
|
|
26501
|
+
const ControlledFileField = (props) => {
|
|
26502
|
+
return (jsx(Controller, { control: props.control, name: props.name, render: ({ field: { value, onChange, onBlur, ref }, fieldState: { error } }) => {
|
|
26503
|
+
return (jsxs(FormGroup, { sx: { width: 1 }, color: "secondary", children: [value ? (jsxs(Stack, { direction: "row", spacing: 1, width: 1, alignItems: "center", children: [jsx(Typography$1, { children: value.name }), jsx(IconButton, { onClick: () => onChange(null), children: jsx(ClearIcon$1, { color: "error" }) })] })) : (jsxs(Button, { component: "label", variant: "contained", startIcon: jsx(UploadFileIcon, {}), sx: { maxWidth: 200 }, ...props.extraProps?.slotProps?.button, children: ["Cargar", jsx(VisuallyHiddenInput, { type: "file", accept: "image/*", ref: ref, onBlur: onBlur, onChange: (e) => onChange(e.target.files && e.target.files[0]), ...props.extraProps?.slotProps?.input })] })), jsx(FormHelperText$1, { error: !!error, children: error ? error.message : " " })] }));
|
|
26504
|
+
} }));
|
|
26515
26505
|
};
|
|
26516
|
-
|
|
26506
|
+
ControlledFileField.displayName = "ControlledFileField";
|
|
26517
26507
|
|
|
26518
26508
|
// ==============================|| DESLIZADOR CONTROLADO ||============================== //
|
|
26519
26509
|
const ControlledSlider = (props) => {
|
|
@@ -26526,7 +26516,8 @@ const ControlledSlider = (props) => {
|
|
|
26526
26516
|
|
|
26527
26517
|
const DeleteConfirmationDialog = (props) => {
|
|
26528
26518
|
const notifications = useNotifications();
|
|
26529
|
-
const pathname =
|
|
26519
|
+
const { pathname } = useLocation();
|
|
26520
|
+
const navigate = useNavigate();
|
|
26530
26521
|
const id = useMemo(() => props.id || pathname.split("/").at(-1), [pathname, props.id]);
|
|
26531
26522
|
const [mutation] = props.mutation();
|
|
26532
26523
|
const schema = object({ confirmation: string() });
|
|
@@ -26548,7 +26539,7 @@ const DeleteConfirmationDialog = (props) => {
|
|
|
26548
26539
|
handleClose();
|
|
26549
26540
|
}
|
|
26550
26541
|
else {
|
|
26551
|
-
|
|
26542
|
+
navigate(-1);
|
|
26552
26543
|
form.reset();
|
|
26553
26544
|
}
|
|
26554
26545
|
notifications.show("Objeto removido exitosamente!", { severity: "success" });
|
|
@@ -26780,6 +26771,18 @@ const ButtonWithDrawer = (props) => {
|
|
|
26780
26771
|
}) })] }));
|
|
26781
26772
|
};
|
|
26782
26773
|
|
|
26774
|
+
const MoreOptions = (props) => {
|
|
26775
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
26776
|
+
const open = Boolean(anchorEl);
|
|
26777
|
+
const handleClick = () => {
|
|
26778
|
+
setAnchorEl(document.getElementById("extra-options"));
|
|
26779
|
+
};
|
|
26780
|
+
const handleClose = () => {
|
|
26781
|
+
setAnchorEl(null);
|
|
26782
|
+
};
|
|
26783
|
+
return (jsxs(Fragment, { children: [jsx(IconButton, { id: "extra-options", onClick: handleClick, children: jsx(MoreVertIcon, {}) }, "extra-options"), jsx(StyledMenu, { anchorEl: anchorEl, open: open, onClose: handleClose, children: props.options.map((option) => (jsxs(MenuItem$1, { onClick: option.onClick, children: [jsx(ListItemIcon, { children: option.icon }), option.title] }))) })] }));
|
|
26784
|
+
};
|
|
26785
|
+
|
|
26783
26786
|
const StatusBadge = (props) => {
|
|
26784
26787
|
const color = useMemo(() => {
|
|
26785
26788
|
switch (props?.severity) {
|
|
@@ -26993,7 +26996,7 @@ const generateSchema = (columns, columnsFilter, id) => {
|
|
|
26993
26996
|
const tempSchema = z.object({});
|
|
26994
26997
|
const dynamicSchema = {};
|
|
26995
26998
|
const dv = {};
|
|
26996
|
-
forEach
|
|
26999
|
+
forEach(columns, function (column) {
|
|
26997
27000
|
if (column.filterable) {
|
|
26998
27001
|
switch (column.type) {
|
|
26999
27002
|
case 'string':
|
|
@@ -27059,7 +27062,7 @@ const FiltersPopper = (props) => {
|
|
|
27059
27062
|
useEffect(() => {
|
|
27060
27063
|
if (props.filters.filterModel.items) {
|
|
27061
27064
|
if (!every(props.filters.filterModel.items, function (_value, key) {
|
|
27062
|
-
return includes
|
|
27065
|
+
return includes(props.protectFilters, key);
|
|
27063
27066
|
})) {
|
|
27064
27067
|
setDirty(true);
|
|
27065
27068
|
}
|
|
@@ -27074,7 +27077,7 @@ const FiltersPopper = (props) => {
|
|
|
27074
27077
|
const handleClear = () => {
|
|
27075
27078
|
setDirty(false);
|
|
27076
27079
|
props.filters.setFilterModel(produce((draft) => {
|
|
27077
|
-
forEach
|
|
27080
|
+
forEach(props.filters.filterModel.items, function (_value, key) {
|
|
27078
27081
|
if (["ordering", "search"].concat(props.protectFilters || []).includes(key))
|
|
27079
27082
|
return;
|
|
27080
27083
|
delete draft["items"][key];
|
|
@@ -27327,8 +27330,8 @@ const EditGridWrapper = (props) => {
|
|
|
27327
27330
|
setEdit((prevState) => !prevState);
|
|
27328
27331
|
};
|
|
27329
27332
|
const processRowUpdate = async (newRow, originalRow) => {
|
|
27330
|
-
const original_data =
|
|
27331
|
-
const data =
|
|
27333
|
+
const original_data = formParser({ submitData: originalRow });
|
|
27334
|
+
const data = formParser({
|
|
27332
27335
|
submitData: newRow,
|
|
27333
27336
|
...(props.parser ? { props: props.parser } : []),
|
|
27334
27337
|
});
|
|
@@ -27980,45 +27983,31 @@ const LinkField = ({ url, value, text }) => {
|
|
|
27980
27983
|
const DetailField = (props) => {
|
|
27981
27984
|
const hasLinkToViewPermission = useHasPermission(`${props.navigation?.permission}.view`);
|
|
27982
27985
|
const value = useCallback(() => {
|
|
27983
|
-
|
|
27984
|
-
|
|
27985
|
-
|
|
27986
|
-
|
|
27987
|
-
|
|
27988
|
-
|
|
27989
|
-
|
|
27990
|
-
|
|
27991
|
-
|
|
27992
|
-
|
|
27993
|
-
|
|
27994
|
-
|
|
27995
|
-
|
|
27996
|
-
|
|
27997
|
-
|
|
27998
|
-
|
|
27999
|
-
|
|
28000
|
-
|
|
28001
|
-
|
|
28002
|
-
|
|
28003
|
-
|
|
28004
|
-
|
|
28005
|
-
}
|
|
28006
|
-
}
|
|
28007
|
-
else if (props.type.displayName == "ControlledPhotoField") {
|
|
28008
|
-
if (props.fieldData)
|
|
28009
|
-
return "Imagen";
|
|
28010
|
-
}
|
|
28011
|
-
else {
|
|
28012
|
-
if (props.fieldData) {
|
|
28013
|
-
if (props.detail_name) {
|
|
28014
|
-
return get(props.fieldData, props.detail_name);
|
|
28015
|
-
}
|
|
28016
|
-
return props.fieldData;
|
|
28017
|
-
}
|
|
27986
|
+
const { fieldData, type, extraProps, detail_name } = props;
|
|
27987
|
+
if (typeof fieldData === "boolean")
|
|
27988
|
+
return fieldData ? "Si" : "No";
|
|
27989
|
+
if (typeof fieldData === "number")
|
|
27990
|
+
return fieldData.toString();
|
|
27991
|
+
switch (type?.displayName) {
|
|
27992
|
+
case "ControlledSelect":
|
|
27993
|
+
return fieldData
|
|
27994
|
+
? fieldData.map((item) => item.label).join(", ")
|
|
27995
|
+
: "N/A";
|
|
27996
|
+
case "ControlledDate":
|
|
27997
|
+
if (!fieldData)
|
|
27998
|
+
return "N/A";
|
|
27999
|
+
return extraProps?.type === "datetime"
|
|
28000
|
+
? dayjs(fieldData).format("YYYY-MM-DD HH:mm")
|
|
28001
|
+
: dayjs(fieldData).format("YYYY-MM-DD");
|
|
28002
|
+
case "ControlledFileField":
|
|
28003
|
+
return fieldData ? "Archivo" : "N/A";
|
|
28004
|
+
default:
|
|
28005
|
+
if (!fieldData)
|
|
28006
|
+
return "N/A";
|
|
28007
|
+
return detail_name ? get(fieldData, detail_name) : fieldData;
|
|
28018
28008
|
}
|
|
28019
|
-
|
|
28020
|
-
|
|
28021
|
-
const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue : ""} ${value()} ${props.detailFieldProps?.postValue ? props.detailFieldProps.postValue : ""}`;
|
|
28009
|
+
}, [props.detail_name, props.extraProps, props.fieldData, props.type?.displayName]);
|
|
28010
|
+
const content = `${props.detailFieldProps?.preValue || ""} ${value()} ${props.detailFieldProps?.postValue || ""}`.trim();
|
|
28022
28011
|
if (props.navigation &&
|
|
28023
28012
|
hasLinkToViewPermission &&
|
|
28024
28013
|
props.fieldData &&
|
|
@@ -28028,8 +28017,8 @@ const DetailField = (props) => {
|
|
|
28028
28017
|
}
|
|
28029
28018
|
return (jsx(LinkField, { url: props.navigation.url, value: get(props.fieldData, "value"), text: content }));
|
|
28030
28019
|
}
|
|
28031
|
-
else if (props.type.displayName == "
|
|
28032
|
-
return (jsx(Link, { href: props.fieldData,
|
|
28020
|
+
else if (props.type.displayName == "ControlledFileField" && content !== "N/A") {
|
|
28021
|
+
return (jsx(Link, { href: props.fieldData, target: "_blank", rel: "noopener noreferrer", children: content }));
|
|
28033
28022
|
}
|
|
28034
28023
|
else {
|
|
28035
28024
|
if (Array.isArray(props.fieldData)) {
|
|
@@ -28060,7 +28049,7 @@ const EditField = (props) => {
|
|
|
28060
28049
|
});
|
|
28061
28050
|
const extraProps = useMemo(() => (produce(props.extraProps, (draft) => {
|
|
28062
28051
|
if (props.filters) {
|
|
28063
|
-
forEach
|
|
28052
|
+
forEach(props.filters, (filter, index) => {
|
|
28064
28053
|
set$1(draft, `queryArgs.filters.${filter.name}`, values[index]);
|
|
28065
28054
|
});
|
|
28066
28055
|
}
|
|
@@ -28115,8 +28104,8 @@ const FieldArrayField = (props) => {
|
|
|
28115
28104
|
remove(getIndex(id));
|
|
28116
28105
|
};
|
|
28117
28106
|
const processRowUpdate = async (newRow, originalRow) => {
|
|
28118
|
-
const original_data =
|
|
28119
|
-
const data =
|
|
28107
|
+
const original_data = formParser({ submitData: originalRow, props: props.parser });
|
|
28108
|
+
const data = formParser({ submitData: newRow, props: props.parser });
|
|
28120
28109
|
if (isEqual$1(data, original_data))
|
|
28121
28110
|
return originalRow;
|
|
28122
28111
|
const index = getIndex(data._id);
|
|
@@ -28390,6 +28379,9 @@ function DetailPage(props) {
|
|
|
28390
28379
|
resolver: zodResolver(props.edit.schema),
|
|
28391
28380
|
defaultValues: props.edit?.defaultValues,
|
|
28392
28381
|
});
|
|
28382
|
+
useImperativeHandle(props.ref, () => ({
|
|
28383
|
+
form: form,
|
|
28384
|
+
}));
|
|
28393
28385
|
const { data, isLoading, isFetching, error: fetchError, } = props.api.data.query(!props.api.data.skipToken ? props.api.data.args : skipToken);
|
|
28394
28386
|
useEffect(() => {
|
|
28395
28387
|
if (data) {
|
|
@@ -28422,11 +28414,12 @@ function DetailPage(props) {
|
|
|
28422
28414
|
const onSubmitHandler = (submitedData) => {
|
|
28423
28415
|
const formData = "nativeEvent" in submitedData ? form.getValues() : submitedData;
|
|
28424
28416
|
const params = {
|
|
28417
|
+
type: props.edit.useFormData ? "formData" : "json",
|
|
28425
28418
|
submitData: formData,
|
|
28426
28419
|
data: data,
|
|
28427
28420
|
props: props.slotProps?.parser,
|
|
28428
28421
|
};
|
|
28429
|
-
const dataToSend =
|
|
28422
|
+
const dataToSend = formParser(params);
|
|
28430
28423
|
mutation(props.edit.useFormData ? dataToSend : { ...dataToSend, ...props.api.mutate.args })
|
|
28431
28424
|
.unwrap()
|
|
28432
28425
|
.then(() => {
|
|
@@ -28494,7 +28487,8 @@ function DetailPage(props) {
|
|
|
28494
28487
|
if (props.pageType == "detail") {
|
|
28495
28488
|
if (!canEdit && !canDelete)
|
|
28496
28489
|
return null;
|
|
28497
|
-
return (jsxs(Stack, { direction: "row", spacing: 1, children: [canDelete && props.api.delete && (jsx(DeleteButton, { mutation: props.api.delete.mutation, disableNavBack: props.slotProps?.deleteButton?.disableNavBack })), canEdit && jsx(EditButton, {})
|
|
28490
|
+
return (jsxs(Stack, { direction: "row", spacing: 1, children: [canDelete && props.api.delete && (jsx(DeleteButton, { mutation: props.api.delete.mutation, disableNavBack: props.slotProps?.deleteButton?.disableNavBack })), canEdit && jsx(EditButton, {}), props.slots?.extraButtons &&
|
|
28491
|
+
map(props.slots.extraButtons, (btn) => btn(data?.id))] }));
|
|
28498
28492
|
}
|
|
28499
28493
|
else {
|
|
28500
28494
|
return (jsx(SaveCancelButton, { slotProps: {
|
|
@@ -28809,5 +28803,5 @@ const theme = () => {
|
|
|
28809
28803
|
return themes;
|
|
28810
28804
|
};
|
|
28811
28805
|
|
|
28812
|
-
export { APIContext, APIProvider, ActiveCell, Base, ButtonWithDrawer, CSVUpload, ContentLayout, ControlledDate, ControlledDropdown, FileUploadBox as ControlledFileUploadBox, ControlledNumber, ControlledPhoneNumber,
|
|
28806
|
+
export { APIContext, APIProvider, ActiveCell, Base, ButtonWithDrawer, CSVUpload, ContentLayout, ControlledDate, ControlledDropdown, ControlledFileField, FileUploadBox as ControlledFileUploadBox, ControlledNumber, ControlledPhoneNumber, ControlledSelect, ControlledSlider as ControlledSimpleSlider, ControlledSlider$1 as ControlledSlider, ControlledSwitch, ControlledText, ControlledTimePicker, ControlledToggleButtons, CoverPage, CreateButtonBase, CreateButtonWithMenuOptions, DeleteButton, DeleteConfirmationDialog, DetailPage, EditButton, ExportCSV, HistorialDrawer, ListPage, Loadable, LoadingComponent, Logo, MainDrawer, MenuItemWithLoading, ModuleCard, MoreOptions, MyGridEditSingleSelect, NavigationContext, NavigationProvider, NormalOrIcon, NotAllowed, NotFound, ObjectProgressStack, SaveCancelButton, StatusBadge, StyledMenu, Tabs, Transitions, UncontrolledText, changeTitle, closeProgressSnack, dayjs, deleteColumn, editColumn, filterQuery, formParser, header as headerReducer, manualCacheRefresh, mergeSettings, openProgressSnack, query, renderEditCellWithErrorTooltip, setErrors, snackProgress_default as snackProgressReducer, tags, theme, updateProgressSnackData, useAPI, useHasPermission, useNavigation, valueLabel };
|
|
28813
28807
|
//# sourceMappingURL=index.js.map
|