@acvl/frontend-components 0.0.32 → 0.0.34

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.
Files changed (24) hide show
  1. package/dist/cjs/index.js +184 -182
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/src/components/v1/buttons/MoreOptions/index.d.ts +10 -0
  4. package/dist/cjs/types/src/components/v1/buttons/index.d.ts +7 -6
  5. package/dist/cjs/types/src/components/v1/drawers/MainDrawer/index.d.ts +1 -1
  6. package/dist/cjs/types/src/components/v1/forms/utils.d.ts +2 -2
  7. package/dist/cjs/types/src/components/v1/inputs/controlled/ControlledFileField/index.d.ts +15 -0
  8. package/dist/cjs/types/src/components/v1/inputs/controlled/index.d.ts +13 -13
  9. package/dist/cjs/types/src/components/v1/layout/pages/DetailPage/FieldArrayField/index.d.ts +7 -2
  10. package/dist/cjs/types/src/components/v1/layout/pages/DetailPage/index.d.ts +2 -1
  11. package/dist/esm/index.js +190 -188
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/types/src/components/v1/buttons/MoreOptions/index.d.ts +10 -0
  14. package/dist/esm/types/src/components/v1/buttons/index.d.ts +7 -6
  15. package/dist/esm/types/src/components/v1/drawers/MainDrawer/index.d.ts +1 -1
  16. package/dist/esm/types/src/components/v1/forms/utils.d.ts +2 -2
  17. package/dist/esm/types/src/components/v1/inputs/controlled/ControlledFileField/index.d.ts +15 -0
  18. package/dist/esm/types/src/components/v1/inputs/controlled/index.d.ts +13 -13
  19. package/dist/esm/types/src/components/v1/layout/pages/DetailPage/FieldArrayField/index.d.ts +7 -2
  20. package/dist/esm/types/src/components/v1/layout/pages/DetailPage/index.d.ts +2 -1
  21. package/dist/index.d.ts +42 -21
  22. package/package.json +1 -1
  23. package/dist/cjs/types/src/components/v1/inputs/controlled/ControlledPhotoField/index.d.ts +0 -6
  24. package/dist/esm/types/src/components/v1/inputs/controlled/ControlledPhotoField/index.d.ts +0 -6
package/dist/cjs/index.js CHANGED
@@ -47,10 +47,7 @@ var immer = require('immer');
47
47
  var set = require('lodash/set');
48
48
  var get = require('lodash/get');
49
49
  var isEmpty = require('lodash/isEmpty');
50
- var isNull = require('lodash/isNull');
51
50
  var isEqual = require('lodash/isEqual');
52
- var forEach = require('lodash/forEach');
53
- var includes = require('lodash/includes');
54
51
  var CancelIcon = require('@mui/icons-material/Cancel');
55
52
  var HistoryIcon = require('@mui/icons-material/History');
56
53
  var lab = require('@mui/lab');
