@omniumretail/component-library 1.3.6 → 1.3.7
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.
|
@@ -24887,40 +24887,37 @@ const ResponsiveTable = (props) => {
|
|
|
24887
24887
|
secondCell: { ...defaultCellStyle.secondCell, ...cellSelectionStyle?.secondCell }
|
|
24888
24888
|
};
|
|
24889
24889
|
const handleCellClick = (record, columnKey, value) => {
|
|
24890
|
-
if (!enableCellSelection || !selectableColumns?.includes(columnKey))
|
|
24891
|
-
return;
|
|
24892
|
-
}
|
|
24893
|
-
const normalizedValue = value?.data ? { type: value.data.type, color: value.data.color } : value;
|
|
24890
|
+
if (!enableCellSelection || !selectableColumns?.includes(columnKey)) return;
|
|
24894
24891
|
const cellData = {
|
|
24895
24892
|
rowKey: record[rowKeyValue],
|
|
24896
24893
|
columnKey,
|
|
24897
|
-
value
|
|
24894
|
+
value,
|
|
24898
24895
|
rowData: record
|
|
24899
24896
|
};
|
|
24900
|
-
|
|
24901
|
-
|
|
24902
|
-
|
|
24897
|
+
console.log("Célula clicada:", cellData);
|
|
24898
|
+
console.log("SelectedCells antes:", selectedCells);
|
|
24899
|
+
const isAlreadySelected = selectedCells.some(
|
|
24900
|
+
(cell) => cell.rowKey === cellData.rowKey && cell.columnKey === cellData.columnKey
|
|
24901
|
+
);
|
|
24902
|
+
console.log("isAlreadySelected:", isAlreadySelected);
|
|
24903
|
+
let newSelectedCells;
|
|
24904
|
+
if (isAlreadySelected) {
|
|
24905
|
+
newSelectedCells = selectedCells.filter(
|
|
24906
|
+
(cell) => !(cell.rowKey === cellData.rowKey && cell.columnKey === cellData.columnKey)
|
|
24903
24907
|
);
|
|
24904
|
-
|
|
24905
|
-
|
|
24906
|
-
|
|
24907
|
-
|
|
24908
|
-
|
|
24908
|
+
} else {
|
|
24909
|
+
const maxSelection = maxCellSelection || 2;
|
|
24910
|
+
if (cellSelectionMode === "single") {
|
|
24911
|
+
newSelectedCells = [cellData];
|
|
24912
|
+
} else if (selectedCells.length >= maxSelection) {
|
|
24913
|
+
newSelectedCells = [...selectedCells.slice(1), cellData];
|
|
24909
24914
|
} else {
|
|
24910
|
-
|
|
24911
|
-
if (cellSelectionMode === "single") {
|
|
24912
|
-
newSelectedCells = [cellData];
|
|
24913
|
-
} else if (prev.length >= maxSelection) {
|
|
24914
|
-
newSelectedCells = [...prev.slice(1), cellData];
|
|
24915
|
-
} else {
|
|
24916
|
-
newSelectedCells = [...prev, cellData];
|
|
24917
|
-
}
|
|
24918
|
-
}
|
|
24919
|
-
if (onCellsSelected) {
|
|
24920
|
-
onCellsSelected(newSelectedCells);
|
|
24915
|
+
newSelectedCells = [...selectedCells, cellData];
|
|
24921
24916
|
}
|
|
24922
|
-
|
|
24923
|
-
|
|
24917
|
+
}
|
|
24918
|
+
console.log("SelectedCells depois:", newSelectedCells);
|
|
24919
|
+
setSelectedCells(newSelectedCells);
|
|
24920
|
+
onCellsSelected?.(newSelectedCells);
|
|
24924
24921
|
};
|
|
24925
24922
|
useEffect(() => {
|
|
24926
24923
|
if (cleanCellSelection) {
|