frontend-plus-react 0.1.4 → 0.1.5
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.cjs +154 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +142 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -622,7 +622,7 @@ var SnackbarAlert = React.forwardRef(function SnackbarAlert2(props, ref) {
|
|
|
622
622
|
});
|
|
623
623
|
var SnackbarContext = createContext(void 0);
|
|
624
624
|
var DEFAULT_SUCCESS_DURATION = 3e3;
|
|
625
|
-
var DEFAULT_ERROR_DURATION =
|
|
625
|
+
var DEFAULT_ERROR_DURATION = 1e4;
|
|
626
626
|
var SnackbarProvider = ({ children }) => {
|
|
627
627
|
const [snackbar, setSnackbar] = useState({
|
|
628
628
|
open: false,
|
|
@@ -757,9 +757,12 @@ var useApiCall = () => {
|
|
|
757
757
|
const { showSnackbar } = useSnackbar();
|
|
758
758
|
const [loading, setLoading] = useState2(false);
|
|
759
759
|
const [error, setError] = useState2(null);
|
|
760
|
-
const callApi = useCallback2(async (procedureName, params) => {
|
|
760
|
+
const callApi = useCallback2(async (procedureName, params, opts) => {
|
|
761
761
|
setLoading(true);
|
|
762
762
|
setError(null);
|
|
763
|
+
const defaultOpts = { ...{
|
|
764
|
+
reportOnSnackbar: true
|
|
765
|
+
}, ...opts };
|
|
763
766
|
try {
|
|
764
767
|
const result = await executeBackendProcedure(procedureName, params);
|
|
765
768
|
return result === null ? void 0 : result;
|
|
@@ -771,7 +774,9 @@ var useApiCall = () => {
|
|
|
771
774
|
} else if (err instanceof Error) {
|
|
772
775
|
snackbarMessage = err.message;
|
|
773
776
|
}
|
|
774
|
-
|
|
777
|
+
if (defaultOpts.reportOnSnackbar) {
|
|
778
|
+
showSnackbar(snackbarMessage, "error");
|
|
779
|
+
}
|
|
775
780
|
throw err;
|
|
776
781
|
} finally {
|
|
777
782
|
setLoading(false);
|
|
@@ -781,14 +786,7 @@ var useApiCall = () => {
|
|
|
781
786
|
};
|
|
782
787
|
|
|
783
788
|
// src/components/grid/GenericDataGrid.tsx
|
|
784
|
-
import {
|
|
785
|
-
CircularProgress,
|
|
786
|
-
Typography as Typography5,
|
|
787
|
-
Box as Box5,
|
|
788
|
-
Alert,
|
|
789
|
-
useTheme as useTheme2,
|
|
790
|
-
Button as Button3
|
|
791
|
-
} from "@mui/material";
|
|
789
|
+
import { CircularProgress, Typography as Typography5, Box as Box5, Alert, useTheme as useTheme3, Button as Button3 } from "@mui/material";
|
|
792
790
|
|
|
793
791
|
// src/utils/functions.tsx
|
|
794
792
|
var JSON4all = __toESM(require_json4all(), 1);
|
|
@@ -1145,7 +1143,6 @@ import { Box as Box3, Typography as Typography3, Tooltip as Tooltip2 } from "@mu
|
|
|
1145
1143
|
import WarningAmberIcon from "@mui/icons-material/WarningAmber";
|
|
1146
1144
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1147
1145
|
var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
1148
|
-
const value = row[column.key];
|
|
1149
1146
|
const clientSideName = fieldDefinition?.clientSide || "Desconocido";
|
|
1150
1147
|
return /* @__PURE__ */ jsx7(Tooltip2, { title: `Componente clientSide '${clientSideName}' no implementado. Mostrando valor por defecto.`, children: /* @__PURE__ */ jsxs3(
|
|
1151
1148
|
Box3,
|
|
@@ -1168,7 +1165,7 @@ var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
|
1168
1165
|
// Evita que el contenido se desborde
|
|
1169
1166
|
},
|
|
1170
1167
|
children: [
|
|
1171
|
-
/* @__PURE__ */ jsx7(Typography3, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children:
|
|
1168
|
+
/* @__PURE__ */ jsx7(Typography3, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children: clientSideName + " not found" }),
|
|
1172
1169
|
/* @__PURE__ */ jsx7(
|
|
1173
1170
|
WarningAmberIcon,
|
|
1174
1171
|
{
|
|
@@ -1217,15 +1214,25 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1217
1214
|
fixedFields.push({ fieldName: field.target, value: row[field.source] });
|
|
1218
1215
|
}
|
|
1219
1216
|
});
|
|
1220
|
-
return /* @__PURE__ */ jsx8(
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1217
|
+
return /* @__PURE__ */ jsx8(
|
|
1218
|
+
Box4,
|
|
1219
|
+
{
|
|
1220
|
+
sx: {
|
|
1221
|
+
// Se eliminó el padding para que la sub-grilla se extienda por completo
|
|
1222
|
+
minHeight: "200px",
|
|
1223
|
+
width: "100%",
|
|
1224
|
+
height: "100%",
|
|
1225
|
+
//display: 'flex',
|
|
1226
|
+
//flexDirection: 'column',
|
|
1227
|
+
boxSizing: "border-box"
|
|
1228
|
+
},
|
|
1229
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1230
|
+
onClick: (e) => e.stopPropagation(),
|
|
1231
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1232
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
1233
|
+
children: /* @__PURE__ */ jsx8(GenericDataGrid_default, { tableName: detailTable.table, fixedFields })
|
|
1234
|
+
}
|
|
1235
|
+
);
|
|
1229
1236
|
}
|
|
1230
1237
|
return void 0;
|
|
1231
1238
|
}
|
|
@@ -1256,7 +1263,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1256
1263
|
}
|
|
1257
1264
|
}
|
|
1258
1265
|
const value = row[props.column.key];
|
|
1259
|
-
return /* @__PURE__ */ jsx8(Box4, { sx: { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", backgroundColor: cellBackgroundColor, transition: "background-color 0.3s ease-in-out", display: "flex", alignItems: "center", paddingLeft: "8px", boxSizing: "border-box" }, children: /* @__PURE__ */ jsx8(Typography4, { variant: "body2", sx: { fontSize: "0.875rem", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", width: "100%" }, children: value === null || value === void 0 ? "" : String(value) }) });
|
|
1266
|
+
return /* @__PURE__ */ jsx8(Tooltip3, { title: cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === props.column.key ? cellFeedback?.message : "", children: /* @__PURE__ */ jsx8(Box4, { sx: { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", backgroundColor: cellBackgroundColor, transition: "background-color 0.3s ease-in-out", display: "flex", alignItems: "center", paddingLeft: "8px", boxSizing: "border-box" }, children: /* @__PURE__ */ jsx8(Typography4, { variant: "body2", sx: { fontSize: "0.875rem", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", width: "100%" }, children: value === null || value === void 0 ? "" : String(value) }) }) });
|
|
1260
1267
|
}
|
|
1261
1268
|
case "detail": {
|
|
1262
1269
|
const detailColumn = column;
|
|
@@ -1305,7 +1312,17 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1305
1312
|
// src/components/grid/InputRenderer.tsx
|
|
1306
1313
|
import { useCallback as useCallback3, useMemo, useState as useState3 } from "react";
|
|
1307
1314
|
import InputBase2 from "@mui/material/InputBase";
|
|
1315
|
+
import { useTheme as useTheme2 } from "@mui/material";
|
|
1308
1316
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1317
|
+
function findChangedValues(oldRowData, newRowData) {
|
|
1318
|
+
let changes = [];
|
|
1319
|
+
for (const key in newRowData) {
|
|
1320
|
+
if (Object.prototype.hasOwnProperty.call(oldRowData, key) && oldRowData[key] !== newRowData[key]) {
|
|
1321
|
+
changes.push(key);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
return changes;
|
|
1325
|
+
}
|
|
1309
1326
|
function InputRenderer({
|
|
1310
1327
|
column,
|
|
1311
1328
|
row,
|
|
@@ -1313,6 +1330,7 @@ function InputRenderer({
|
|
|
1313
1330
|
tableDefinition,
|
|
1314
1331
|
onRowChange,
|
|
1315
1332
|
onClose,
|
|
1333
|
+
cellFeedback,
|
|
1316
1334
|
setCellFeedback,
|
|
1317
1335
|
onEnterPress,
|
|
1318
1336
|
setTableData,
|
|
@@ -1322,7 +1340,13 @@ function InputRenderer({
|
|
|
1322
1340
|
}) {
|
|
1323
1341
|
const tableName = tableDefinition.tableName;
|
|
1324
1342
|
const [editingValue, setEditingValue] = useState3(row[column.key]);
|
|
1343
|
+
const theme = useTheme2();
|
|
1325
1344
|
const { showSuccess, showError } = useSnackbar();
|
|
1345
|
+
const rowId = getPrimaryKeyValues(row, primaryKey);
|
|
1346
|
+
let cellBackgroundColor;
|
|
1347
|
+
if (cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === column.key) {
|
|
1348
|
+
cellBackgroundColor = cellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1349
|
+
}
|
|
1326
1350
|
const initialRowId = useMemo(() => getPrimaryKeyValues(row, primaryKey), [row, primaryKey]);
|
|
1327
1351
|
const { callApi } = useApiCall();
|
|
1328
1352
|
const handleCommit = useCallback3(async (currentValue, closeEditor, focusNextCell) => {
|
|
@@ -1336,27 +1360,12 @@ function InputRenderer({
|
|
|
1336
1360
|
const isMandatoryFieldEmpty = isNewRow && isMandatoryField && (processedNewValue === null || processedNewValue === void 0 || String(processedNewValue).trim() === "");
|
|
1337
1361
|
if (processedNewValue === row[column.key] && !isNewRow && !isMandatoryFieldEmpty) {
|
|
1338
1362
|
console.log("No se guard\xF3: el valor no cambi\xF3 (y no es una nueva fila o campo obligatorio vac\xEDo que se est\xE1 iniciando).");
|
|
1339
|
-
onClose(false, focusNextCell);
|
|
1340
|
-
setLocalCellChanges((prev) => {
|
|
1341
|
-
const newMap = new Map(prev);
|
|
1342
|
-
const columnKeys = newMap.get(initialRowId);
|
|
1343
|
-
if (columnKeys) {
|
|
1344
|
-
columnKeys.delete(column.key);
|
|
1345
|
-
if (columnKeys.size === 0) {
|
|
1346
|
-
newMap.delete(initialRowId);
|
|
1347
|
-
} else {
|
|
1348
|
-
newMap.set(initialRowId, columnKeys);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
return newMap;
|
|
1352
|
-
});
|
|
1353
1363
|
return;
|
|
1354
1364
|
}
|
|
1355
1365
|
const oldRowData = { ...row };
|
|
1356
1366
|
const primaryKeyValuesForBackend = tableDefinition.primaryKey.map((key) => potentialUpdatedRow[key]);
|
|
1357
1367
|
const currentRowIdBeforeUpdate = getPrimaryKeyValues(oldRowData, tableDefinition.primaryKey);
|
|
1358
1368
|
onRowChange({ ...row, [column.key]: processedNewValue }, true);
|
|
1359
|
-
onClose(true, focusNextCell);
|
|
1360
1369
|
if (isNewRow) {
|
|
1361
1370
|
const areAllMandatoryFieldsFilled = tableDefinition.fields.every((fieldDef) => {
|
|
1362
1371
|
const isMandatory = fieldDef.nullable === false || fieldDef.isPk;
|
|
@@ -1423,21 +1432,7 @@ function InputRenderer({
|
|
|
1423
1432
|
newRow: rowToSend,
|
|
1424
1433
|
oldRow: oldRowData,
|
|
1425
1434
|
status
|
|
1426
|
-
});
|
|
1427
|
-
setLocalCellChanges((prev) => {
|
|
1428
|
-
const newMap = new Map(prev);
|
|
1429
|
-
const columnKeys = newMap.get(initialRowId);
|
|
1430
|
-
if (columnKeys) {
|
|
1431
|
-
columnKeys.delete(column.key);
|
|
1432
|
-
if (columnKeys.size === 0) {
|
|
1433
|
-
newMap.delete(initialRowId);
|
|
1434
|
-
} else {
|
|
1435
|
-
newMap.set(initialRowId, columnKeys);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
return newMap;
|
|
1439
|
-
});
|
|
1440
|
-
showSuccess("Registro guardado exitosamente!");
|
|
1435
|
+
}, { reportOnSnackbar: false });
|
|
1441
1436
|
let finalRowIdForFeedback;
|
|
1442
1437
|
let persistedRowData;
|
|
1443
1438
|
if (response.row && isNewRow) {
|
|
@@ -1460,15 +1455,18 @@ function InputRenderer({
|
|
|
1460
1455
|
});
|
|
1461
1456
|
finalRowIdForFeedback = getPrimaryKeyValues(persistedRowData, tableDefinition.primaryKey);
|
|
1462
1457
|
} else {
|
|
1463
|
-
persistedRowData =
|
|
1458
|
+
persistedRowData = response.row;
|
|
1464
1459
|
const isPrimaryKeyColumn = tableDefinition.primaryKey.includes(column.key);
|
|
1465
1460
|
finalRowIdForFeedback = isPrimaryKeyColumn ? getPrimaryKeyValues(potentialUpdatedRow, tableDefinition.primaryKey) : currentRowIdBeforeUpdate;
|
|
1461
|
+
onRowChange({ ...response.row }, true);
|
|
1462
|
+
onClose(true, focusNextCell);
|
|
1466
1463
|
}
|
|
1467
|
-
|
|
1464
|
+
findChangedValues(oldRowData, response.row).forEach(
|
|
1465
|
+
(key) => setCellFeedback({ rowId: finalRowIdForFeedback, columnKey: key, type: "success" })
|
|
1466
|
+
);
|
|
1468
1467
|
} catch (err) {
|
|
1469
1468
|
console.error("Error al guardar el registro:", err);
|
|
1470
|
-
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error" });
|
|
1471
|
-
onRowChange(oldRowData, true);
|
|
1469
|
+
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error", message: err.message });
|
|
1472
1470
|
}
|
|
1473
1471
|
}, [
|
|
1474
1472
|
column,
|
|
@@ -1487,6 +1485,7 @@ function InputRenderer({
|
|
|
1487
1485
|
initialRowId
|
|
1488
1486
|
]);
|
|
1489
1487
|
const handleKeyDown = useCallback3((event) => {
|
|
1488
|
+
console.log("entra");
|
|
1490
1489
|
if (event.key === "Enter") {
|
|
1491
1490
|
handleCommit(editingValue, true, true);
|
|
1492
1491
|
event.preventDefault();
|
|
@@ -1517,7 +1516,8 @@ function InputRenderer({
|
|
|
1517
1516
|
borderRadius: "4px",
|
|
1518
1517
|
padding: "2px 4px",
|
|
1519
1518
|
fontSize: "0.8rem",
|
|
1520
|
-
boxSizing: "border-box"
|
|
1519
|
+
boxSizing: "border-box",
|
|
1520
|
+
backgroundColor: cellBackgroundColor
|
|
1521
1521
|
},
|
|
1522
1522
|
onClick: (e) => e.stopPropagation(),
|
|
1523
1523
|
autoFocus: true,
|
|
@@ -1529,28 +1529,54 @@ var InputRenderer_default = InputRenderer;
|
|
|
1529
1529
|
|
|
1530
1530
|
// src/components/grid/renderers/editCellRenderers.tsx
|
|
1531
1531
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1532
|
-
var
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
if (!isFieldEditableByUI) {
|
|
1539
|
-
return void 0;
|
|
1540
|
-
}
|
|
1541
|
-
return /* @__PURE__ */ jsx10(
|
|
1542
|
-
InputRenderer_default,
|
|
1543
|
-
{
|
|
1544
|
-
...props,
|
|
1532
|
+
var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
1533
|
+
const column = props.column;
|
|
1534
|
+
switch (column.customType) {
|
|
1535
|
+
case "default": {
|
|
1536
|
+
const defaultColumn = column;
|
|
1537
|
+
const {
|
|
1545
1538
|
tableDefinition,
|
|
1546
|
-
|
|
1547
|
-
|
|
1539
|
+
fixedFields,
|
|
1540
|
+
primaryKey,
|
|
1548
1541
|
setTableData,
|
|
1549
|
-
|
|
1542
|
+
cellFeedback,
|
|
1543
|
+
setCellFeedback,
|
|
1544
|
+
handleEnterKeyPressInEditor,
|
|
1550
1545
|
localCellChanges,
|
|
1551
|
-
|
|
1546
|
+
setLocalCellChanges
|
|
1547
|
+
} = defaultColumn;
|
|
1548
|
+
if (column.editable) {
|
|
1549
|
+
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1550
|
+
const isFixedField = fixedFields?.some((f) => f.fieldName === column.key);
|
|
1551
|
+
const isFieldEditableByUI = fieldDefinition?.editable !== false && !isFixedField;
|
|
1552
|
+
if (!isFieldEditableByUI) {
|
|
1553
|
+
return void 0;
|
|
1554
|
+
}
|
|
1555
|
+
return /* @__PURE__ */ jsx10(
|
|
1556
|
+
InputRenderer_default,
|
|
1557
|
+
{
|
|
1558
|
+
...props,
|
|
1559
|
+
tableDefinition,
|
|
1560
|
+
setCellFeedback,
|
|
1561
|
+
cellFeedback,
|
|
1562
|
+
onEnterPress: (rowIndex, columnKey) => handleEnterKeyPressInEditor(rowIndex, columnKey, allColumns),
|
|
1563
|
+
setTableData,
|
|
1564
|
+
setLocalCellChanges,
|
|
1565
|
+
localCellChanges,
|
|
1566
|
+
primaryKey
|
|
1567
|
+
}
|
|
1568
|
+
);
|
|
1552
1569
|
}
|
|
1553
|
-
|
|
1570
|
+
return void 0;
|
|
1571
|
+
}
|
|
1572
|
+
case "detail": {
|
|
1573
|
+
return void 0;
|
|
1574
|
+
}
|
|
1575
|
+
case "action": {
|
|
1576
|
+
return void 0;
|
|
1577
|
+
}
|
|
1578
|
+
default:
|
|
1579
|
+
return void 0;
|
|
1554
1580
|
}
|
|
1555
1581
|
};
|
|
1556
1582
|
|
|
@@ -1578,7 +1604,10 @@ function EmptyRowsRenderer() {
|
|
|
1578
1604
|
// src/components/grid/GenericDataGrid.tsx
|
|
1579
1605
|
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1580
1606
|
var getPrimaryKeyValues = (row, primaryKey) => {
|
|
1581
|
-
|
|
1607
|
+
if (row[DETAIL_ROW_INDICATOR]) {
|
|
1608
|
+
primaryKey = primaryKey.concat(DETAIL_ROW_INDICATOR);
|
|
1609
|
+
}
|
|
1610
|
+
return primaryKey.map((key) => {
|
|
1582
1611
|
return row[key] !== void 0 && row[key] !== null ? String(row[key]) : "NULL_OR_UNDEFINED";
|
|
1583
1612
|
}).join("|");
|
|
1584
1613
|
};
|
|
@@ -1593,9 +1622,10 @@ var GenericDataGrid = ({
|
|
|
1593
1622
|
const [isFilterRowVisible, setIsFilterRowVisible] = useState4(false);
|
|
1594
1623
|
const [filters, setFilters] = useState4({});
|
|
1595
1624
|
const [selectedRows, setSelectedRows] = useState4(() => /* @__PURE__ */ new Set());
|
|
1625
|
+
const [selectedCell, setSelectedCell] = useState4(void 0);
|
|
1596
1626
|
const [cellFeedback, setCellFeedback] = useState4(null);
|
|
1597
1627
|
const [localCellChanges, setLocalCellChanges] = useState4(/* @__PURE__ */ new Map());
|
|
1598
|
-
const theme =
|
|
1628
|
+
const theme = useTheme3();
|
|
1599
1629
|
const [openConfirmDialog, setOpenConfirmDialog] = useState4(false);
|
|
1600
1630
|
const [rowToDelete, setRowToDelete] = useState4(null);
|
|
1601
1631
|
const [exitingRowIds, setExitingRowIds] = useState4(/* @__PURE__ */ new Set());
|
|
@@ -1638,7 +1668,11 @@ var GenericDataGrid = ({
|
|
|
1638
1668
|
}
|
|
1639
1669
|
};
|
|
1640
1670
|
fetchDataAndDefinition();
|
|
1641
|
-
}, [
|
|
1671
|
+
}, [
|
|
1672
|
+
tableName,
|
|
1673
|
+
/*fixedFields,*/
|
|
1674
|
+
showError
|
|
1675
|
+
]);
|
|
1642
1676
|
useEffect(() => {
|
|
1643
1677
|
if (cellFeedback) {
|
|
1644
1678
|
if (feedbackTimerRef.current) {
|
|
@@ -1646,7 +1680,8 @@ var GenericDataGrid = ({
|
|
|
1646
1680
|
}
|
|
1647
1681
|
const timerDuration = 3e3;
|
|
1648
1682
|
feedbackTimerRef.current = setTimeout(() => {
|
|
1649
|
-
|
|
1683
|
+
if (cellFeedback.type == "success")
|
|
1684
|
+
setCellFeedback(null);
|
|
1650
1685
|
}, timerDuration);
|
|
1651
1686
|
}
|
|
1652
1687
|
return () => {
|
|
@@ -1817,11 +1852,14 @@ var GenericDataGrid = ({
|
|
|
1817
1852
|
}
|
|
1818
1853
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1819
1854
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1820
|
-
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor:
|
|
1855
|
+
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1821
1856
|
}
|
|
1822
1857
|
}
|
|
1823
1858
|
}
|
|
1824
1859
|
}, [filteredRows, tableDefinition]);
|
|
1860
|
+
const handleSelectedCellChange = useCallback4((args) => {
|
|
1861
|
+
setSelectedCell(args);
|
|
1862
|
+
}, []);
|
|
1825
1863
|
const columns = useMemo2(() => {
|
|
1826
1864
|
if (!tableDefinition) return [];
|
|
1827
1865
|
const fieldsToShow = tableDefinition.fields.filter((field) => {
|
|
@@ -1840,11 +1878,14 @@ var GenericDataGrid = ({
|
|
|
1840
1878
|
primaryKey,
|
|
1841
1879
|
fixedFields,
|
|
1842
1880
|
localCellChanges,
|
|
1881
|
+
setLocalCellChanges,
|
|
1882
|
+
setTableData,
|
|
1883
|
+
setCellFeedback,
|
|
1843
1884
|
name: fieldDef.label || cambiarGuionesBajosPorEspacios(fieldDef.name),
|
|
1844
1885
|
resizable: true,
|
|
1845
1886
|
sortable: true,
|
|
1846
|
-
//frozen: true,
|
|
1847
1887
|
editable: isFieldEditable,
|
|
1888
|
+
handleEnterKeyPressInEditor,
|
|
1848
1889
|
flexGrow: 1,
|
|
1849
1890
|
minWidth: 60,
|
|
1850
1891
|
renderHeaderCell: (props) => defaultColumnHeaderCellRenderer(props, fieldDef),
|
|
@@ -1858,9 +1899,9 @@ var GenericDataGrid = ({
|
|
|
1858
1899
|
handleDeleteRow,
|
|
1859
1900
|
name: "filterCol",
|
|
1860
1901
|
width: 50,
|
|
1902
|
+
editable: false,
|
|
1861
1903
|
resizable: false,
|
|
1862
1904
|
sortable: false,
|
|
1863
|
-
//frozen: true,
|
|
1864
1905
|
renderHeaderCell: (props) => actionsColumnHeaderCellRenderer(props, isFilterRowVisible, toggleFilterVisibility),
|
|
1865
1906
|
renderSummaryCell: (props) => actionsColumnSummaryCellRenderer(props)
|
|
1866
1907
|
};
|
|
@@ -1880,8 +1921,8 @@ var GenericDataGrid = ({
|
|
|
1880
1921
|
name: detailTable.label || `Detalle ${detailTable.abr}`,
|
|
1881
1922
|
resizable: false,
|
|
1882
1923
|
sortable: false,
|
|
1924
|
+
editable: false,
|
|
1883
1925
|
width: 50,
|
|
1884
|
-
//frozen: true,
|
|
1885
1926
|
renderHeaderCell: (props) => detailColumnCellHeaderRenderer(props, detailTable),
|
|
1886
1927
|
renderSummaryCell: (props) => detailColumnCellSummaryRenderer(props)
|
|
1887
1928
|
});
|
|
@@ -1903,7 +1944,7 @@ var GenericDataGrid = ({
|
|
|
1903
1944
|
}
|
|
1904
1945
|
return void 0;
|
|
1905
1946
|
},
|
|
1906
|
-
renderEditCell: (props) =>
|
|
1947
|
+
renderEditCell: (props) => allColumnsEditCellRenderer(props, allColumns),
|
|
1907
1948
|
renderCell: (props) => allColumnsCellRenderer(props)
|
|
1908
1949
|
}));
|
|
1909
1950
|
}, [
|
|
@@ -1927,7 +1968,18 @@ var GenericDataGrid = ({
|
|
|
1927
1968
|
const handleRowsChange = useCallback4((updatedRows) => {
|
|
1928
1969
|
setTableData(updatedRows);
|
|
1929
1970
|
}, []);
|
|
1971
|
+
const deselectAllOtherGrids = (currentGridElement) => {
|
|
1972
|
+
const allSelectedCells = document.querySelectorAll("div[aria-selected='true']");
|
|
1973
|
+
allSelectedCells.forEach((cell) => {
|
|
1974
|
+
const parentGrid = cell.closest(".rdg");
|
|
1975
|
+
if (parentGrid && parentGrid !== currentGridElement) {
|
|
1976
|
+
cell.setAttribute("aria-selected", "false");
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
};
|
|
1930
1980
|
const handleCellClick = useCallback4((args) => {
|
|
1981
|
+
deselectAllOtherGrids(dataGridRef.current?.element);
|
|
1982
|
+
args.selectCell(true);
|
|
1931
1983
|
const fieldDefinition = tableDefinition?.fields.find((f) => f.name === args.column.key);
|
|
1932
1984
|
const isFixedField = fixedFields?.some((f) => f.fieldName === args.column.key);
|
|
1933
1985
|
const isEditable = fieldDefinition?.editable !== false && !isFixedField;
|
|
@@ -2003,6 +2055,7 @@ var GenericDataGrid = ({
|
|
|
2003
2055
|
enableVirtualization: true,
|
|
2004
2056
|
rowKeyGetter: (row) => getPrimaryKeyValues(row, primaryKey),
|
|
2005
2057
|
onSelectedRowsChange: setSelectedRows,
|
|
2058
|
+
onSelectedCellChange: handleSelectedCellChange,
|
|
2006
2059
|
onRowsChange: handleRowsChange,
|
|
2007
2060
|
selectedRows,
|
|
2008
2061
|
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 : 35,
|
|
@@ -2010,8 +2063,8 @@ var GenericDataGrid = ({
|
|
|
2010
2063
|
headerRowHeight: 35,
|
|
2011
2064
|
topSummaryRows: isFilterRowVisible ? [{ id: "filterRow" }] : void 0,
|
|
2012
2065
|
summaryRowHeight: isFilterRowVisible ? 35 : 0,
|
|
2013
|
-
|
|
2014
|
-
|
|
2066
|
+
renderers: { noRowsFallback: /* @__PURE__ */ jsx12(EmptyRowsRenderer, {}) },
|
|
2067
|
+
onCellClick: handleCellClick
|
|
2015
2068
|
}
|
|
2016
2069
|
)
|
|
2017
2070
|
}
|
|
@@ -2045,7 +2098,7 @@ import {
|
|
|
2045
2098
|
Drawer,
|
|
2046
2099
|
CssBaseline,
|
|
2047
2100
|
IconButton as IconButton3,
|
|
2048
|
-
useTheme as
|
|
2101
|
+
useTheme as useTheme4,
|
|
2049
2102
|
useMediaQuery
|
|
2050
2103
|
} from "@mui/material";
|
|
2051
2104
|
|
|
@@ -2351,7 +2404,7 @@ var MainLayout = () => {
|
|
|
2351
2404
|
const logout = useLogout_default();
|
|
2352
2405
|
const isDrawerOpen = useIsDrawerOpen();
|
|
2353
2406
|
const dispatch = useAppDispatch();
|
|
2354
|
-
const theme =
|
|
2407
|
+
const theme = useTheme4();
|
|
2355
2408
|
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
|
2356
2409
|
useEffect3(() => {
|
|
2357
2410
|
if (isMobile && isDrawerOpen) {
|