frontend-plus-react 0.1.10 → 0.1.12
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 +136 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -18
- package/dist/index.d.ts +19 -18
- package/dist/index.js +122 -74
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1258,8 +1258,10 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1258
1258
|
switch (column.customType) {
|
|
1259
1259
|
case "default": {
|
|
1260
1260
|
const defaultColumn = column;
|
|
1261
|
-
const { fieldDef, tableDefinition, primaryKey,
|
|
1261
|
+
const { fieldDef, tableDefinition, primaryKey, cellFeedbackMap, fixedFields, localCellChanges } = defaultColumn;
|
|
1262
1262
|
const rowId = getPrimaryKeyValues(row, primaryKey);
|
|
1263
|
+
const cellKey = `${rowId}-${props.column.key}`;
|
|
1264
|
+
const currentCellFeedback = cellFeedbackMap.get ? cellFeedbackMap.get(cellKey) : cellFeedbackMap[cellKey];
|
|
1263
1265
|
if (_optionalChain([fieldDef, 'optionalAccess', _6 => _6.clientSide])) {
|
|
1264
1266
|
const ClientSideComponent = clientSides[fieldDef.clientSide];
|
|
1265
1267
|
if (ClientSideComponent) {
|
|
@@ -1268,8 +1270,8 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1268
1270
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FallbackClientSideRenderer_default, { ...props, fieldDefinition: fieldDef, tableDefinition, primaryKey });
|
|
1269
1271
|
}
|
|
1270
1272
|
let cellBackgroundColor = "transparent";
|
|
1271
|
-
if (
|
|
1272
|
-
cellBackgroundColor =
|
|
1273
|
+
if (currentCellFeedback) {
|
|
1274
|
+
cellBackgroundColor = currentCellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1273
1275
|
} else {
|
|
1274
1276
|
const isNewRowLocalCheck = row[NEW_ROW_INDICATOR];
|
|
1275
1277
|
const isMandatory = tableDefinition.primaryKey.includes(props.column.key) || _optionalChain([tableDefinition, 'access', _7 => _7.fields, 'access', _8 => _8.find, 'call', _9 => _9((f) => f.name === props.column.key), 'optionalAccess', _10 => _10.nullable]) === false;
|
|
@@ -1282,7 +1284,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1282
1284
|
}
|
|
1283
1285
|
}
|
|
1284
1286
|
const value = row[props.column.key];
|
|
1285
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title:
|
|
1287
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: _optionalChain([currentCellFeedback, 'optionalAccess', _17 => _17.message]) || "", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { 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__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", sx: { fontSize: "0.875rem", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", width: "100%" }, children: value === null || value === void 0 ? "" : String(value) }) }) });
|
|
1286
1288
|
}
|
|
1287
1289
|
case "detail": {
|
|
1288
1290
|
const detailColumn = column;
|
|
@@ -1366,10 +1368,10 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1366
1368
|
var _InputBase = require('@mui/material/InputBase'); var _InputBase2 = _interopRequireDefault(_InputBase);
|
|
1367
1369
|
|
|
1368
1370
|
|
|
1369
|
-
function findChangedValues(oldRowData, newRowData) {
|
|
1371
|
+
function findChangedValues(oldRowData, newRowData, isNewRow) {
|
|
1370
1372
|
let changes = [];
|
|
1371
1373
|
for (const key in newRowData) {
|
|
1372
|
-
if (Object.prototype.hasOwnProperty.call(oldRowData, key) && oldRowData[key] !== newRowData[key]) {
|
|
1374
|
+
if (Object.prototype.hasOwnProperty.call(oldRowData, key) && oldRowData[key] !== newRowData[key] || isNewRow) {
|
|
1373
1375
|
changes.push(key);
|
|
1374
1376
|
}
|
|
1375
1377
|
}
|
|
@@ -1382,8 +1384,10 @@ function InputRenderer({
|
|
|
1382
1384
|
tableDefinition,
|
|
1383
1385
|
onRowChange,
|
|
1384
1386
|
onClose,
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
+
cellFeedbackMap,
|
|
1388
|
+
// Tipo: CellFeedbackMap
|
|
1389
|
+
setCellFeedbackMap,
|
|
1390
|
+
// Tipo: Dispatch<SetStateAction<CellFeedbackMap>>
|
|
1387
1391
|
onKeyPress,
|
|
1388
1392
|
setTableData,
|
|
1389
1393
|
setLocalCellChanges,
|
|
@@ -1394,10 +1398,11 @@ function InputRenderer({
|
|
|
1394
1398
|
const [editingValue, setEditingValue] = _react.useState.call(void 0, row[column.key]);
|
|
1395
1399
|
const theme = _material.useTheme.call(void 0, );
|
|
1396
1400
|
const { showSuccess, showError } = useSnackbar();
|
|
1397
|
-
const
|
|
1401
|
+
const cellKey = getCellKey(row, column.key, primaryKey);
|
|
1402
|
+
const currentCellFeedback = cellFeedbackMap.get(cellKey);
|
|
1398
1403
|
let cellBackgroundColor;
|
|
1399
|
-
if (
|
|
1400
|
-
cellBackgroundColor =
|
|
1404
|
+
if (currentCellFeedback) {
|
|
1405
|
+
cellBackgroundColor = currentCellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1401
1406
|
}
|
|
1402
1407
|
const initialRowId = _react.useMemo.call(void 0, () => getPrimaryKeyValues(row, primaryKey), [row, primaryKey]);
|
|
1403
1408
|
const { callApi } = useApiCall();
|
|
@@ -1496,7 +1501,6 @@ function InputRenderer({
|
|
|
1496
1501
|
if (rowIndex !== -1) {
|
|
1497
1502
|
newData[rowIndex] = persistedRowData;
|
|
1498
1503
|
} else {
|
|
1499
|
-
console.warn("Fila no encontrada para actualizar despu\xE9s de la inserci\xF3n. Podr\xEDa haber un problema de sincronizaci\xF3n.");
|
|
1500
1504
|
const newPrimaryKeyId = getPrimaryKeyValues(persistedRowData, tableDefinition.primaryKey);
|
|
1501
1505
|
const newRowIndex = newData.findIndex((r) => getPrimaryKeyValues(r, tableDefinition.primaryKey) === newPrimaryKeyId);
|
|
1502
1506
|
if (newRowIndex !== -1) {
|
|
@@ -1512,12 +1516,28 @@ function InputRenderer({
|
|
|
1512
1516
|
finalRowIdForFeedback = isPrimaryKeyColumn ? getPrimaryKeyValues(potentialUpdatedRow, tableDefinition.primaryKey) : currentRowIdBeforeUpdate;
|
|
1513
1517
|
onRowChange({ ...response.row }, true);
|
|
1514
1518
|
}
|
|
1515
|
-
findChangedValues(oldRowData, response.row)
|
|
1516
|
-
|
|
1517
|
-
|
|
1519
|
+
const changes = findChangedValues(oldRowData, response.row, isNewRow);
|
|
1520
|
+
setCellFeedbackMap((prevFeedback) => {
|
|
1521
|
+
const newFeedback = new Map(prevFeedback);
|
|
1522
|
+
changes.forEach((key) => {
|
|
1523
|
+
const keyForMap = `${finalRowIdForFeedback}-${key}`;
|
|
1524
|
+
newFeedback.set(keyForMap, { rowId: finalRowIdForFeedback, columnKey: key, type: "success" });
|
|
1525
|
+
});
|
|
1526
|
+
return newFeedback;
|
|
1527
|
+
});
|
|
1518
1528
|
} catch (err) {
|
|
1519
1529
|
console.error("Error al guardar el registro:", err);
|
|
1520
|
-
|
|
1530
|
+
const keyForMap = `${currentRowIdBeforeUpdate}-${column.key}`;
|
|
1531
|
+
setCellFeedbackMap((prevFeedback) => {
|
|
1532
|
+
const newFeedback = new Map(prevFeedback);
|
|
1533
|
+
newFeedback.set(keyForMap, {
|
|
1534
|
+
rowId: currentRowIdBeforeUpdate,
|
|
1535
|
+
columnKey: column.key,
|
|
1536
|
+
type: "error",
|
|
1537
|
+
message: err.message
|
|
1538
|
+
});
|
|
1539
|
+
return newFeedback;
|
|
1540
|
+
});
|
|
1521
1541
|
}
|
|
1522
1542
|
}, [
|
|
1523
1543
|
column,
|
|
@@ -1528,18 +1548,18 @@ function InputRenderer({
|
|
|
1528
1548
|
tableDefinition.fields,
|
|
1529
1549
|
showSuccess,
|
|
1530
1550
|
showError,
|
|
1531
|
-
|
|
1551
|
+
setCellFeedbackMap,
|
|
1532
1552
|
onClose,
|
|
1533
1553
|
setTableData,
|
|
1534
1554
|
setLocalCellChanges,
|
|
1535
1555
|
localCellChanges,
|
|
1536
1556
|
initialRowId
|
|
1537
1557
|
]);
|
|
1538
|
-
const handleKeyDown = _react.useCallback.call(void 0, (event) => {
|
|
1539
|
-
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"].includes(event.key)) {
|
|
1540
|
-
handleCommit(editingValue, true, true);
|
|
1558
|
+
const handleKeyDown = _react.useCallback.call(void 0, async (event) => {
|
|
1559
|
+
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft", "F4"].includes(event.key)) {
|
|
1560
|
+
await handleCommit(editingValue, true, true);
|
|
1541
1561
|
if (onKeyPress) {
|
|
1542
|
-
onKeyPress(rowIdx, column.key, event);
|
|
1562
|
+
onKeyPress(rowIdx, column.key, event, handleCommit);
|
|
1543
1563
|
}
|
|
1544
1564
|
}
|
|
1545
1565
|
}, [handleCommit, editingValue, column.key, rowIdx, onKeyPress]);
|
|
@@ -1587,8 +1607,10 @@ var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
|
1587
1607
|
fixedFields,
|
|
1588
1608
|
primaryKey,
|
|
1589
1609
|
setTableData,
|
|
1590
|
-
|
|
1591
|
-
|
|
1610
|
+
cellFeedbackMap,
|
|
1611
|
+
// <--- CAMBIADO
|
|
1612
|
+
setCellFeedbackMap,
|
|
1613
|
+
// <--- CAMBIADO
|
|
1592
1614
|
handleKeyPressInEditor,
|
|
1593
1615
|
localCellChanges,
|
|
1594
1616
|
setLocalCellChanges
|
|
@@ -1601,20 +1623,25 @@ var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
|
1601
1623
|
return void 0;
|
|
1602
1624
|
}
|
|
1603
1625
|
const rowId = getPrimaryKeyValues(props.row, primaryKey);
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1626
|
+
const cellKey = `${rowId}-${props.column.key}`;
|
|
1627
|
+
const currentCellFeedback = cellFeedbackMap.get ? cellFeedbackMap.get(cellKey) : cellFeedbackMap[cellKey];
|
|
1628
|
+
return (
|
|
1629
|
+
// --- TOOLTIP ADAPTADO: Lee el mensaje de error desde el Mapa ---
|
|
1630
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: _optionalChain([currentCellFeedback, 'optionalAccess', _30 => _30.message]) || "", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1631
|
+
InputRenderer_default,
|
|
1632
|
+
{
|
|
1633
|
+
...props,
|
|
1634
|
+
tableDefinition,
|
|
1635
|
+
setCellFeedbackMap,
|
|
1636
|
+
cellFeedbackMap,
|
|
1637
|
+
onKeyPress: (rowIndex, columnKey, event, handleCommit) => handleKeyPressInEditor(rowIndex, columnKey, event, allColumns, handleCommit),
|
|
1638
|
+
setTableData,
|
|
1639
|
+
setLocalCellChanges,
|
|
1640
|
+
localCellChanges,
|
|
1641
|
+
primaryKey
|
|
1642
|
+
}
|
|
1643
|
+
) }) })
|
|
1644
|
+
);
|
|
1618
1645
|
}
|
|
1619
1646
|
return void 0;
|
|
1620
1647
|
}
|
|
@@ -1652,16 +1679,20 @@ function EmptyRowsRenderer() {
|
|
|
1652
1679
|
|
|
1653
1680
|
// src/components/grid/GenericDataGrid.tsx
|
|
1654
1681
|
|
|
1682
|
+
var NEW_ROW_INDICATOR = "$new";
|
|
1683
|
+
var DETAIL_ROW_INDICATOR = "$detail";
|
|
1655
1684
|
var getPrimaryKeyValues = (row, primaryKey) => {
|
|
1685
|
+
let keys = [...primaryKey];
|
|
1656
1686
|
if (row[DETAIL_ROW_INDICATOR]) {
|
|
1657
|
-
|
|
1687
|
+
keys = keys.concat(DETAIL_ROW_INDICATOR);
|
|
1658
1688
|
}
|
|
1659
|
-
return
|
|
1689
|
+
return keys.map((key) => {
|
|
1660
1690
|
return row[key] !== void 0 && row[key] !== null ? String(row[key]) : "NULL_OR_UNDEFINED";
|
|
1661
1691
|
}).join("|");
|
|
1662
1692
|
};
|
|
1663
|
-
var
|
|
1664
|
-
|
|
1693
|
+
var getCellKey = (row, columnKey, primaryKey) => {
|
|
1694
|
+
return `${getPrimaryKeyValues(row, primaryKey)}|${columnKey}`;
|
|
1695
|
+
};
|
|
1665
1696
|
var GenericDataGrid = ({
|
|
1666
1697
|
tableName,
|
|
1667
1698
|
fixedFields,
|
|
@@ -1674,7 +1705,7 @@ var GenericDataGrid = ({
|
|
|
1674
1705
|
const [filters, setFilters] = _react.useState.call(void 0, {});
|
|
1675
1706
|
const [selectedRows, setSelectedRows] = _react.useState.call(void 0, () => /* @__PURE__ */ new Set());
|
|
1676
1707
|
const [selectedCell, setSelectedCell] = _react.useState.call(void 0, void 0);
|
|
1677
|
-
const [
|
|
1708
|
+
const [cellFeedbackMap, setCellFeedbackMap] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
1678
1709
|
const [localCellChanges, setLocalCellChanges] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
1679
1710
|
const theme = _material.useTheme.call(void 0, );
|
|
1680
1711
|
const [openConfirmDialog, setOpenConfirmDialog] = _react.useState.call(void 0, false);
|
|
@@ -1692,7 +1723,7 @@ var GenericDataGrid = ({
|
|
|
1692
1723
|
setSelectedRows(/* @__PURE__ */ new Set());
|
|
1693
1724
|
setTableDefinition(null);
|
|
1694
1725
|
setTableData([]);
|
|
1695
|
-
|
|
1726
|
+
setCellFeedbackMap(/* @__PURE__ */ new Map());
|
|
1696
1727
|
setLocalCellChanges(/* @__PURE__ */ new Map());
|
|
1697
1728
|
setOpenConfirmDialog(false);
|
|
1698
1729
|
setRowToDelete(null);
|
|
@@ -1719,20 +1750,26 @@ var GenericDataGrid = ({
|
|
|
1719
1750
|
}
|
|
1720
1751
|
};
|
|
1721
1752
|
fetchDataAndDefinition();
|
|
1722
|
-
}, [
|
|
1723
|
-
tableName,
|
|
1724
|
-
/*fixedFields,*/
|
|
1725
|
-
showError
|
|
1726
|
-
]);
|
|
1753
|
+
}, [tableName, fixedFields, showError]);
|
|
1727
1754
|
_react.useEffect.call(void 0, () => {
|
|
1728
|
-
if (
|
|
1755
|
+
if (cellFeedbackMap.size > 0) {
|
|
1729
1756
|
if (feedbackTimerRef.current) {
|
|
1730
1757
|
clearTimeout(feedbackTimerRef.current);
|
|
1731
1758
|
}
|
|
1732
1759
|
const timerDuration = 3e3;
|
|
1733
1760
|
feedbackTimerRef.current = setTimeout(() => {
|
|
1734
|
-
|
|
1735
|
-
|
|
1761
|
+
setCellFeedbackMap((prevMap) => {
|
|
1762
|
+
const newMap = new Map(prevMap);
|
|
1763
|
+
let mapChanged = false;
|
|
1764
|
+
for (const [cellId, feedback] of prevMap.entries()) {
|
|
1765
|
+
if (feedback.type === "success") {
|
|
1766
|
+
newMap.delete(cellId);
|
|
1767
|
+
mapChanged = true;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return mapChanged ? newMap : prevMap;
|
|
1771
|
+
});
|
|
1772
|
+
feedbackTimerRef.current = null;
|
|
1736
1773
|
}, timerDuration);
|
|
1737
1774
|
}
|
|
1738
1775
|
return () => {
|
|
@@ -1740,7 +1777,7 @@ var GenericDataGrid = ({
|
|
|
1740
1777
|
clearTimeout(feedbackTimerRef.current);
|
|
1741
1778
|
}
|
|
1742
1779
|
};
|
|
1743
|
-
}, [
|
|
1780
|
+
}, [cellFeedbackMap]);
|
|
1744
1781
|
const primaryKey = _react.useMemo.call(void 0, () => {
|
|
1745
1782
|
if (!tableDefinition) return ["id"];
|
|
1746
1783
|
return tableDefinition.primaryKey && tableDefinition.primaryKey.length > 0 ? tableDefinition.primaryKey : ["id"];
|
|
@@ -1881,19 +1918,20 @@ var GenericDataGrid = ({
|
|
|
1881
1918
|
}
|
|
1882
1919
|
return rows;
|
|
1883
1920
|
}, [tableData, filters, isFilterRowVisible]);
|
|
1884
|
-
const handleKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, event, currentColumns) => {
|
|
1921
|
+
const handleKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, event, currentColumns, handleCommit) => {
|
|
1885
1922
|
if (dataGridRef.current && tableDefinition) {
|
|
1886
1923
|
const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
|
|
1887
1924
|
const editableColumns = currentColumns.filter((col) => {
|
|
1888
1925
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1889
1926
|
return col.key !== "actionsColumn" && col.customType != "detail" && (_optionalChain([fieldDefinition, 'optionalAccess', _31 => _31.editable]) !== false && !_optionalChain([fieldDefinition, 'optionalAccess', _32 => _32.clientSide]));
|
|
1890
1927
|
});
|
|
1891
|
-
const { key,
|
|
1892
|
-
const input =
|
|
1928
|
+
const { key, target } = event;
|
|
1929
|
+
const input = target;
|
|
1893
1930
|
if (currentColumnIndex !== -1 && editableColumns.length > 0) {
|
|
1894
1931
|
const editableColumnKeys = editableColumns.map((col) => col.key);
|
|
1895
1932
|
let currentEditableColumnIndex = editableColumnKeys.indexOf(columnKey);
|
|
1896
|
-
const
|
|
1933
|
+
const hacerFoco = ({ rowIdx, idx }) => setTimeout(() => _optionalChain([dataGridRef, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.selectCell, 'call', _35 => _35({ rowIdx, idx }, { enableEditor: true, shouldFocusCell: true })]), 10);
|
|
1934
|
+
const calcularColumnaSiguiente = () => {
|
|
1897
1935
|
let nextEditableColumnIndex = currentEditableColumnIndex + 1;
|
|
1898
1936
|
let nextRowIndex = rowIndex;
|
|
1899
1937
|
if (nextEditableColumnIndex >= editableColumns.length) {
|
|
@@ -1908,9 +1946,9 @@ var GenericDataGrid = ({
|
|
|
1908
1946
|
}
|
|
1909
1947
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1910
1948
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1911
|
-
|
|
1949
|
+
return { rowIdx: nextRowIndex, idx: nextColumnIndex };
|
|
1912
1950
|
};
|
|
1913
|
-
const
|
|
1951
|
+
const calcularColumnaAnterior = () => {
|
|
1914
1952
|
let nextEditableColumnIndex = currentEditableColumnIndex - 1;
|
|
1915
1953
|
let nextRowIndex = rowIndex;
|
|
1916
1954
|
if (nextEditableColumnIndex <= 0) {
|
|
@@ -1918,57 +1956,65 @@ var GenericDataGrid = ({
|
|
|
1918
1956
|
}
|
|
1919
1957
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1920
1958
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1921
|
-
|
|
1959
|
+
return { rowIdx: nextRowIndex, idx: nextColumnIndex };
|
|
1922
1960
|
};
|
|
1923
|
-
const
|
|
1961
|
+
const calcularFilaSiguiente = () => {
|
|
1924
1962
|
let nextRowIndex = rowIndex;
|
|
1925
1963
|
nextRowIndex++;
|
|
1926
1964
|
while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
|
|
1927
1965
|
nextRowIndex++;
|
|
1928
1966
|
}
|
|
1929
1967
|
if (nextRowIndex >= filteredRows.length) {
|
|
1930
|
-
return;
|
|
1968
|
+
return { rowIdx: rowIndex, idx: currentColumnIndex };
|
|
1931
1969
|
}
|
|
1932
|
-
|
|
1970
|
+
return { rowIdx: nextRowIndex, idx: currentColumnIndex };
|
|
1933
1971
|
};
|
|
1934
|
-
const
|
|
1972
|
+
const calcularFilaAnterior = () => {
|
|
1935
1973
|
let nextRowIndex = rowIndex;
|
|
1936
1974
|
nextRowIndex--;
|
|
1937
1975
|
while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
|
|
1938
1976
|
nextRowIndex--;
|
|
1939
1977
|
}
|
|
1940
1978
|
if (nextRowIndex < 0) {
|
|
1941
|
-
return;
|
|
1979
|
+
return { rowIdx: rowIndex, idx: currentColumnIndex };
|
|
1942
1980
|
}
|
|
1943
|
-
|
|
1981
|
+
return { rowIdx: nextRowIndex, idx: currentColumnIndex };
|
|
1944
1982
|
};
|
|
1945
1983
|
if (currentEditableColumnIndex !== -1) {
|
|
1946
1984
|
switch (true) {
|
|
1947
1985
|
case ["Enter", "Tab"].includes(key): {
|
|
1948
|
-
|
|
1986
|
+
hacerFoco(calcularColumnaSiguiente());
|
|
1949
1987
|
break;
|
|
1950
1988
|
}
|
|
1951
1989
|
case key == "ArrowRight": {
|
|
1952
1990
|
const cursorPosition = input.selectionStart;
|
|
1953
1991
|
const inputValueLength = input.value.length;
|
|
1954
1992
|
if (cursorPosition === inputValueLength) {
|
|
1955
|
-
|
|
1993
|
+
hacerFoco(calcularColumnaSiguiente());
|
|
1956
1994
|
}
|
|
1957
1995
|
break;
|
|
1958
1996
|
}
|
|
1959
1997
|
case key == "ArrowLeft": {
|
|
1960
1998
|
const cursorPosition = input.selectionStart;
|
|
1961
1999
|
if (cursorPosition === 0) {
|
|
1962
|
-
|
|
2000
|
+
hacerFoco(calcularColumnaAnterior());
|
|
1963
2001
|
}
|
|
1964
2002
|
break;
|
|
1965
2003
|
}
|
|
1966
2004
|
case key == "ArrowUp": {
|
|
1967
|
-
|
|
2005
|
+
hacerFoco(calcularFilaAnterior());
|
|
1968
2006
|
break;
|
|
1969
2007
|
}
|
|
1970
2008
|
case key == "ArrowDown": {
|
|
1971
|
-
|
|
2009
|
+
hacerFoco(calcularFilaSiguiente());
|
|
2010
|
+
break;
|
|
2011
|
+
}
|
|
2012
|
+
case key == "F4": {
|
|
2013
|
+
const { rowIdx, idx } = calcularFilaSiguiente();
|
|
2014
|
+
const previousRow = tableData[rowIndex - 1];
|
|
2015
|
+
if (previousRow && !previousRow[DETAIL_ROW_INDICATOR]) {
|
|
2016
|
+
handleCommit(previousRow[columnKey], true, true).then(() => hacerFoco({ rowIdx, idx }));
|
|
2017
|
+
}
|
|
1972
2018
|
break;
|
|
1973
2019
|
}
|
|
1974
2020
|
default:
|
|
@@ -1977,31 +2023,32 @@ var GenericDataGrid = ({
|
|
|
1977
2023
|
}
|
|
1978
2024
|
}
|
|
1979
2025
|
}
|
|
1980
|
-
}, [filteredRows, tableDefinition]);
|
|
2026
|
+
}, [filteredRows, tableDefinition, tableData]);
|
|
1981
2027
|
const handleSelectedCellChange = _react.useCallback.call(void 0, (args) => {
|
|
1982
2028
|
setSelectedCell(args);
|
|
1983
2029
|
}, []);
|
|
1984
2030
|
const columns = _react.useMemo.call(void 0, () => {
|
|
1985
2031
|
if (!tableDefinition) return [];
|
|
1986
2032
|
const fieldsToShow = tableDefinition.fields.filter((field) => {
|
|
1987
|
-
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess',
|
|
2033
|
+
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _36 => _36.find, 'call', _37 => _37((f) => f.fieldName === field.name)]);
|
|
1988
2034
|
return !(fixedFieldEntry && fixedFieldEntry.until === void 0);
|
|
1989
2035
|
});
|
|
1990
2036
|
const defaultColumns = fieldsToShow.map((fieldDef) => {
|
|
1991
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
2037
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((f) => f.fieldName === fieldDef.name)]);
|
|
1992
2038
|
const isFieldEditable = fieldDef.editable !== false && !isFixedField;
|
|
1993
2039
|
return {
|
|
1994
2040
|
key: fieldDef.name,
|
|
1995
2041
|
customType: "default",
|
|
1996
2042
|
tableDefinition,
|
|
1997
2043
|
fieldDef,
|
|
1998
|
-
|
|
2044
|
+
// 💥 MULTI-CELL: Se inyecta el mapa y su setter
|
|
2045
|
+
cellFeedbackMap,
|
|
2046
|
+
setCellFeedbackMap,
|
|
1999
2047
|
primaryKey,
|
|
2000
2048
|
fixedFields,
|
|
2001
2049
|
localCellChanges,
|
|
2002
2050
|
setLocalCellChanges,
|
|
2003
2051
|
setTableData,
|
|
2004
|
-
setCellFeedback,
|
|
2005
2052
|
name: fieldDef.label || cambiarGuionesBajosPorEspacios(fieldDef.name),
|
|
2006
2053
|
resizable: true,
|
|
2007
2054
|
sortable: true,
|
|
@@ -2014,9 +2061,9 @@ var GenericDataGrid = ({
|
|
|
2014
2061
|
};
|
|
2015
2062
|
});
|
|
2016
2063
|
const availableActions = [
|
|
2017
|
-
_optionalChain([tableDefinition, 'access',
|
|
2018
|
-
_optionalChain([tableDefinition, 'access',
|
|
2019
|
-
_optionalChain([tableDefinition, 'access',
|
|
2064
|
+
_optionalChain([tableDefinition, 'access', _40 => _40.allow, 'optionalAccess', _41 => _41.insert]),
|
|
2065
|
+
_optionalChain([tableDefinition, 'access', _42 => _42.allow, 'optionalAccess', _43 => _43.delete]),
|
|
2066
|
+
_optionalChain([tableDefinition, 'access', _44 => _44.allow, 'optionalAccess', _45 => _45["vertical-edit"]])
|
|
2020
2067
|
].filter(Boolean).length;
|
|
2021
2068
|
const actionColumnWidth = availableActions === 0 ? 30 : 12 + availableActions * 25;
|
|
2022
2069
|
const actionsColumn = {
|
|
@@ -2083,7 +2130,8 @@ var GenericDataGrid = ({
|
|
|
2083
2130
|
isFilterRowVisible,
|
|
2084
2131
|
filters,
|
|
2085
2132
|
toggleFilterVisibility,
|
|
2086
|
-
|
|
2133
|
+
// 💥 MULTI-CELL: Se usa el mapa en lugar de la variable simple
|
|
2134
|
+
cellFeedbackMap,
|
|
2087
2135
|
primaryKey,
|
|
2088
2136
|
theme.palette.success.light,
|
|
2089
2137
|
theme.palette.error.light,
|
|
@@ -2121,11 +2169,11 @@ var GenericDataGrid = ({
|
|
|
2121
2169
|
event.preventGridDefault();
|
|
2122
2170
|
}, []);
|
|
2123
2171
|
const handleCellClick = _react.useCallback.call(void 0, (args, _event) => {
|
|
2124
|
-
const fieldDefinition = _optionalChain([tableDefinition, 'optionalAccess',
|
|
2125
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
2126
|
-
const isEditable = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
2172
|
+
const fieldDefinition = _optionalChain([tableDefinition, 'optionalAccess', _46 => _46.fields, 'access', _47 => _47.find, 'call', _48 => _48((f) => f.name === args.column.key)]);
|
|
2173
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _49 => _49.some, 'call', _50 => _50((f) => f.fieldName === args.column.key)]);
|
|
2174
|
+
const isEditable = _optionalChain([fieldDefinition, 'optionalAccess', _51 => _51.editable]) !== false && !isFixedField;
|
|
2127
2175
|
if (isEditable) {
|
|
2128
|
-
deselectAllOtherGrids(_optionalChain([dataGridRef, 'access',
|
|
2176
|
+
deselectAllOtherGrids(_optionalChain([dataGridRef, 'access', _52 => _52.current, 'optionalAccess', _53 => _53.element]));
|
|
2129
2177
|
args.selectCell(true);
|
|
2130
2178
|
}
|
|
2131
2179
|
console.log("Clicked column index:", args.column.idx);
|
|
@@ -2746,7 +2794,7 @@ var SessionExpiredMessage_default = SessionExpiredMessage;
|
|
|
2746
2794
|
var HomePage = () => {
|
|
2747
2795
|
const { clientContext } = useApp();
|
|
2748
2796
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 3 }, children: [
|
|
2749
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess',
|
|
2797
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess', _54 => _54.username])}` }),
|
|
2750
2798
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", children: "Usa el men\xFA lateral para navegar por las diferentes secciones." })
|
|
2751
2799
|
] });
|
|
2752
2800
|
};
|
|
@@ -2875,7 +2923,7 @@ var LoginPage = () => {
|
|
|
2875
2923
|
fullWidth: true,
|
|
2876
2924
|
margin: "normal",
|
|
2877
2925
|
error: !!errors.username,
|
|
2878
|
-
helperText: _optionalChain([errors, 'access',
|
|
2926
|
+
helperText: _optionalChain([errors, 'access', _55 => _55.username, 'optionalAccess', _56 => _56.message]),
|
|
2879
2927
|
disabled: isSubmitting
|
|
2880
2928
|
}
|
|
2881
2929
|
)
|
|
@@ -2898,7 +2946,7 @@ var LoginPage = () => {
|
|
|
2898
2946
|
fullWidth: true,
|
|
2899
2947
|
margin: "normal",
|
|
2900
2948
|
error: !!errors.password,
|
|
2901
|
-
helperText: _optionalChain([errors, 'access',
|
|
2949
|
+
helperText: _optionalChain([errors, 'access', _57 => _57.password, 'optionalAccess', _58 => _58.message]),
|
|
2902
2950
|
disabled: isSubmitting
|
|
2903
2951
|
}
|
|
2904
2952
|
)
|
|
@@ -2976,7 +3024,7 @@ var ProcedureForm = () => {
|
|
|
2976
3024
|
const [executionLog, setExecutionLog] = _react.useState.call(void 0, []);
|
|
2977
3025
|
const [procedureResultData, setProcedureResultData] = _react.useState.call(void 0, null);
|
|
2978
3026
|
const procedure = _react.useMemo.call(void 0, () => {
|
|
2979
|
-
if (procedureName && _optionalChain([clientContext, 'optionalAccess',
|
|
3027
|
+
if (procedureName && _optionalChain([clientContext, 'optionalAccess', _59 => _59.procedure])) {
|
|
2980
3028
|
return clientContext.procedure[procedureName];
|
|
2981
3029
|
}
|
|
2982
3030
|
return void 0;
|
|
@@ -3267,7 +3315,7 @@ var ProcedureForm = () => {
|
|
|
3267
3315
|
}
|
|
3268
3316
|
}, [formValues, handleChange, apiLoading, validationErrors]);
|
|
3269
3317
|
const ResultDisplayContent = _react.useMemo.call(void 0, () => {
|
|
3270
|
-
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess',
|
|
3318
|
+
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess', _60 => _60.resultOk])) return null;
|
|
3271
3319
|
const ComponentToRender = resultsOk[procedure.resultOk];
|
|
3272
3320
|
if (ComponentToRender) {
|
|
3273
3321
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentToRender, { data: procedureResultData });
|