@omniumretail/component-library 1.3.39 → 1.3.40

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.
@@ -24893,15 +24893,56 @@ const ResponsiveTable = (props) => {
24893
24893
  if (!enableCellSelection || !selectableColumns?.includes(columnKey)) return;
24894
24894
  if (disableCellSelection) return;
24895
24895
  const rowKey = record[rowKeyValue];
24896
- record[columnKey];
24897
- if (useOrderedCellSelection) ;
24898
- else {
24896
+ const originalCellContent = record[columnKey];
24897
+ if (useOrderedCellSelection) {
24898
+ const isAlreadySelected = selectedCells.some(
24899
+ (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24900
+ );
24901
+ let newSelectedCells;
24902
+ if (isAlreadySelected) {
24903
+ newSelectedCells = selectedCells.filter(
24904
+ (cell) => !(cell.rowKey === rowKey && cell.columnKey === columnKey)
24905
+ );
24906
+ } else {
24907
+ const cellData = {
24908
+ rowKey,
24909
+ columnKey,
24910
+ value: {
24911
+ type: "X",
24912
+ color: selectedCellColor || "grey"
24913
+ },
24914
+ rowData: record
24915
+ };
24916
+ const maxSelection = maxCellSelection || 2;
24917
+ if (cellSelectionMode === "single") {
24918
+ newSelectedCells = [cellData];
24919
+ } else if (selectedCells.length >= maxSelection) {
24920
+ newSelectedCells = [...selectedCells.slice(1), cellData];
24921
+ } else {
24922
+ newSelectedCells = [...selectedCells, cellData];
24923
+ }
24924
+ }
24925
+ setSelectedCells(newSelectedCells);
24926
+ onCellsSelected?.(newSelectedCells);
24927
+ } else {
24899
24928
  const cellIndex = selectedCells.findIndex(
24900
24929
  (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24901
24930
  );
24931
+ const isSelected = cellIndex >= 0;
24932
+ const hasBackendSD = originalCellContent?.type === "S" || originalCellContent?.type === "D";
24933
+ const hasBackendContent = originalCellContent?.type && !hasBackendSD;
24902
24934
  let newSelectedCells;
24903
- if (cellIndex >= 0) {
24935
+ if (isSelected) {
24904
24936
  newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24937
+ } else if (hasBackendContent) {
24938
+ const newCell = {
24939
+ rowKey,
24940
+ columnKey,
24941
+ value: { type: null, color: null },
24942
+ // ⚡ Marca como removido/vazio
24943
+ rowData: record
24944
+ };
24945
+ newSelectedCells = [...selectedCells, newCell];
24905
24946
  } else {
24906
24947
  const newCell = {
24907
24948
  rowKey,
@@ -25058,8 +25099,12 @@ const ResponsiveTable = (props) => {
25058
25099
  const getTopLayerContent = () => {
25059
25100
  if (isSelected2) {
25060
25101
  const selectedCell = selectedCells[cellIndex2];
25102
+ const cellType = selectedCell?.value?.type;
25103
+ if (cellType === null) {
25104
+ return null;
25105
+ }
25061
25106
  return {
25062
- type: selectedCell?.value?.type,
25107
+ type: cellType,
25063
25108
  color: selectedCell?.value?.color,
25064
25109
  isFromSelection: true
25065
25110
  };