@omniumretail/component-library 1.3.41 → 1.3.43

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.
@@ -24862,7 +24862,8 @@ const ResponsiveTable = (props) => {
24862
24862
  disableCellSelection,
24863
24863
  templateEditMode,
24864
24864
  currentTemplateType,
24865
- currentTemplateColor
24865
+ currentTemplateColor,
24866
+ calendarMode
24866
24867
  } = props;
24867
24868
  const [customFilters, setCustomFilters] = useState([]);
24868
24869
  const [customColumns, setCustomColumns] = useState([]);
@@ -24894,61 +24895,118 @@ const ResponsiveTable = (props) => {
24894
24895
  if (disableCellSelection) return;
24895
24896
  const rowKey = record[rowKeyValue];
24896
24897
  const originalCellContent = record[columnKey];
24897
- console.log("🔍 CLICK DEBUG:", {
24898
- rowKey,
24899
- columnKey,
24900
- originalCellContent,
24901
- selectedCells: selectedCells.length
24902
- });
24903
- if (useOrderedCellSelection) ;
24904
- else {
24898
+ console.log("🔍 CLICK DEBUG:", { rowKey, columnKey, originalCellContent, selectedCells: selectedCells.length, templateEditMode, calendarMode });
24899
+ if (useOrderedCellSelection) {
24900
+ const isAlreadySelected = selectedCells.some(
24901
+ (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24902
+ );
24903
+ let newSelectedCells;
24904
+ if (isAlreadySelected) {
24905
+ newSelectedCells = selectedCells.filter(
24906
+ (cell) => !(cell.rowKey === rowKey && cell.columnKey === columnKey)
24907
+ );
24908
+ } else {
24909
+ const cellData = {
24910
+ rowKey,
24911
+ columnKey,
24912
+ value: {
24913
+ type: "X",
24914
+ color: selectedCellColor || "grey"
24915
+ },
24916
+ rowData: record
24917
+ };
24918
+ const maxSelection = maxCellSelection || 2;
24919
+ if (cellSelectionMode === "single") {
24920
+ newSelectedCells = [cellData];
24921
+ } else if (selectedCells.length >= maxSelection) {
24922
+ newSelectedCells = [...selectedCells.slice(1), cellData];
24923
+ } else {
24924
+ newSelectedCells = [...selectedCells, cellData];
24925
+ }
24926
+ }
24927
+ setSelectedCells(newSelectedCells);
24928
+ onCellsSelected?.(newSelectedCells);
24929
+ } else {
24905
24930
  const cellIndex = selectedCells.findIndex(
24906
24931
  (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24907
24932
  );
24908
24933
  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 });
24912
- let newSelectedCells;
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) {
24934
+ originalCellContent?.type === "S" || originalCellContent?.type === "D";
24935
+ console.log("🔍 STATE:", {
24936
+ cellIndex,
24937
+ isSelected,
24938
+ originalType: originalCellContent?.type,
24939
+ calendarMode,
24940
+ templateEditMode
24941
+ });
24942
+ let newSelectedCells = selectedCells;
24943
+ if (calendarMode) {
24944
+ if (isSelected) {
24945
+ const selectedCell = selectedCells[cellIndex];
24946
+ if (selectedCell?.value?.type === "F") {
24947
+ if (originalCellContent?.type === "F") {
24948
+ newSelectedCells = selectedCells.map(
24949
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: null, color: null } } : cell
24950
+ );
24951
+ console.log("➡️ Marked F as removed (backend F)");
24952
+ } else {
24953
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24954
+ console.log("➡️ Removed F background (calendar)");
24955
+ }
24956
+ } else if (selectedCell?.value?.type === null) {
24919
24957
  newSelectedCells = selectedCells.map(
24920
- (cell, idx) => idx === cellIndex ? { ...cell, value: { type: null, color: null } } : cell
24958
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: "F", color: currentTemplateColor } } : cell
24921
24959
  );
24922
- console.log("➡️ Marked as empty");
24923
- } else {
24924
- newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24925
- console.log("➡️ Removed");
24960
+ console.log("➡️ Re-added F after removal");
24926
24961
  }
24927
24962
  } 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");
24963
+ const newCell = {
24964
+ rowKey,
24965
+ columnKey,
24966
+ value: { type: "F", color: currentTemplateColor },
24967
+ rowData: record
24968
+ };
24969
+ newSelectedCells = [...selectedCells, newCell];
24970
+ console.log("➡️ Added F background (calendar)");
24935
24971
  }
