componentes-sinco 1.3.5 → 1.3.6
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 +14 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5420,7 +5420,7 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5420
5420
|
const [insertRowValues, setInsertRowValues] = (0, import_react51.useState)({});
|
|
5421
5421
|
const INSERT_ROW_ID = "__sc-datagrid-insert-row__";
|
|
5422
5422
|
const resolvedGetRowId = (row) => (row == null ? void 0 : row.__isInsertRow) ? INSERT_ROW_ID : getRowId ? getRowId(row) : row.id;
|
|
5423
|
-
const pinnedRows = showInsertRow ? { bottom: [{ __isInsertRow: true }] } : void 0;
|
|
5423
|
+
const pinnedRows = showInsertRow ? { bottom: [__spreadValues({ __isInsertRow: true }, insertRowValues)] } : void 0;
|
|
5424
5424
|
const normalizedInsertRowFields = (insertRowFields && insertRowFields.length > 0 ? insertRowFields : [(_a = columns[0]) == null ? void 0 : _a.field]).map((item) => typeof item === "string" ? { field: item } : item);
|
|
5425
5425
|
const insertRowTargetFields = normalizedInsertRowFields.map((item) => item.field);
|
|
5426
5426
|
const isInsertRowValueFilled = (value) => value !== void 0 && value !== null && (typeof value !== "string" || value.trim() !== "");
|
|
@@ -5437,6 +5437,10 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5437
5437
|
setInsertRowValues({});
|
|
5438
5438
|
onAddRow && onAddRow(newRow);
|
|
5439
5439
|
};
|
|
5440
|
+
const hasInsertRowValueRef = (0, import_react51.useRef)(hasInsertRowValue);
|
|
5441
|
+
hasInsertRowValueRef.current = hasInsertRowValue;
|
|
5442
|
+
const handleAddInsertRowRef = (0, import_react51.useRef)(handleAddInsertRow);
|
|
5443
|
+
handleAddInsertRowRef.current = handleAddInsertRow;
|
|
5440
5444
|
(0, import_react51.useEffect)(() => {
|
|
5441
5445
|
var _a2;
|
|
5442
5446
|
if (setSelectedRow) {
|
|
@@ -5510,11 +5514,12 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5510
5514
|
}
|
|
5511
5515
|
}
|
|
5512
5516
|
};
|
|
5513
|
-
const processedColumns = columns.map((col, index) => {
|
|
5517
|
+
const processedColumns = import_react51.default.useMemo(() => columns.map((col, index) => {
|
|
5514
5518
|
const baseCol = col.width !== void 0 || col.flex !== void 0 ? col : __spreadProps(__spreadValues({}, col), { flex: 1 });
|
|
5515
5519
|
if (!showInsertRow) return baseCol;
|
|
5516
5520
|
const isLastColumn = index === columns.length - 1;
|
|
5517
5521
|
const isInputField = !isLastColumn && insertRowTargetFields.includes(baseCol.field);
|
|
5522
|
+
const fieldConfig = normalizedInsertRowFields.find((item) => item.field === baseCol.field);
|
|
5518
5523
|
const originalRenderCell = baseCol.renderCell;
|
|
5519
5524
|
return __spreadProps(__spreadValues({}, baseCol), {
|
|
5520
5525
|
renderCell: (params) => {
|
|
@@ -5522,11 +5527,10 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5522
5527
|
return originalRenderCell ? originalRenderCell(params) : params.formattedValue;
|
|
5523
5528
|
}
|
|
5524
5529
|
if (isInputField) {
|
|
5525
|
-
const fieldConfig = normalizedInsertRowFields.find((item) => item.field === baseCol.field);
|
|
5526
5530
|
const setFieldValue = (newValue) => setInsertRowValues((prev) => __spreadProps(__spreadValues({}, prev), { [baseCol.field]: newValue }));
|
|
5527
5531
|
if (fieldConfig == null ? void 0 : fieldConfig.renderCell) {
|
|
5528
5532
|
return fieldConfig.renderCell({
|
|
5529
|
-
value:
|
|
5533
|
+
value: params.value,
|
|
5530
5534
|
onChange: setFieldValue,
|
|
5531
5535
|
field: baseCol.field
|
|
5532
5536
|
});
|
|
@@ -5537,10 +5541,11 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5537
5541
|
variant: "outlined",
|
|
5538
5542
|
size: "small",
|
|
5539
5543
|
placeholder: (fieldConfig == null ? void 0 : fieldConfig.placeholder) || baseCol.headerName || `Escribir ${baseCol.field}`,
|
|
5540
|
-
value:
|
|
5544
|
+
value: params.value || "",
|
|
5541
5545
|
onChange: (e) => setFieldValue(e.target.value),
|
|
5542
5546
|
onKeyDown: (e) => {
|
|
5543
|
-
|
|
5547
|
+
e.stopPropagation();
|
|
5548
|
+
if (e.key === "Enter") handleAddInsertRowRef.current();
|
|
5544
5549
|
},
|
|
5545
5550
|
sx: { width: "100%", "& .MuiOutlinedInput-root": { height: "32px" } }
|
|
5546
5551
|
}
|
|
@@ -5552,8 +5557,8 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5552
5557
|
{
|
|
5553
5558
|
variant: "contained",
|
|
5554
5559
|
size: "small",
|
|
5555
|
-
disabled: !
|
|
5556
|
-
onClick:
|
|
5560
|
+
disabled: !hasInsertRowValueRef.current(),
|
|
5561
|
+
onClick: () => handleAddInsertRowRef.current()
|
|
5557
5562
|
},
|
|
5558
5563
|
"Agregar"
|
|
5559
5564
|
);
|
|
@@ -5561,7 +5566,7 @@ function SCDataGridInitial({ data, columns, getRowId, groupColumns, titleRowsPag
|
|
|
5561
5566
|
return null;
|
|
5562
5567
|
}
|
|
5563
5568
|
});
|
|
5564
|
-
});
|
|
5569
|
+
}), [columns, showInsertRow, insertRowFields]);
|
|
5565
5570
|
const columnVisibilityModel = {};
|
|
5566
5571
|
processedColumns.forEach((col) => {
|
|
5567
5572
|
if (col.hide === true) {
|