@omniumretail/component-library 1.3.5 → 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) {
|
|
@@ -25044,13 +25041,13 @@ const ResponsiveTable = (props) => {
|
|
|
25044
25041
|
);
|
|
25045
25042
|
}
|
|
25046
25043
|
if (!useOrderedCellSelection) {
|
|
25047
|
-
const cellContent =
|
|
25044
|
+
const cellContent = isSelected ? /* @__PURE__ */ jsx(Tag, { color: "grey", style: { margin: -4 }, children: "X" }) : originalCellContent ? /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4 }, children: originalCellContent.type }) : null;
|
|
25048
25045
|
return /* @__PURE__ */ jsx(
|
|
25049
25046
|
"div",
|
|
25050
25047
|
{
|
|
25051
25048
|
onClick: (e) => {
|
|
25052
25049
|
e.stopPropagation();
|
|
25053
|
-
handleCellClick(record, key,
|
|
25050
|
+
handleCellClick(record, key, originalCellContent);
|
|
25054
25051
|
},
|
|
25055
25052
|
className: classNames(
|
|
25056
25053
|
styles$7.selectableCell,
|