@omniumretail/component-library 1.3.38 → 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,
@@ -25054,27 +25095,39 @@ const ResponsiveTable = (props) => {
25054
25095
  (cell) => cell.rowKey === record[rowKeyValue] && cell.columnKey === key
25055
25096
  );
25056
25097
  const isSelected2 = cellIndex2 !== -1;
25057
- const getDisplayTypeAndColor = () => {
25098
+ const hasBackendSD = originalCellContent2?.type === "S" || originalCellContent2?.type === "D";
25099
+ const getTopLayerContent = () => {
25058
25100
  if (isSelected2) {
25059
25101
  const selectedCell = selectedCells[cellIndex2];
25102
+ const cellType = selectedCell?.value?.type;
25103
+ if (cellType === null) {
25104
+ return null;
25105
+ }
25060
25106
  return {
25061
- type: selectedCell?.value?.type,
25062
- color: selectedCell?.value?.color
25107
+ type: cellType,
25108
+ color: selectedCell?.value?.color,
25109
+ isFromSelection: true
25063
25110
  };
25064
25111
  }
25065
- if (originalCellContent2?.type) {
25112
+ if (originalCellContent2?.type && !hasBackendSD) {
25066
25113
  return {
25067
25114
  type: originalCellContent2.type,
25068
- color: originalCellContent2.color
25115
+ color: originalCellContent2.color,
25116
+ isFromSelection: false
25069
25117
  };
25070
25118
  }
25071
- return { type: null, color: null };
25119
+ return null;
25072
25120
  };
25073
- const { type: displayType, color: displayColor } = getDisplayTypeAndColor();
25121
+ const topLayer = getTopLayerContent();
25074
25122
  const getBackgroundColor = () => {
25075
- if (!displayType) return void 0;
25076
- if (displayType === "F" || displayType === "S" || displayType === "D") {
25077
- return displayColor;
25123
+ if (hasBackendSD) {
25124
+ return originalCellContent2.color;
25125
+ }
25126
+ if (topLayer && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25127
+ return topLayer.color;
25128
+ }
25129
+ if (originalCellContent2?.type === "F" && !hasBackendSD) {
25130
+ return originalCellContent2.color;
25078
25131
  }
25079
25132
  return void 0;
25080
25133
  };
@@ -25102,8 +25155,11 @@ const ResponsiveTable = (props) => {
25102
25155
  if (isSelectable2) {
25103
25156
  const cellContent = (() => {
25104
25157
  if (templateEditMode) {
25105
- if (displayType) {
25106
- return /* @__PURE__ */ jsx(Tag, { color: displayColor, style: { margin: -4, cursor: "pointer" }, children: displayType });
25158
+ if (topLayer) {
25159
+ return /* @__PURE__ */ jsx(Tag, { color: topLayer.color, style: { margin: -4, cursor: "pointer" }, children: topLayer.type });
25160
+ }
25161
+ if (hasBackendSD) {
25162
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent2.type });
25107
25163
  }
25108
25164
  return null;
25109
25165
  }