24936
- } else {
24937
- console.log("❌ NOT SELECTED");
24938
- if (hasBackendContent) {
24972
+ } else if (templateEditMode) {
24973
+ if (isSelected) {
24974
+ const selectedCell = selectedCells[cellIndex];
24975
+ if (selectedCell?.value?.type === "I" || selectedCell?.value?.type === "L") {
24976
+ if (originalCellContent?.type === "I" || originalCellContent?.type === "L") {
24977
+ newSelectedCells = selectedCells.map(
24978
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: null, color: null } } : cell
24979
+ );
24980
+ console.log("➡️ Marked I/L as removed (backend I/L)");
24981
+ } else {
24982
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24983
+ console.log("➡️ Removed I/L (rules)");
24984
+ }
24985
+ } else if (selectedCell?.value?.type === null) {
24986
+ newSelectedCells = selectedCells.map(
24987
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: currentTemplateType, color: currentTemplateColor } } : cell
24988
+ );
24989
+ console.log("➡️ Re-added I/L after removal");
24990
+ }
24991
+ } else {
24939
24992
  const newCell = {
24940
24993
  rowKey,
24941
24994
  columnKey,
24942
- value: { type: null, color: null },
24995
+ value: { type: currentTemplateType, color: currentTemplateColor },
24943
24996
  rowData: record
24944
24997
  };
24945
24998
  newSelectedCells = [...selectedCells, newCell];
24946
- console.log("➡️ Adding as empty (backend content)");
24999
+ console.log("➡️ Added I/L (rules)");
25000
+ }
25001
+ } else {
25002
+ if (isSelected) {
25003
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
25004
+ console.log("➡️ Removed (user mode)");
24947
25005
  } else {
24948
25006
  const newCell = {
24949
25007
  rowKey,
24950
25008
  columnKey,
24951
- value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
25009
+ value: { type: "X", color: selectedCellColor || "grey" },
24952
25010
  rowData: record
24953
25011
  };
24954
25012
  if (cellSelectionMode === "single") {
@@ -24956,7 +25014,7 @@ const ResponsiveTable = (props) => {
24956
25014
  } else {
24957
25015
  newSelectedCells = [...selectedCells, newCell];
24958
25016
  }
24959
- console.log("➡️ Adding new type (empty cell)");
25017
+ console.log("➡️ Added X (user mode)");
24960
25018
  }
24961
25019
  }
24962
25020
  console.log("📤 NEW STATE:", newSelectedCells.length);
@@ -25091,55 +25149,64 @@ const ResponsiveTable = (props) => {
25091
25149
  );
25092
25150
  }