@@ -70,20 +67,21 @@ var CheckBoxOutlineBlankIcon = require('@mui/icons-material/CheckBoxOutlineBlank
70
67
  var CheckBoxIcon = require('@mui/icons-material/CheckBox');
71
68
  var iconsMaterial = require('@mui/icons-material');
72
69
  var merge$1 = require('lodash/merge');
70
+ var UploadFileIcon = require('@mui/icons-material/UploadFile');
71
+ var ClearIcon$1 = require('@mui/icons-material/Clear');
73
72
  var SaveIcon = require('@mui/icons-material/Save');
74
73
  var AddIcon = require('@mui/icons-material/Add');
75
74
  var KeyboardArrowDownIcon = require('@mui/icons-material/KeyboardArrowDown');
76
75
  var LinearProgress = require('@mui/material/LinearProgress');
77
76
  var AttachFileIcon = require('@mui/icons-material/AttachFile');
77
+ var MoreVertIcon = require('@mui/icons-material/MoreVert');
78
78
  var xDataGrid = require('@mui/x-data-grid');
79
79
  var Tooltip = require('@mui/material/Tooltip');
80
80
  var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
81
81
  var ExpandLessIcon = require('@mui/icons-material/ExpandLess');
82
82
  var Menu = require('@mui/material/Menu');
83
- var MoreVertIcon = require('@mui/icons-material/MoreVert');
84
83
  var SearchIcon = require('@mui/icons-material/Search');
85
84
  var FilterListIcon = require('@mui/icons-material/FilterList');
86
- var ClearIcon$1 = require('@mui/icons-material/Clear');
87
85
  var FilterAltIcon = require('@mui/icons-material/FilterAlt');
88
86
  var FilterNoneIcon = require('@mui/icons-material/FilterNone');
89
87
  var CheckIcon = require('@mui/icons-material/Check');
@@ -25668,68 +25666,65 @@ dayjs.locale(es);
25668
25666
  dayjs.extend(duration);
25669
25667
 
25670
25668
  // ==============================|| JSON ||============================== //
25669
+ const setValue = (formType, form, key, value) => {
25670
+ if (formType === "json")
25671
+ set(form, key, value);
25672
+ else
25673
+ form.append(key, value);
25674
+ };
25671
25675
  const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, data, props, formType, }) => {
25672
25676
  const ignore = get(props, `${base_key}.ignore`, false);
25673
25677
  if (ignore || ["obj_permissions", "has_history"].includes(base_key))
25674
25678
  return;
25675
- const altered_key = lodash.invoke(props, `${base_key}.alter_key`, base_key);
25679
+ const altered_key = props?.[base_key]?.alter_key?.(base_key);
25676
25680
  const key = altered_key || base_key;
25677
- const altered_obj = lodash.invoke(props, `${base_key}.alter_value`, base_object, submitData);
25681
+ const altered_obj = props?.[base_key]?.alter_value?.(base_object, submitData);
25678
25682
  const object = altered_obj || base_object;
25679
- const setValue = (form, key, value) => {
25680
- if (formType === "json") {
25681
- set(form, key, value);
25682
- }
25683
- else if (formType === "formData") {
25684
- form.append(key, value);
25685
- }
25686
- };
25687
25683
  switch (typeof object) {
25688
25684
  case "string":
25689
- if (lodash.invoke(props, `${base_key}.extra_validation`, object))
25685
+ if (props?.[base_key]?.extra_validation?.(object))
25690
25686
  return;
25691
- setValue(response, key, isEmpty(object) ? "" : object);
25687
+ setValue(formType, response, key, isEmpty(object) ? "" : object);
25692
25688
  break;
25693
25689
  case "number":
25694
- setValue(response, key, object);
25690
+ setValue(formType, response, key, object);
25695
25691
  break;
25696
25692
  case "boolean":
25697
- setValue(response, key, object);
25693
+ setValue(formType, response, key, object);
25698
25694
  break;
25699
25695
  case "object":
25700
- if (isNull(object) || isEmpty(object)) {
25701
- if (includes(key, "after") || includes(key, "before"))
25702
- setValue(response, key, "");
25703
- else
25704
- setValue(response, key, object);
25696
+ if (object instanceof File) {
25697
+ setValue(formType, response, key, object);
25705
25698
  }
25706
- else if (object instanceof File) {
25707
- setValue(response, key, object);
25699
+ else if (object === null || isEmpty(object)) {
25700
+ if (key.includes("after") || key.includes("before"))
25701
+ setValue(formType, response, key, "");
25702
+ else
25703
+ setValue(formType, response, key, formType == "json" ? object : "");
25708
25704
  }
25709
25705
  else if (dayjs.isDayjs(object)) {
25710
- setValue(response, key, object.format(get(props, `${key}.format`, "YYYY-MM-DD")));
25706
+ setValue(formType, response, key, object.format(get(props, `${key}.format`, "YYYY-MM-DD")));
25711
25707
  }
25712
25708
  else if ("label" in object && "value" in object) {
25713
25709
  if (useLabel)
25714
- setValue(response, key, object["label"]);
25710
+ setValue(formType, response, key, object["label"]);
25715
25711
  else
25716
- setValue(response, key, object["value"]);
25712
+ setValue(formType, response, key, object["value"]);
25717
25713
  }
25718
25714
  else if (Array.isArray(object)) {
25719
- // it is an array
25720
25715
  if (object.length &&
25721
- typeof object[0] == "object" &&
25716
+ typeof object[0] === "object" &&
25722
25717
  !Array.isArray(object[0]) &&
25723
25718
  "value" in object[0] &&
25724
- object[0]["value"] == "all") {
25719
+ object[0]["value"] === "all") {
25725
25720
  // for data grid filters
25726
- setValue(response, key, "");
25721
+ setValue(formType, response, key, "");
25727
25722
  }
25728
25723
  else {
25729
- forEach(object, (arrayItem, idx) => {
25730
- if (typeof arrayItem == "object") {
25724
+ object.forEach((arrayItem, idx) => {
25725
+ if (typeof arrayItem === "object") {
25731
25726
  if ("label" in arrayItem) {
25732
- setValue(response, `${key}.${idx}`, function (item) {
25727
+ setValue(formType, response, `${key}.${idx}`, function (item) {
25733
25728
  if (useLabel)
25734
25729
  return item.label;
25735
25730
  else
@@ -25738,7 +25733,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
25738
25733
  }
25739
25734
  typeSwitch({
25740
25735
  base_object: arrayItem,
25741
- base_key: `${key}.${idx}`,
25736
+ base_key: formType === "json" ? `${key}.${idx}` : `${key}[${idx}]`,
25742
25737
  response: response,
25743
25738
  useLabel: useLabel,
25744
25739
  data: data,
@@ -25752,21 +25747,21 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
25752
25747
  if (keyArray)
25753
25748
  keyArray.push(arrayItem);
25754
25749
  else
25755
- setValue(response, key, [arrayItem]);
25750
+ setValue(formType, response, key, [arrayItem]);
25756
25751
  }
25757
25752
  });
25758
25753
  }
25759
25754
  }
25760
25755
  else if (object instanceof Set) {
25761
- setValue(response, key, Array.from(object));
25756
+ setValue(formType, response, key, Array.from(object));
25762
25757
  }
25763
25758
  else {
25764
- forEach(object, (value, key2) => {
25759
+ Object.entries(object).forEach(([key2, value]) => {
25765
25760
  if (key2 !== "id" && isEqual(get(data, `${key}.${key2}`), value))
25766
25761
  return;
25767
25762
  typeSwitch({
25768
25763
  base_object: value,
25769
- base_key: `${key}.${key2}`,
25764
+ base_key: formType === "json" ? `${key}.${key2}` : `${key}${key2}`,
25770
25765
  response: response,
25771
25766
  useLabel: useLabel,
25772
25767
  data: data,
@@ -25778,14 +25773,15 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
25778
25773
  }
25779
25774
  break;
25780
25775
  default:
25781
- setValue(response, key, object);
25776
+ setValue(formType, response, key, object);
25782
25777
  break;
25783
25778
  }
25784
25779
  };
25785
- const jsonForm = ({ submitData, data, useLabel, props }) => {
25786
- const response = {};
25787
- forEach(submitData, function (value, key) {
25788
- if (key != "id" && isEqual(get(data, key), value))
25780
+ const formParser = ({ type, submitData, data, useLabel, props, }) => {
25781
+ const t = type || "json";
25782
+ const response = t === "json" ? {} : new FormData();
25783
+ Object.entries(submitData).forEach(([key, value]) => {
25784
+ if (key !== "id" && isEqual(get(data, key), value))
25789
25785
  return;
25790
25786
  typeSwitch({
25791
25787
  base_object: value,
@@ -25795,29 +25791,11 @@ const jsonForm = ({ submitData, data, useLabel, props }) => {
25795
25791
  data: data,
25796
25792
  props: props,
25797
25793
  submitData: submitData,
25798
- formType: "json",
25794
+ formType: t,
25799
25795
  });
25800
25796
  });
25801
25797
  return response;
25802
25798
  };
25803
- const formDataForm = ({ submitData, data, useLabel, props }) => {
25804
- const formData = new FormData();
25805
- forEach(submitData, function (value, key) {
25806
- if (key != "id" && isEqual(get(data, key), value))
25807
- return;
25808
- typeSwitch({
25809
- base_object: value,
25810
- base_key: key,
25811
- response: formData,
25812
- useLabel: useLabel,
25813
- data: data,
25814
- props: props,
25815
- submitData: submitData,
25816
- formType: "formData",
25817
- });
25818
- });
25819
- return formData;
25820
- };
25821
25799
  // ==============================|| ERRORS ||============================== //
25822
25800
  const setErrors = (form, error) => {
25823
25801
  if ("invalid_params" in error.data) {
@@ -25954,7 +25932,7 @@ const FileBox = (props) => {
25954
25932
  return (jsxRuntime.jsxs(material.Box, { bgcolor: colors.grey[200], borderRadius: '12px', p: 2, display: 'flex', children: [jsxRuntime.jsx(material.Box, { flexGrow: 0.8, display: 'flex', justifyContent: 'left', alignItems: 'center', children: jsxRuntime.jsx(material.Typography, { fontWeight: 'bold', children: props.file.name.split('.')[0] }) }), jsxRuntime.jsx(material.Box, { flexGrow: 0.2, display: 'flex', justifyContent: 'right', alignItems: 'center', children: props.loadingRemove ? (jsxRuntime.jsx(material.CircularProgress, { size: '18px' })) : (jsxRuntime.jsx(material.Tooltip, { title: 'Remove', children: jsxRuntime.jsx(material.IconButton, { color: 'error', sx: { p: 0 }, onClick: props.handleRemove, children: jsxRuntime.jsx(DeleteIcon, {}) }) })) })] }));
25955
25933
  };
25956
25934
 
25957
- const VisuallyHiddenInput = material.styled("input")({
25935
+ const VisuallyHiddenInput$1 = material.styled("input")({
25958
25936
  clipPath: "inset(50%)",
25959
25937
  height: 1,
25960
25938
  overflow: "hidden",
@@ -25973,7 +25951,7 @@ const FileUploadBox = (props) => {
25973
25951
  const Dropzone = ({ onChange, value }) => {
25974
25952
  const onDrop = React.useCallback((acceptedFiles) => {
25975
25953
  acceptedFiles.map((file) => {
25976
- const data = formDataForm({ submitData: { archivo: file } });
25954
+ const data = formParser({ type: "formData", submitData: { archivo: file } });
25977
25955
  validarCSV({
25978
25956
  endpoint: props.csvProps.endpoint || "",
25979
25957
  data: data,
@@ -26024,7 +26002,7 @@ const FileUploadBox = (props) => {
26024
26002
  return;
26025
26003
  return Object.entries(rows).map(([row, errors]) => (jsxRuntime.jsx(RowErrors, { row: row, data: errors }, row)));
26026
26004
  };
26027
- return (jsxRuntime.jsx(Box, { width: 1, children: jsxRuntime.jsxs(material.Stack, { spacing: 2, children: [!file && !isLoading && (jsxRuntime.jsxs(Box, { component: "div", width: 1, display: "flex", justifyContent: "center", alignItems: "center", border: "1.5px dashed", borderRadius: "12px", py: 4, px: 2, borderColor: colors.grey[800], bgcolor: colors.grey[50], ...getRootProps(), children: [jsxRuntime.jsx(VisuallyHiddenInput, { id: "file-upload", type: "file", ...getInputProps() }), jsxRuntime.jsx(FileUploadIcon, { sx: {
26005
+ return (jsxRuntime.jsx(Box, { width: 1, children: jsxRuntime.jsxs(material.Stack, { spacing: 2, children: [!file && !isLoading && (jsxRuntime.jsxs(Box, { component: "div", width: 1, display: "flex", justifyContent: "center", alignItems: "center", border: "1.5px dashed", borderRadius: "12px", py: 4, px: 2, borderColor: colors.grey[800], bgcolor: colors.grey[50], ...getRootProps(), children: [jsxRuntime.jsx(VisuallyHiddenInput$1, { id: "file-upload", type: "file", ...getInputProps() }), jsxRuntime.jsx(FileUploadIcon, { sx: {
26028
26006
  color: colors.grey[800],
26029
26007
  pr: 1,
26030
26008
  } }), jsxRuntime.jsx(Typography, { variant: "body2", sx: { color: colors.grey[800] }, children: isDragActive
@@ -26060,7 +26038,7 @@ const CSVUpload = (props) => {
26060
26038
  };
26061
26039
  const tag = React.useMemo(() => endpoint.split("/").at(-1), [endpoint]);
26062
26040
  const onSubmitHandler = (submitData) => {
26063
- const data = formDataForm({ submitData });
26041
+ const data = formParser({ type: "formData", submitData });
26064
26042
  subirCSV({ endpoint, tagType: tag, data, custom: props.data?.custom })
26065
26043
  .unwrap()
26066
26044
  .then((response) => {
@@ -26111,10 +26089,10 @@ const mergeSettings = (baseSettings, mergingSettings) => {
26111
26089
  };
26112
26090
  const val = (value) => {
26113
26091
  if (Array.isArray(value)) {
26114
- return value.join(',');
26092
+ return value.join(",");
26115
26093
  }
26116
- else if (typeof value == 'boolean') {
26117
- return value ? 'true' : 'false';
26094
+ else if (typeof value == "boolean") {
26095
+ return value ? "true" : "false";
26118
26096
  }
26119
26097
  else {
26120
26098
  return value;
@@ -26130,13 +26108,14 @@ const filterQuery = ({ filters }) => {
26130
26108
  return queryParams;
26131
26109
  };
26132
26110
  const filterGrid = ({ page, pageSize, filterModel, sortModel, ignoreSort }) => {
26111
+ //GridArgs
26133
26112
  const queryParams = [];
26134
26113
  if (page)
26135
26114
  queryParams.push(`page=${page + 1}`);
26136
26115
  if (pageSize)
26137
26116
  queryParams.push(`page_size=${pageSize}`);
26138
26117
  if (filterModel.items) {
26139
- const jsonFilters = jsonForm({ submitData: filterModel.items });
26118
+ const jsonFilters = formParser({ submitData: filterModel.items });
26140
26119
  lodash.forEach(jsonFilters, function (value, key) {
26141
26120
  queryParams.push(`${key}=${val(value)}`);
26142
26121
  });
@@ -26145,28 +26124,28 @@ const filterGrid = ({ page, pageSize, filterModel, sortModel, ignoreSort }) => {
26145
26124
  queryParams.push(`search=${filterModel.quickFilterValues}`);
26146
26125
  }
26147
26126
  if (sortModel.length && !ignoreSort) {
26148
- const val = `${sortModel[0]?.sort == 'asc' ? '' : '-'}${sortModel[0]?.field}`;
26127
+ const val = `${sortModel[0]?.sort == "asc" ? "" : "-"}${sortModel[0]?.field}`;
26149
26128
  queryParams.push(`ordering=${val}`);
26150
26129
  }
26151
26130
  return queryParams;
26152
26131
  };
26153
26132
  const query = (data, url, type) => {
26154
26133
  switch (type) {
26155
- case 'grid':
26156
- return `${url}?${filterGrid(data).join('&')}`;
26157
- case 'simpleFilter':
26158
- return `${url}?${filterQuery(data).join('&')}`;
26159
- case 'single':
26134
+ case "grid":
26135
+ return `${url}?${filterGrid(data).join("&")}`;
26136
+ case "simpleFilter":
26137
+ return `${url}?${filterQuery(data).join("&")}`;
26138
+ case "single":
26160
26139
  return `${url}/${data.id}`;
26161
26140
  }
26162
26141
  };
26163
26142
  const tags = (result, type, invalidate) => {
26164
26143
  if (result) {
26165
26144
  if (!invalidate) {
26166
- if ('results' in result) {
26145
+ if ("results" in result) {
26167
26146
  return [
26168
26147
  ...result.results.map(({ id }) => ({ type: type, id })),
26169
- { type: type, id: 'LIST' },
26148
+ { type: type, id: "LIST" },
26170
26149
  ];
26171
26150
  }
26172
26151
  else {
@@ -26174,14 +26153,12 @@ const tags = (result, type, invalidate) => {
26174
26153
  }
26175
26154
  }
26176
26155
  else {
26177
- return invalidate.request == 'post' ?
26178
- [{ type: type, id: 'LIST' }] :
26179
- []; // { type: type, id: result.id }
26156
+ return invalidate.request == "post" ? [{ type: type, id: "LIST" }] : []; // { type: type, id: result.id }
26180
26157
  }
26181
26158
  }
26182
26159
  else {
26183
26160
  if (!invalidate) {
26184
- return [{ type: type, id: 'LIST' },];
26161
+ return [{ type: type, id: "LIST" }];
26185
26162
  }
26186
26163
  else {
26187
26164
  return [];
@@ -26192,15 +26169,15 @@ async function manualCacheRefresh(api, id, dispatch, queryFulfilled, endpoints)
26192
26169
  try {
26193
26170
  const { data } = await queryFulfilled;
26194
26171
  if (endpoints.single) {
26195
- dispatch(api.util.updateQueryData(endpoints.single, { id: id.toString(), type: 'single' }, (draft) => {
26196
- Object.assign(draft, data['detail']);
26172
+ dispatch(api.util.updateQueryData(endpoints.single, { id: id.toString(), type: "single" }, (draft) => {
26173
+ Object.assign(draft, data["detail"]);
26197
26174
  }));
26198
26175
  }
26199
26176
  if (endpoints.multiple) {
26200
- dispatch(api.util.updateQueryData(endpoints.multiple, { type: 'all' }, (draft) => {
26201
- const index = lodash.findIndex(draft.results, ['id', id]);
26177
+ dispatch(api.util.updateQueryData(endpoints.multiple, { type: "all" }, (draft) => {
26178
+ const index = lodash.findIndex(draft.results, ["id", id]);
26202
26179
  if (index > -1)
26203
- Object.assign(draft.results[index], data['list']);
26180
+ Object.assign(draft.results[index], data["list"]);
26204
26181
  }));
26205
26182
  }
26206
26183
  }
@@ -26530,10 +26507,23 @@ const ControlledTimePicker = (props) => {
26530
26507
  } }));
26531
26508
  };
26532
26509
 
26533
- const ControlledPhotoField = (props) => {
26534
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.name, render: ({ field: { onChange, onBlur, ref }, fieldState: { error } }) => (jsxRuntime.jsxs(material.FormGroup, { sx: { width: 1 }, color: 'secondary', children: [jsxRuntime.jsx("input", { type: "file", accept: "image/*", ref: ref, onBlur: onBlur, onChange: (e) => onChange(e.target.files && e.target.files[0]) }), jsxRuntime.jsx(material.FormHelperText, { error: !!error, children: error ? error.message : ' ' })] })) }));
26510
+ const VisuallyHiddenInput = material.styled("input")({
26511
+ clip: "rect(0 0 0 0)",
26512
+ clipPath: "inset(50%)",
26513
+ height: 1,
26514
+ overflow: "hidden",
26515
+ position: "absolute",
26516
+ bottom: 0,
26517
+ left: 0,
26518
+ whiteSpace: "nowrap",
26519
+ width: 1,
26520
+ });
26521
+ const ControlledFileField = (props) => {
26522
+ return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.name, render: ({ field: { value, onChange, onBlur, ref }, fieldState: { error } }) => {
26523
+ return (jsxRuntime.jsxs(material.FormGroup, { sx: { width: 1 }, color: "secondary", children: [value ? (jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, width: 1, alignItems: "center", children: [jsxRuntime.jsx(material.Typography, { children: value.name }), jsxRuntime.jsx(material.IconButton, { onClick: () => onChange(null), children: jsxRuntime.jsx(ClearIcon$1, { color: "error" }) })] })) : (jsxRuntime.jsxs(material.Button, { component: "label", variant: "contained", startIcon: jsxRuntime.jsx(UploadFileIcon, {}), sx: { maxWidth: 200 }, ...props.extraProps?.slotProps?.button, children: ["Cargar", jsxRuntime.jsx(VisuallyHiddenInput, { type: "file", accept: "image/*", ref: ref, onBlur: onBlur, onChange: (e) => onChange(e.target.files && e.target.files[0]), ...props.extraProps?.slotProps?.input })] })), jsxRuntime.jsx(material.FormHelperText, { error: !!error, children: error ? error.message : " " })] }));
26524
+ } }));
26535
26525
  };
26536
- ControlledPhotoField.displayName = 'ControlledPhotoField';
26526
+ ControlledFileField.displayName = "ControlledFileField";
26537
26527
 
26538
26528
  // ==============================|| DESLIZADOR CONTROLADO ||============================== //
26539
26529
  const ControlledSlider = (props) => {
@@ -26546,7 +26536,8 @@ const ControlledSlider = (props) => {
26546
26536
 
26547
26537
  const DeleteConfirmationDialog = (props) => {
26548
26538
  const notifications = core.useNotifications();
26549
- const pathname = "temp";
26539
+ const { pathname } = reactRouterDom.useLocation();
26540
+ const navigate = reactRouterDom.useNavigate();
26550
26541
  const id = React.useMemo(() => props.id || pathname.split("/").at(-1), [pathname, props.id]);
26551
26542
  const [mutation] = props.mutation();
26552
26543
  const schema = zod.object({ confirmation: zod.string() });
@@ -26568,7 +26559,7 @@ const DeleteConfirmationDialog = (props) => {
26568
26559
  handleClose();
26569
26560
  }
26570
26561
  else {
26571
- // props.navigate(-1);
26562
+ navigate(-1);
26572
26563
  form.reset();
26573
26564
  }
26574
26565
  notifications.show("Objeto removido exitosamente!", { severity: "success" });
@@ -26800,6 +26791,18 @@ const ButtonWithDrawer = (props) => {
26800
26791
  }) })] }));
26801
26792
  };
26802
26793
 
26794
+ const MoreOptions = (props) => {
26795
+ const [anchorEl, setAnchorEl] = React.useState(null);
26796
+ const open = Boolean(anchorEl);
26797
+ const handleClick = () => {
26798
+ setAnchorEl(document.getElementById("extra-options"));
26799
+ };
26800
+ const handleClose = () => {
26801
+ setAnchorEl(null);
26802
+ };
26803
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.IconButton, { id: "extra-options", onClick: handleClick, children: jsxRuntime.jsx(MoreVertIcon, {}) }, "extra-options"), jsxRuntime.jsx(StyledMenu, { anchorEl: anchorEl, open: open, onClose: handleClose, children: props.options.map((option) => (jsxRuntime.jsxs(material.MenuItem, { onClick: option.onClick, children: [jsxRuntime.jsx(material.ListItemIcon, { children: option.icon }), option.title] }))) })] }));
26804
+ };
26805
+
26803
26806
  const StatusBadge = (props) => {
26804
26807
  const color = React.useMemo(() => {
26805
26808
  switch (props?.severity) {
@@ -27347,8 +27350,8 @@ const EditGridWrapper = (props) => {
27347
27350
  setEdit((prevState) => !prevState);
27348
27351
  };
27349
27352
  const processRowUpdate = async (newRow, originalRow) => {
27350
- const original_data = jsonForm({ submitData: originalRow });
27351
- const data = jsonForm({
27353
+ const original_data = formParser({ submitData: originalRow });
27354
+ const data = formParser({
27352
27355
  submitData: newRow,
27353
27356
  ...(props.parser ? { props: props.parser } : []),
27354
27357
  });
@@ -28000,45 +28003,31 @@ const LinkField = ({ url, value, text }) => {
28000
28003
  const DetailField = (props) => {
28001
28004
  const hasLinkToViewPermission = useHasPermission(`${props.navigation?.permission}.view`);
28002
28005
  const value = React.useCallback(() => {
28003
- if (typeof props.fieldData == "boolean") {
28004
- if (props.fieldData)
28005
- return "Si";
28006
- return "No";
28007
- }
28008
- else if (typeof props.fieldData == "number") {
28009
- return props.fieldData.toString();
28010
- }
28011
- else if (props.type.displayName == "ControlledSelect") {
28012
- if (props.fieldData)
28013
- return lodash.map(props.fieldData, function (item) {
28014
- return item.label;
28015
- }).join(", ");
28016
- }
28017
- else if (props.type.displayName == "ControlledDate") {
28018
- if (props.fieldData) {
28019
- switch (props.extraProps.type) {
28020
- case "date":
28021
- return dayjs(props.fieldData).format("YYYY-MM-DD");
28022
- case "datetime":
28023
- return dayjs(props.fieldData).format("YYYY-MM-DD HH:mm");
28024
- }
28025
- }
28026
- }
28027
- else if (props.type.displayName == "ControlledPhotoField") {
28028
- if (props.fieldData)
28029
- return "Imagen";
28030
- }
28031
- else {
28032
- if (props.fieldData) {
28033
- if (props.detail_name) {
28034
- return lodash.get(props.fieldData, props.detail_name);
28035
- }
28036
- return props.fieldData;
28037
- }
28006
+ const { fieldData, type, extraProps, detail_name } = props;
28007
+ if (typeof fieldData === "boolean")
28008
+ return fieldData ? "Si" : "No";
28009
+ if (typeof fieldData === "number")
28010
+ return fieldData.toString();
28011
+ switch (type?.displayName) {
28012
+ case "ControlledSelect":
28013
+ return fieldData
28014
+ ? fieldData.map((item) => item.label).join(", ")
28015
+ : "N/A";
28016
+ case "ControlledDate":
28017
+ if (!fieldData)
28018
+ return "N/A";
28019
+ return extraProps?.type === "datetime"
28020
+ ? dayjs(fieldData).format("YYYY-MM-DD HH:mm")
28021
+ : dayjs(fieldData).format("YYYY-MM-DD");
28022
+ case "ControlledFileField":
28023
+ return fieldData ? "Archivo" : "N/A";
28024
+ default:
28025
+ if (!fieldData)
28026
+ return "N/A";
28027
+ return detail_name ? lodash.get(fieldData, detail_name) : fieldData;
28038
28028
  }
28039
- return "N/A";
28040
- }, [props.detail_name, props.fieldData, props.type.displayName]);
28041
- const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue : ""} ${value()} ${props.detailFieldProps?.postValue ? props.detailFieldProps.postValue : ""}`;
28029
+ }, [props.detail_name, props.extraProps, props.fieldData, props.type?.displayName]);
28030
+ const content = `${props.detailFieldProps?.preValue || ""} ${value()} ${props.detailFieldProps?.postValue || ""}`.trim();
28042
28031
  if (props.navigation &&
28043
28032
  hasLinkToViewPermission &&
28044
28033
  props.fieldData &&
@@ -28048,8 +28037,8 @@ const DetailField = (props) => {
28048
28037
  }
28049
28038
  return (jsxRuntime.jsx(LinkField, { url: props.navigation.url, value: lodash.get(props.fieldData, "value"), text: content }));
28050
28039
  }
28051
- else if (props.type.displayName == "ControlledPhotoField") {
28052
- return (jsxRuntime.jsx(material.Link, { href: props.fieldData, download: "filename.pdf", children: content }));
28040
+ else if (props.type.displayName == "ControlledFileField" && content !== "N/A") {
28041
+ return (jsxRuntime.jsx(material.Link, { href: props.fieldData, target: "_blank", rel: "noopener noreferrer", children: content }));
28053
28042
  }
28054
28043
  else {
28055
28044
  if (Array.isArray(props.fieldData)) {
@@ -28115,43 +28104,49 @@ const Field = (props) => {
28115
28104
  };
28116
28105
 
28117
28106
  const EditToolbar = (props) => {
28118
- return (jsxRuntime.jsx(xDataGrid.Toolbar, { children: props.pageType != "detail" && (jsxRuntime.jsx(Tooltip, { title: "Crear", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.handleCreate, children: jsxRuntime.jsx(AddIcon, { fontSize: "small" }) }) })) }));
28107
+ return (jsxRuntime.jsx(xDataGrid.Toolbar, { children: props.pageType != "detail" && (jsxRuntime.jsx(Tooltip, { title: "Crear", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.handleClick, children: jsxRuntime.jsx(AddIcon, { fontSize: "small" }) }) })) }));
28119
28108
  };
28120
28109
  const FieldArrayField = (props) => {
28121
28110
  const detail = React.useMemo(() => props.pageType === "detail", [props.pageType]);
28122
- const { fields, append, update, remove } = reactHookForm.useFieldArray({
28111
+ const { fields, append, remove, update } = reactHookForm.useFieldArray({
28123
28112
  control: props.form.control,
28124
28113
  name: props.name,
28125
28114
  keyName: "_id",
28126
28115
  });
28127
- const [rowModesModel, setRowModesModel] = React.useState({});
28116
+ // console.log(props.form?.watch(props.name));
28117
+ // console.log(fields);
28128
28118
  const getIndex = React.useCallback((id) => lodash.findIndex(fields, function (field) {
28129
28119
  return field._id == id;
28130
28120
  }), [fields]);
28121
+ const [drawer, setDrawer] = React.useState({
28122
+ index: 0,
28123
+ open: false,
28124
+ });
28131
28125
  const handleCreate = () => {
28132
28126
  append(props.defaultValues);
28127
+ setDrawer({ index: fields.length, open: true });
28128
+ };
28129
+ const handleRowClick = (params) => {
28130
+ const index = getIndex(params.id);
28131
+ setDrawer({ index, open: true });
28132
+ };
28133
+ const handleCloseDrawer = () => {
28134
+ setDrawer((prev) => ({ ...prev, open: false }));
28135
+ };
28136
+ const handleCancel = () => {
28137
+ update(drawer.index, fields[drawer.index]);
28138
+ handleCloseDrawer();
28139
+ };
28140
+ const handleSave = () => {
28141
+ update(drawer.index, props.form.watch(`${props.name}.${drawer.index}`));
28142
+ handleCloseDrawer();
28133
28143
  };
28134
28144
  const handleDelete = (id) => {
28135
28145
  remove(getIndex(id));
28136
28146
  };
28137
- const processRowUpdate = async (newRow, originalRow) => {
28138
- const original_data = jsonForm({ submitData: originalRow, props: props.parser });
28139
- const data = jsonForm({ submitData: newRow, props: props.parser });
28140
- if (lodash.isEqual(data, original_data))
28141
- return originalRow;
28142
- const index = getIndex(data._id);
28143
- update(index, data);
28144
- return newRow;
28145
- };
28146
- const handleProcessRowUpdateError = () => { };
28147
28147
  const dataGridProps = mergeSettings({
28148
28148
  columns: !detail
28149
28149
  ? [
28150
- ...editColumn({
28151
- displayEdit: true,
28152
- rowModesModel,
28153
- setRowModesModel,
28154
- }),
28155
28150
  {
28156
28151
  field: "delete",
28157
28152
  type: "actions",
@@ -28167,8 +28162,7 @@ const FieldArrayField = (props) => {
28167
28162
  slots: { toolbar: EditToolbar },
28168
28163
  slotProps: {
28169
28164
  toolbar: {
28170
- handleCreate: handleCreate,
28171
- handleDelete: handleDelete,
28165
+ handleClick: handleCreate,
28172
28166
  pageType: props.pageType,
28173
28167
  },
28174
28168
  baseCheckbox: {
@@ -28178,23 +28172,21 @@ const FieldArrayField = (props) => {
28178
28172
  getRowId: (row) => row._id,
28179
28173
  getRowClassName: (params) => params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd",
28180
28174
  density: "compact",
28181
- onRowClick: undefined,
28182
- editMode: "row",
28183
- rowModesModel: rowModesModel,
28184
- onRowModesModelChange: setRowModesModel,
28185
- processRowUpdate: processRowUpdate,
28186
- onProcessRowUpdateError: handleProcessRowUpdateError,
28187
- onRowEditStart: ({ reason }, event) => {
28188
- if (reason === xDataGrid.GridRowEditStartReasons.cellDoubleClick && detail)
28189
- event.defaultMuiPrevented = true;
28190
- },
28191
- onRowEditStop: (params, event) => {
28192
- if (params.reason === xDataGrid.GridRowEditStopReasons.rowFocusOut) {
28193
- event.defaultMuiPrevented = true;
28194
- }
28195
- },
28175
+ onRowClick: props.pageType == "edit" ? handleRowClick : undefined,
28196
28176
  }, props.dataGridProps);
28197
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction: "column", ...props.gridProps, children: [jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(material.Typography, { variant: "body1", fontWeight: "bold", children: props.label }) }), jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(xDataGrid.DataGrid, { ...dataGridProps }) })] }) }));
28177
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MainDrawer, { open: drawer.open, drawerToggle: handleCancel, title: "Trailer", slots: {
28178
+ button: (jsxRuntime.jsx(SaveCancelButton, { slotProps: {
28179
+ saveBtn: { onClick: handleSave, type: "button" },
28180
+ cancelBtn: { onClick: handleCancel },
28181
+ } })),
28182
+ }, ...props.slotProps?.drawer, children: jsxRuntime.jsx(material.Grid, { container: true, size: 12, children: props.fields.map((field, index) => {
28183
+ return (jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction: "column", ...field.gridProps, children: [jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(material.Typography, { variant: "body1", fontWeight: "bold", children: field.label }) }), jsxRuntime.jsx(material.Grid, { size: 12, children: field.type({
28184
+ name: `${props.name}.${drawer.index}.${field.name}`,
28185
+ control: props.form.control,
28186
+ fieldProps: field.fieldProps,
28187
+ extraProps: field.extraProps,
28188
+ }) })] }, `grid-${index}`));
28189
+ }) }) }), jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction: "column", ...props.gridProps, children: [jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(material.Typography, { variant: "body1", fontWeight: "bold", children: props.label }) }), jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(xDataGrid.DataGrid, { ...dataGridProps }) })] })] }));
28198
28190
  };
28199
28191
 
28200
28192
  const Section = (props) => {
@@ -28410,6 +28402,9 @@ function DetailPage(props) {
28410
28402
  resolver: zod$1.zodResolver(props.edit.schema),
28411
28403
  defaultValues: props.edit?.defaultValues,
28412
28404
  });
28405
+ React.useImperativeHandle(props.ref, () => ({
28406
+ form: form,
28407
+ }));
28413
28408
  const { data, isLoading, isFetching, error: fetchError, } = props.api.data.query(!props.api.data.skipToken ? props.api.data.args : query$1.skipToken);
28414
28409
  React.useEffect(() => {
28415
28410
  if (data) {
@@ -28424,7 +28419,7 @@ function DetailPage(props) {
28424
28419
  }
28425
28420
  }
28426
28421
  }, [data, dispatch, form, props.slots?.title]);
28427
- const [mutation, { isLoading: mutationIsLoading, isSuccess, data: mutationResponse }] = props.api.mutate.mutation();
28422
+ const [mutation, { isLoading: mutationIsLoading, isSuccess, data: mutationResponse },] = props.api.mutate.mutation();
28428
28423
  const handleCancel = () => {
28429
28424
  form.reset();
28430
28425
  navigate(-1);
@@ -28434,7 +28429,8 @@ function DetailPage(props) {
28434
28429
  // ==============================|| VALIDATION ||============================== //
28435
28430
  useValidateFieldData(props, form);
28436
28431
  // ==============================|| QUICK RETURN ||============================== //
28437
- if ((!canEdit && props.pageType == "edit") || (fetchError && fetchError.originalStatus == 403))
28432
+ if ((!canEdit && props.pageType == "edit") ||
28433
+ (fetchError && fetchError.originalStatus == 403))
28438
28434
  return jsxRuntime.jsx(NotAllowed, {});
28439
28435
  if (fetchError && fetchError.originalStatus == 404)
28440
28436
  return jsxRuntime.jsx(NotFound, {});
@@ -28442,12 +28438,15 @@ function DetailPage(props) {
28442
28438
  const onSubmitHandler = (submitedData) => {
28443
28439
  const formData = "nativeEvent" in submitedData ? form.getValues() : submitedData;
28444
28440
  const params = {
28441
+ type: props.edit.useFormData ? "formData" : "json",
28445
28442
  submitData: formData,
28446
28443
  data: data,
28447
28444
  props: props.slotProps?.parser,
28448
28445
  };
28449
- const dataToSend = props.edit.useFormData ? formDataForm(params) : jsonForm(params);
28450
- mutation(props.edit.useFormData ? dataToSend : { ...dataToSend, ...props.api.mutate.args })
28446
+ const dataToSend = formParser(params);
28447
+ mutation(props.edit.useFormData
28448
+ ? dataToSend
28449
+ : { ...dataToSend, ...props.api.mutate.args })
28451
28450
  .unwrap()
28452
28451
  .then(() => {
28453
28452
  if (!props.slotProps?.button?.save?.disableNavBack)
@@ -28479,7 +28478,9 @@ function DetailPage(props) {
28479
28478
  if (!section.display)
28480
28479
  return null;
28481
28480
  if (typeof section.display == "object") {
28482
- const validateAgainst = form.watch(section.display.field)?.toString();
28481
+ const validateAgainst = form
28482
+ .watch(section.display.field)
28483
+ ?.toString();
28483
28484
  if (!section.display.method(validateAgainst, section.display.value))
28484
28485
  return null;
28485
28486
  }
@@ -28491,7 +28492,8 @@ function DetailPage(props) {
28491
28492
  if (props.api.mutate.postAction &&
28492
28493
  isSuccess &&
28493
28494
  "post_action" in mutationResponse &&
28494
- mutationResponse["post_action"]["type"] === props.api.mutate.postAction.type) {
28495
+ mutationResponse["post_action"]["type"] ===
28496
+ props.api.mutate.postAction.type) {
28495
28497
  switch (props.api.mutate.postAction.after) {
28496
28498
  // case 'create':
28497
28499
  // if (props.pageType === 'create') return addPropsToNode(props.api.mutate.postAction.node, mutationResponse);
@@ -28839,10 +28841,10 @@ exports.CSVUpload = CSVUpload;
28839
28841
  exports.ContentLayout = ContentLayout;
28840
28842
  exports.ControlledDate = ControlledDate;
28841
28843
  exports.ControlledDropdown = ControlledDropdown;
28844
+ exports.ControlledFileField = ControlledFileField;
28842
28845
  exports.ControlledFileUploadBox = FileUploadBox;
28843
28846
  exports.ControlledNumber = ControlledNumber;
28844
28847
  exports.ControlledPhoneNumber = ControlledPhoneNumber;
28845
- exports.ControlledPhotoField = ControlledPhotoField;
28846
28848
  exports.ControlledSelect = ControlledSelect;
28847
28849
  exports.ControlledSimpleSlider = ControlledSlider;
28848
28850
  exports.ControlledSlider = ControlledSlider$1;
@@ -28866,6 +28868,7 @@ exports.Logo = Logo;
28866
28868
  exports.MainDrawer = MainDrawer;
28867
28869
  exports.MenuItemWithLoading = MenuItemWithLoading;
28868
28870
  exports.ModuleCard = ModuleCard;
28871
+ exports.MoreOptions = MoreOptions;
28869
28872
  exports.MyGridEditSingleSelect = MyGridEditSingleSelect;
28870
28873
  exports.NavigationContext = NavigationContext;
28871
28874
  exports.NavigationProvider = NavigationProvider;
@@ -28885,9 +28888,8 @@ exports.dayjs = dayjs;
28885
28888
  exports.deleteColumn = deleteColumn;
28886
28889
  exports.editColumn = editColumn;
28887
28890
  exports.filterQuery = filterQuery;
28888
- exports.formDataForm = formDataForm;
28891
+ exports.formParser = formParser;
28889
28892
  exports.headerReducer = header;
28890
- exports.jsonForm = jsonForm;
28891
28893
  exports.manualCacheRefresh = manualCacheRefresh;
28892
28894
  exports.mergeSettings = mergeSettings;
28893
28895
  exports.openProgressSnack = openProgressSnack;