@omniumretail/component-library 1.3.39 → 1.3.41

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,28 +24893,73 @@ 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];
24896
+ const originalCellContent = record[columnKey];
24897
+ console.log("🔍 CLICK DEBUG:", {
24898
+ rowKey,
24899
+ columnKey,
24900
+ originalCellContent,
24901
+ selectedCells: selectedCells.length
24902
+ });
24897
24903
  if (useOrderedCellSelection) ;
24898
24904
  else {
24899
24905
  const cellIndex = selectedCells.findIndex(
24900
24906
  (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24901
24907
  );
24908
+ const isSelected = cellIndex >= 0;
24909
+ const hasBackendSD = originalCellContent?.type === "S" || originalCellContent?.type === "D";
24910
+ const hasBackendContent = originalCellContent?.type && !hasBackendSD;
24911
+ console.log("🔍 STATE:", { cellIndex, isSelected, hasBackendSD, hasBackendContent });
24902
24912
  let newSelectedCells;
24903
- if (cellIndex >= 0) {
24904
- newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24905
- } else {
24906
- const newCell = {
24907
- rowKey,
24908
- columnKey,
24909
- value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
24910
- rowData: record
24911
- };
24912
- if (cellSelectionMode === "single") {
24913
- newSelectedCells = [newCell];
24913
+ if (isSelected) {
24914
+ const selectedCell = selectedCells[cellIndex];
24915
+ const selectedType = selectedCell?.value?.type;
24916
+ console.log("✅ IS SELECTED:", { selectedType });
24917
+ if (selectedType !== null) {
24918
+ if (hasBackendContent) {
24919
+ newSelectedCells = selectedCells.map(
24920
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: null, color: null } } : cell
24921
+ );
24922
+ console.log("➡️ Marked as empty");
24923
+ } else {
24924
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24925
+ console.log("➡️ Removed");
24926
+ }
24914
24927
  } else {
24928
+ newSelectedCells = selectedCells.map(
24929
+ (cell, idx) => idx === cellIndex ? {
24930
+ ...cell,
24931
+ value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" }
24932
+ } : cell
24933
+ );
24934
+ console.log("➡️ Added new type to empty");
24935
+ }
24936
+ } else {
24937
+ console.log("❌ NOT SELECTED");
24938
+ if (hasBackendContent) {
24939
+ const newCell = {
24940
+ rowKey,
24941
+ columnKey,
24942
+ value: { type: null, color: null },
24943
+ rowData: record
24944
+ };
24915
24945
  newSelectedCells = [...selectedCells, newCell];
24946
+ console.log("➡️ Adding as empty (backend content)");
24947
+ } else {
24948
+ const newCell = {
24949
+ rowKey,
24950
+ columnKey,
24951
+ value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
24952
+ rowData: record
24953
+ };
24954
+ if (cellSelectionMode === "single") {
24955
+ newSelectedCells = [newCell];
24956
+ } else {
24957
+ newSelectedCells = [...selectedCells, newCell];
24958
+ }
24959
+ console.log("➡️ Adding new type (empty cell)");
24916
24960
  }
24917
24961
  }
24962
+ console.log("📤 NEW STATE:", newSelectedCells.length);
24918
24963
  setSelectedCells(newSelectedCells);
24919
24964
  onCellsSelected?.(newSelectedCells);
24920
24965
  }
@@ -25058,8 +25103,10 @@ const ResponsiveTable = (props) => {
25058
25103
  const getTopLayerContent = () => {
25059
25104
  if (isSelected2) {
25060
25105
  const selectedCell = selectedCells[cellIndex2];
25106
+ const cellType = selectedCell?.value?.type;
25061
25107
  return {
25062
- type: selectedCell?.value?.type,
25108
+ type: cellType,
25109
+ // ⚡ Pode ser null!
25063
25110
  color: selectedCell?.value?.color,
25064
25111
  isFromSelection: true
25065
25112
  };
@@ -25075,13 +25122,16 @@ const ResponsiveTable = (props) => {
25075
25122
  };
25076
25123
  const topLayer = getTopLayerContent();
25077
25124
  const getBackgroundColor = () => {
25125
+ if (topLayer?.isFromSelection && topLayer.type === null) {
25126
+ return void 0;
25127
+ }
25078
25128
  if (hasBackendSD) {
25079
25129
  return originalCellContent2.color;
25080
25130
  }
25081
- if (topLayer && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25131
+ if (topLayer?.isFromSelection && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25082
25132
  return topLayer.color;
25083
25133
  }
25084
- if (originalCellContent2?.type === "F" && !hasBackendSD) {
25134
+ if (!topLayer?.isFromSelection && originalCellContent2?.type && (originalCellContent2.type === "F" || originalCellContent2.type === "S" || originalCellContent2.type === "D")) {
25085
25135
  return originalCellContent2.color;
25086
25136
  }
25087
25137
  return void 0;
@@ -25110,6 +25160,9 @@ const ResponsiveTable = (props) => {
25110
25160
  if (isSelectable2) {
25111
25161
  const cellContent = (() => {
25112
25162
  if (templateEditMode) {
25163
+ if (topLayer && topLayer.type === null) {
25164
+ return null;
25165
+ }
25113
25166
  if (topLayer) {
25114
25167
  return /* @__PURE__ */ jsx(Tag, { color: topLayer.color, style: { margin: -4, cursor: "pointer" }, children: topLayer.type });
25115
25168
  }