25093
25151
  if (!useOrderedCellSelection) {
25094
- const isSelectable2 = enableCellSelection && selectableColumns?.includes(key);
25095
- const originalCellContent2 = record[key];
25096
- const isDisabled = originalCellContent2?.disabled === true;
25097
- const isReadonly = originalCellContent2?.readonly === true;
25098
- const cellIndex2 = selectedCells.findIndex(
25099
- (cell) => cell.rowKey === record[rowKeyValue] && cell.columnKey === key
25100
- );
25101
- const isSelected2 = cellIndex2 !== -1;
25102
- const hasBackendSD = originalCellContent2?.type === "S" || originalCellContent2?.type === "D";
25152
+ const isDisabled = originalCellContent?.disabled === true;
25153
+ const isReadonly = originalCellContent?.readonly === true;
25154
+ const hasBackendSD = originalCellContent?.type === "S" || originalCellContent?.type === "D";
25155
+ let hasBackendBackground;
25156
+ if (calendarMode) {
25157
+ hasBackendBackground = hasBackendSD;
25158
+ } else {
25159
+ hasBackendBackground = hasBackendSD || originalCellContent?.type === "F";
25160
+ }
25161
+ !calendarMode && templateEditMode && originalCellContent?.type === "F" || !templateEditMode && !calendarMode && (originalCellContent?.type === "I" || originalCellContent?.type === "L");
25103
25162
  const getTopLayerContent = () => {
25104
- if (isSelected2) {
25105
- const selectedCell = selectedCells[cellIndex2];
25163
+ if (isSelected) {
25164
+ const selectedCell = selectedCells[cellIndex];
25106
25165
  const cellType = selectedCell?.value?.type;
25107
25166
  return {
25108
25167
  type: cellType,
25109
- // ⚡ Pode ser null!
25110
25168
  color: selectedCell?.value?.color,
25111
25169
  isFromSelection: true
25112
25170
  };
25113
25171
  }
25114
- if (originalCellContent2?.type && !hasBackendSD) {
25172
+ if (originalCellContent?.type && !hasBackendBackground) {
25115
25173
  return {
25116
- type: originalCellContent2.type,
25117
- color: originalCellContent2.color,
25174
+ type: originalCellContent.type,
25175
+ color: originalCellContent.color,
25118
25176
  isFromSelection: false
25119
25177
  };
25120
25178
  }
25121
25179
  return null;
25122
25180
  };
25123
- const topLayer = getTopLayerContent();
25181
+ getTopLayerContent();
25124
25182
  const getBackgroundColor = () => {
25125
- if (topLayer?.isFromSelection && topLayer.type === null) {
25183
+ if (isSelected && selectedCells[cellIndex]?.value?.type === null && originalCellContent?.type === "F") {
25184
+ if (originalCellContent?.type === "D") {
25185
+ return void 0;
25186
+ }
25126
25187
  return void 0;
25127
25188
  }
25128
- if (hasBackendSD) {
25129
- return originalCellContent2.color;
25189
+ if (isSelected) {
25190
+ const selectedCell = selectedCells[cellIndex];
25191
+ if (selectedCell?.value?.type === "F") {
25192
+ return selectedCell.value.color;
25193
+ }
25194
+ }
25195
+ if (originalCellContent?.type === "F") {
25196
+ return originalCellContent.color;
25130
25197
  }
25131
- if (topLayer?.isFromSelection && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25132
- return topLayer.color;
25198
+ if (originalCellContent?.type === "D") {
25199
+ return originalCellContent.color;
25133
25200
  }
25134
- if (!topLayer?.isFromSelection && originalCellContent2?.type && (originalCellContent2.type === "F" || originalCellContent2.type === "S" || originalCellContent2.type === "D")) {
25135
- return originalCellContent2.color;
25201
+ if (originalCellContent?.type === "S") {
25202
+ return originalCellContent.color;
25136
25203
  }
25137
25204
  return void 0;
25138
25205
  };
25139
25206
  const cellBackgroundColor = getBackgroundColor();
25140
25207
  if (isDisabled) {
25141
- if (originalCellContent2?.type === "I" || originalCellContent2?.type === "L" || isReadonly) {
25142
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent2.type });
25208
+ if (originalCellContent?.type === "I" || originalCellContent?.type === "L" || isReadonly) {
25209
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent.type });
25143
25210
  } else {
25144
25211
  return /* @__PURE__ */ jsx(
25145
25212
  "div",
@@ -25157,37 +25224,91 @@ const ResponsiveTable = (props) => {
25157
25224
  );
25158
25225
  }
25159
25226
  }
25160
- if (isSelectable2) {
25227
+ if (isSelectable) {
25161
25228
  const cellContent = (() => {
25229
+ if (calendarMode) {
25230
+ const fWasRemoved = isSelected && selectedCells[cellIndex]?.value?.type === null && originalCellContent?.type === "F";
25231
+ if (fWasRemoved) {
25232
+ return null;
25233
+ }
25234
+ if (isSelected && selectedCells[cellIndex]?.value?.type === "F") {
25235
+ if (originalCellContent?.type === "I" || originalCellContent?.type === "L") {
25236
+ return /* @__PURE__ */ jsx(
25237
+ Tag,
25238
+ {
25239
+ color: originalCellContent.color,
25240
+ style: { margin: -4, cursor: "pointer" },
25241
+ children: originalCellContent.type
25242
+ }
25243
+ );
25244
+ }
25245
+ return /* @__PURE__ */ jsx(
25246
+ Tag,
25247
+ {
25248
+ color: selectedCells[cellIndex].value.color,
25249
+ style: { margin: -4, cursor: "pointer" },
25250
+ children: "F"
25251
+ }
25252
+ );
25253
+ }
25254
+ if (originalCellContent?.type) {
25255
+ return /* @__PURE__ */ jsx(
25256
+ Tag,
25257
+ {
25258
+ color: originalCellContent.color,
25259
+ style: { margin: -4, cursor: "pointer" },
25260
+ children: originalCellContent.type
25261
+ }
25262
+ );
25263
+ }
25264
+ return null;
25265
+ }
25162
25266
  if (templateEditMode) {
25163
- if (topLayer && topLayer.type === null) {
25267
+ const wasRemoved = isSelected && selectedCells[cellIndex]?.value?.type === null && (originalCellContent?.type === "I" || originalCellContent?.type === "L");
25268
+ if (wasRemoved) {
25269
+ if (originalCellContent?.type === "S" || originalCellContent?.type === "D" || originalCellContent?.type === "F") {
25270
+ return /* @__PURE__ */ jsx(
25271
+ Tag,
25272
+ {
25273
+ color: originalCellContent.color,
25274
+ style: { margin: -4, cursor: "pointer" },
25275
+ children: originalCellContent.type
25276
+ }
25277
+ );
25278
+ }
25164
25279
  return null;
25165
25280
  }
25166
- if (topLayer) {
25167
- return /* @__PURE__ */ jsx(Tag, { color: topLayer.color, style: { margin: -4, cursor: "pointer" }, children: topLayer.type });
25281
+ if (isSelected && (selectedCells[cellIndex]?.value?.type === "I" || selectedCells[cellIndex]?.value?.type === "L")) {
25282
+ const selectedCell = selectedCells[cellIndex];
25283
+ return /* @__PURE__ */ jsx(Tag, { color: selectedCell.value.color, style: { margin: -4, cursor: "pointer" }, children: selectedCell.value.type });
25168
25284
  }
25169
- if (hasBackendSD) {
25170
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent2.type });
25285
+ if (originalCellContent?.type) {
25286
+ return /* @__PURE__ */ jsx(
25287
+ Tag,
25288
+ {
25289
+ color: originalCellContent.color,
25290
+ style: { margin: -4, cursor: "pointer" },
25291
+ children: originalCellContent.type
25292
+ }
25293
+ );
25171
25294
  }
25172
25295
  return null;
25173
25296
  }
25174
- if (isSelected2) {
25175
- const selectedCell = selectedCells[cellIndex2];
25297
+ if (isSelected) {
25298
+ const selectedCell = selectedCells[cellIndex];
25176
25299
  const cellColor = selectedCell?.value?.color || selectedCellColor;
25177
25300
  const cellType = selectedCell?.value?.type || "X";
25178
- const isLicenseType = cellType === "L";
25179
- const isReadonlyCell = selectedCell?.value?.readonly || disableCellSelection;
25180
25301
  return /* @__PURE__ */ jsx(
25181
25302
  Tag,
25182
25303
  {
25183
25304
  color: cellColor,
25184
- style: { margin: -4, cursor: isLicenseType || isReadonlyCell ? "not-allowed" : "pointer" },
25305
+ style: { margin: -4, cursor: "pointer" },
25185
25306
  children: cellType
25186
25307
  }
25187
25308
  );
25188
25309
  }
25189
- if (originalCellContent2) {
25190
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4 }, children: originalCellContent2.type });
25310
+ if (originalCellContent?.type) {
25311
+ return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent.type });
25191
25312
  }
25192
25313
  return null;
25193
25314
  })();
@@ -25197,15 +25318,15 @@ const ResponsiveTable = (props) => {
25197
25318
  onClick: (e) => {
25198
25319
  e.stopPropagation();
25199
25320
  if (disableCellSelection) return;
25200
- if (!templateEditMode && isSelected2 && selectedCells[cellIndex2]?.value?.type === "L") {
25321
+ if (!templateEditMode && !calendarMode && isSelected && selectedCells[cellIndex]?.value?.type === "L") {
25201
25322
  return;
25202
25323
  }
25203
25324
  handleCellClick(record, key);
25204
25325
  },
25205
25326
  className: classNames(
25206
25327
  styles$7.selectableCell,
25207
- isSelected2 && styles$7.selected,
25208
- isSelected2 && styles$7.uniformSelection
25328
+ isSelected && styles$7.selected,
25329
+ isSelected && styles$7.uniformSelection
25209
25330
  ),
25210
25331
  style: {
25211
25332
  cursor: disableCellSelection ? "not-allowed" : void 0,