@omniumretail/component-library 1.3.40 → 1.3.42

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.
@@ -24894,68 +24894,91 @@ const ResponsiveTable = (props) => {
24894
24894
  if (disableCellSelection) return;
24895
24895
  const rowKey = record[rowKeyValue];
24896
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 {
24897
+ console.log("🔍 CLICK DEBUG:", { rowKey, columnKey, originalCellContent, selectedCells: selectedCells.length, templateEditMode });
24898
+ if (useOrderedCellSelection) ;
24899
+ else {
24928
24900
  const cellIndex = selectedCells.findIndex(
24929
24901
  (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24930
24902
  );
24931
24903
  const isSelected = cellIndex >= 0;
24932
24904
  const hasBackendSD = originalCellContent?.type === "S" || originalCellContent?.type === "D";
24933
24905
  const hasBackendContent = originalCellContent?.type && !hasBackendSD;
24906
+ const hasBackendBackground = hasBackendSD || originalCellContent?.type === "F";
24907
+ const hasBlockedContent = originalCellContent?.type === "I" || originalCellContent?.type === "L";
24908
+ console.log("🔍 STATE:", { cellIndex, isSelected, hasBackendSD, hasBackendContent, templateEditMode });
24909
+ if (!templateEditMode && hasBlockedContent) {
24910
+ console.log("🚫 BLOCKED: I/L not clickable in user mode");
24911
+ return;
24912
+ }
24934
24913
  let newSelectedCells;
24935
24914
  if (isSelected) {
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];
24946
- } else {
24947
- const newCell = {
24948
- rowKey,
24949
- columnKey,
24950
- value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
24951
- rowData: record
24952
- };
24953
- if (cellSelectionMode === "single") {
24954
- newSelectedCells = [newCell];
24915
+ const selectedCell = selectedCells[cellIndex];
24916
+ const selectedType = selectedCell?.value?.type;
24917
+ console.log("✅ IS SELECTED:", { selectedType });
24918
+ if (templateEditMode) {
24919
+ if (selectedType !== null) {
24920
+ if (hasBackendContent) {
24921
+ newSelectedCells = selectedCells.map(
24922
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: null, color: null } } : cell
24923
+ );
24924
+ console.log("➡️ Marked as empty (template mode)");
24925
+ } else {
24926
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24927
+ console.log("➡️ Removed (template mode)");
24928
+ }
24929
+ } else {
24930
+ newSelectedCells = selectedCells.map(
24931
+ (cell, idx) => idx === cellIndex ? {
24932
+ ...cell,
24933
+ value: { type: currentTemplateType, color: currentTemplateColor }
24934
+ } : cell
24935
+ );
24936
+ console.log("➡️ Added new type to empty (template mode)");
24937
+ }
24955
24938
  } else {
24939
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24940
+ console.log("➡️ Removed (user mode)");
24941
+ }
24942
+ } else {
24943
+ console.log("❌ NOT SELECTED");
24944
+ if (templateEditMode && hasBackendContent) {
24945
+ const newCell = {
24946
+ rowKey,
24947
+ columnKey,
24948
+ value: { type: null, color: null },
24949
+ rowData: record
24950
+ };
24956
24951
  newSelectedCells = [...selectedCells, newCell];
24952
+ console.log("➡️ Adding as empty (template mode, backend content)");
24953
+ } else if (!templateEditMode && (hasBackendBackground || !originalCellContent?.type)) {
24954
+ const newCell = {
24955
+ rowKey,
24956
+ columnKey,
24957
+ value: { type: "X", color: selectedCellColor || "grey" },
24958
+ rowData: record
24959
+ };
24960
+ if (cellSelectionMode === "single") {
24961
+ newSelectedCells = [newCell];
24962
+ } else {
24963
+ newSelectedCells = [...selectedCells, newCell];
24964
+ }
24965
+ console.log("➡️ Adding X (user mode, empty or background)");
24966
+ } else {
24967
+ const newCell = {
24968
+ rowKey,
24969
+ columnKey,
24970
+ value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
24971
+ rowData: record
24972
+ };
24973
+ if (cellSelectionMode === "single") {
24974
+ newSelectedCells = [newCell];
24975
+ } else {
24976
+ newSelectedCells = [...selectedCells, newCell];
24977
+ }
24978
+ console.log("➡️ Adding new type (empty cell)");
24957
24979
  }
24958
24980
  }
24981
+ console.log("📤 NEW STATE:", newSelectedCells.length);
24959
24982
  setSelectedCells(newSelectedCells);
24960
24983
  onCellsSelected?.(newSelectedCells);
24961
24984
  }
@@ -25087,32 +25110,25 @@ const ResponsiveTable = (props) => {
25087
25110
  );
25088
25111
  }
25089
25112
  if (!useOrderedCellSelection) {
25090
- const isSelectable2 = enableCellSelection && selectableColumns?.includes(key);
25091
- const originalCellContent2 = record[key];
25092
- const isDisabled = originalCellContent2?.disabled === true;
25093
- const isReadonly = originalCellContent2?.readonly === true;
25094
- const cellIndex2 = selectedCells.findIndex(
25095
- (cell) => cell.rowKey === record[rowKeyValue] && cell.columnKey === key
25096
- );
25097
- const isSelected2 = cellIndex2 !== -1;
25098
- const hasBackendSD = originalCellContent2?.type === "S" || originalCellContent2?.type === "D";
25113
+ const isDisabled = originalCellContent?.disabled === true;
25114
+ const isReadonly = originalCellContent?.readonly === true;
25115
+ const hasBackendBackground = originalCellContent?.type === "S" || originalCellContent?.type === "D" || originalCellContent?.type === "F";
25116
+ const hasBlockedContent = originalCellContent?.type === "I" || originalCellContent?.type === "L";
25099
25117
  const getTopLayerContent = () => {
25100
- if (isSelected2) {
25101
- const selectedCell = selectedCells[cellIndex2];
25118
+ if (isSelected) {
25119
+ const selectedCell = selectedCells[cellIndex];
25102
25120
  const cellType = selectedCell?.value?.type;
25103
- if (cellType === null) {
25104
- return null;
25105
- }
25106
25121
  return {
25107
25122
  type: cellType,
25123
+ // ⚡ Pode ser null!
25108
25124
  color: selectedCell?.value?.color,
25109
25125
  isFromSelection: true
25110
25126
  };
25111
25127
  }
25112
- if (originalCellContent2?.type && !hasBackendSD) {
25128
+ if (originalCellContent?.type && !hasBackendBackground) {
25113
25129
  return {
25114
- type: originalCellContent2.type,
25115
- color: originalCellContent2.color,
25130
+ type: originalCellContent.type,
25131
+ color: originalCellContent.color,
25116
25132
  isFromSelection: false
25117
25133
  };
25118
25134
  }
@@ -25120,21 +25136,21 @@ const ResponsiveTable = (props) => {
25120
25136
  };
25121
25137
  const topLayer = getTopLayerContent();
25122
25138
  const getBackgroundColor = () => {
25123
- if (hasBackendSD) {
25124
- return originalCellContent2.color;
25139
+ if (topLayer?.isFromSelection && topLayer.type === null) {
25140
+ return void 0;
25125
25141
  }
25126
- if (topLayer && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25127
- return topLayer.color;
25142
+ if (hasBackendBackground) {
25143
+ return originalCellContent.color;
25128
25144
  }
25129
- if (originalCellContent2?.type === "F" && !hasBackendSD) {
25130
- return originalCellContent2.color;
25145
+ if (topLayer?.isFromSelection && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25146
+ return topLayer.color;
25131
25147
  }
25132
25148
  return void 0;
25133
25149
  };
25134
25150
  const cellBackgroundColor = getBackgroundColor();
25135
25151
  if (isDisabled) {
25136
- if (originalCellContent2?.type === "I" || originalCellContent2?.type === "L" || isReadonly) {
25137
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent2.type });
25152
+ if (originalCellContent?.type === "I" || originalCellContent?.type === "L" || isReadonly) {
25153
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent.type });
25138
25154
  } else {
25139
25155
  return /* @__PURE__ */ jsx(
25140
25156
  "div",
@@ -25152,19 +25168,22 @@ const ResponsiveTable = (props) => {
25152
25168
  );
25153
25169
  }
25154
25170
  }
25155
- if (isSelectable2) {
25171
+ if (isSelectable) {
25156
25172
  const cellContent = (() => {
25157
25173
  if (templateEditMode) {
25174
+ if (topLayer && topLayer.type === null) {
25175
+ return null;
25176
+ }
25158
25177
  if (topLayer) {
25159
25178
  return /* @__PURE__ */ jsx(Tag, { color: topLayer.color, style: { margin: -4, cursor: "pointer" }, children: topLayer.type });
25160
25179
  }
25161
- if (hasBackendSD) {
25162
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent2.type });
25180
+ if (hasBackendBackground) {
25181
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent.type });
25163
25182
  }
25164
25183
  return null;
25165
25184
  }
25166
- if (isSelected2) {
25167
- const selectedCell = selectedCells[cellIndex2];
25185
+ if (isSelected) {
25186
+ const selectedCell = selectedCells[cellIndex];
25168
25187
  const cellColor = selectedCell?.value?.color || selectedCellColor;
25169
25188
  const cellType = selectedCell?.value?.type || "X";
25170
25189
  const isLicenseType = cellType === "L";
@@ -25178,8 +25197,11 @@ const ResponsiveTable = (props) => {
25178
25197
  }
25179
25198
  );
25180
25199
  }
25181
- if (originalCellContent2) {
25182
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4 }, children: originalCellContent2.type });
25200
+ if (hasBackendBackground) {
25201
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent.type });
25202
+ }
25203
+ if (hasBlockedContent) {
25204
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent.type });
25183
25205
  }
25184
25206
  return null;
25185
25207
  })();
@@ -25189,15 +25211,15 @@ const ResponsiveTable = (props) => {
25189
25211
  onClick: (e) => {
25190
25212
  e.stopPropagation();
25191
25213
  if (disableCellSelection) return;
25192
- if (!templateEditMode && isSelected2 && selectedCells[cellIndex2]?.value?.type === "L") {
25214
+ if (!templateEditMode && isSelected && selectedCells[cellIndex]?.value?.type === "L") {
25193
25215
  return;
25194
25216
  }
25195
25217
  handleCellClick(record, key);
25196
25218
  },
25197
25219
  className: classNames(
25198
25220
  styles$7.selectableCell,
25199
- isSelected2 && styles$7.selected,
25200
- isSelected2 && styles$7.uniformSelection
25221
+ isSelected && styles$7.selected,
25222
+ isSelected && styles$7.uniformSelection
25201
25223
  ),
25202
25224
  style: {
25203
25225
  cursor: disableCellSelection ? "not-allowed" : void 0,