@omniumretail/component-library 1.3.42 → 1.3.44

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,80 +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:", { rowKey, columnKey, originalCellContent, selectedCells: selectedCells.length, templateEditMode });
24898
- if (useOrderedCellSelection) ;
24899
- 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 {
24900
24930
  const cellIndex = selectedCells.findIndex(
24901
24931
  (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24902
24932
  );
24903
24933
  const isSelected = cellIndex >= 0;
24904
- const hasBackendSD = originalCellContent?.type === "S" || originalCellContent?.type === "D";
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
- }
24913
- let newSelectedCells;
24914
- if (isSelected) {
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) {
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") {
24921
24948
  newSelectedCells = selectedCells.map(
24922
24949
  (cell, idx) => idx === cellIndex ? { ...cell, value: { type: null, color: null } } : cell
24923
24950
  );
24924
- console.log("➡️ Marked as empty (template mode)");
24951
+ console.log("➡️ Marked F as removed (backend F)");
24925
24952
  } else {
24926
24953
  newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24927
- console.log("➡️ Removed (template mode)");
24954
+ console.log("➡️ Removed F background (calendar)");
24928
24955
  }
24929
- } else {
24956
+ } else if (selectedCell?.value?.type === null) {
24930
24957
  newSelectedCells = selectedCells.map(
24931
- (cell, idx) => idx === cellIndex ? {
24932
- ...cell,
24933
- value: { type: currentTemplateType, color: currentTemplateColor }
24934
- } : cell
24958
+ (cell, idx) => idx === cellIndex ? { ...cell, value: { type: "F", color: currentTemplateColor } } : cell
24935
24959
  );
24936
- console.log("➡️ Added new type to empty (template mode)");
24960
+ console.log("➡️ Re-added F after removal");
24937
24961
  }
24938
24962
  } 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
24963
  const newCell = {
24946
24964
  rowKey,
24947
24965
  columnKey,
24948
- value: { type: null, color: null },
24966
+ value: { type: "F", color: currentTemplateColor },
24949
24967
  rowData: record
24950
24968
  };
24951
24969
  newSelectedCells = [...selectedCells, newCell];
24952
- console.log("➡️ Adding as empty (template mode, backend content)");
24953
- } else if (!templateEditMode && (hasBackendBackground || !originalCellContent?.type)) {
24970
+ console.log("➡️ Added F background (calendar)");
24971
+ }
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 {
24954
24992
  const newCell = {
24955
24993
  rowKey,
24956
24994
  columnKey,
24957
- value: { type: "X", color: selectedCellColor || "grey" },
24995
+ value: { type: currentTemplateType, color: currentTemplateColor },
24958
24996
  rowData: record
24959
24997
  };
24960
- if (cellSelectionMode === "single") {
24961
- newSelectedCells = [newCell];
24962
- } else {
24963
- newSelectedCells = [...selectedCells, newCell];
24964
- }
24965
- console.log("➡️ Adding X (user mode, empty or background)");
24998
+ newSelectedCells = [...selectedCells, newCell];
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)");
24966
25005
  } else {
24967
25006
  const newCell = {
24968
25007
  rowKey,
24969
25008
  columnKey,
24970
- value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
25009
+ value: { type: "X", color: selectedCellColor || "grey" },
24971
25010
  rowData: record
24972
25011
  };
24973
25012
  if (cellSelectionMode === "single") {
@@ -24975,7 +25014,7 @@ const ResponsiveTable = (props) => {
24975
25014
  } else {
24976
25015
  newSelectedCells = [...selectedCells, newCell];
24977
25016
  }
24978
- console.log("➡️ Adding new type (empty cell)");
25017
+ console.log("➡️ Added X (user mode)");
24979
25018
  }
24980
25019
  }
24981
25020
  console.log("📤 NEW STATE:", newSelectedCells.length);
@@ -25112,15 +25151,20 @@ const ResponsiveTable = (props) => {
25112
25151
  if (!useOrderedCellSelection) {
25113
25152
  const isDisabled = originalCellContent?.disabled === true;
25114
25153
  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";
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");
25117
25162
  const getTopLayerContent = () => {
25118
25163
  if (isSelected) {
25119
25164
  const selectedCell = selectedCells[cellIndex];
25120
25165
  const cellType = selectedCell?.value?.type;
25121
25166
  return {
25122
25167
  type: cellType,
25123
- // ⚡ Pode ser null!
25124
25168
  color: selectedCell?.value?.color,
25125
25169
  isFromSelection: true
25126
25170
  };
@@ -25134,16 +25178,28 @@ const ResponsiveTable = (props) => {
25134
25178
  }
25135
25179
  return null;
25136
25180
  };
25137
- const topLayer = getTopLayerContent();
25181
+ getTopLayerContent();
25138
25182
  const getBackgroundColor = () => {
25139
- 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
+ }
25140
25187
  return void 0;
25141
25188
  }
25142
- if (hasBackendBackground) {
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") {
25143
25196
  return originalCellContent.color;
25144
25197
  }
25145
- if (topLayer?.isFromSelection && (topLayer.type === "F" || topLayer.type === "S" || topLayer.type === "D")) {
25146
- return topLayer.color;
25198
+ if (originalCellContent?.type === "D") {
25199
+ return originalCellContent.color;
25200
+ }
25201
+ if (originalCellContent?.type === "S") {
25202
+ return originalCellContent.color;
25147
25203
  }
25148
25204
  return void 0;
25149
25205
  };
@@ -25170,15 +25226,84 @@ const ResponsiveTable = (props) => {
25170
25226
  }
25171
25227
  if (isSelectable) {
25172
25228
  const cellContent = (() => {
25229
+ if (calendarMode) {
25230
+ if (isSelected && (selectedCells[cellIndex]?.value?.type === "I" || selectedCells[cellIndex]?.value?.type === "L")) {
25231
+ return /* @__PURE__ */ jsx(
25232
+ Tag,
25233
+ {
25234
+ color: selectedCells[cellIndex].value.color,
25235
+ style: { margin: -4, cursor: "pointer" },
25236
+ children: selectedCells[cellIndex].value.type
25237
+ }
25238
+ );
25239
+ }
25240
+ const fWasRemoved = isSelected && selectedCells[cellIndex]?.value?.type === null && originalCellContent?.type === "F";
25241
+ if (fWasRemoved) {
25242
+ return null;
25243
+ }
25244
+ if (isSelected && selectedCells[cellIndex]?.value?.type === "F") {
25245
+ if (originalCellContent?.type === "S" || originalCellContent?.type === "D") {
25246
+ return null;
25247
+ }
25248
+ return /* @__PURE__ */ jsx(
25249
+ Tag,
25250
+ {
25251
+ color: selectedCells[cellIndex].value.color,
25252
+ style: { margin: -4, cursor: "pointer" },
25253
+ children: "F"
25254
+ }
25255
+ );
25256
+ }
25257
+ if (originalCellContent?.type === "I" || originalCellContent?.type === "L") {
25258
+ return /* @__PURE__ */ jsx(
25259
+ Tag,
25260
+ {
25261
+ color: originalCellContent.color,
25262
+ style: { margin: -4, cursor: "not-allowed" },
25263
+ children: originalCellContent.type
25264
+ }
25265
+ );
25266
+ }
25267
+ if (originalCellContent?.type === "F") {
25268
+ return /* @__PURE__ */ jsx(
25269
+ Tag,
25270
+ {
25271
+ color: originalCellContent.color,
25272
+ style: { margin: -4, cursor: "pointer" },
25273
+ children: "F"
25274
+ }
25275
+ );
25276
+ }
25277
+ return null;
25278
+ }
25173
25279
  if (templateEditMode) {
25174
- if (topLayer && topLayer.type === null) {
25280
+ const wasRemoved = isSelected && selectedCells[cellIndex]?.value?.type === null && (originalCellContent?.type === "I" || originalCellContent?.type === "L");
25281
+ if (wasRemoved) {
25282
+ if (originalCellContent?.type === "S" || originalCellContent?.type === "D" || originalCellContent?.type === "F") {
25283
+ return /* @__PURE__ */ jsx(
25284
+ Tag,
25285
+ {
25286
+ color: originalCellContent.color,
25287
+ style: { margin: -4, cursor: "pointer" },
25288
+ children: originalCellContent.type
25289
+ }
25290
+ );
25291
+ }
25175
25292
  return null;
25176
25293
  }
25177
- if (topLayer) {
25178
- return /* @__PURE__ */ jsx(Tag, { color: topLayer.color, style: { margin: -4, cursor: "pointer" }, children: topLayer.type });
25294
+ if (isSelected && (selectedCells[cellIndex]?.value?.type === "I" || selectedCells[cellIndex]?.value?.type === "L")) {
25295
+ const selectedCell = selectedCells[cellIndex];
25296
+ return /* @__PURE__ */ jsx(Tag, { color: selectedCell.value.color, style: { margin: -4, cursor: "pointer" }, children: selectedCell.value.type });
25179
25297
  }
25180
- if (hasBackendBackground) {
25181
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent.type });
25298
+ if (originalCellContent?.type) {
25299
+ return /* @__PURE__ */ jsx(
25300
+ Tag,
25301
+ {
25302
+ color: originalCellContent.color,
25303
+ style: { margin: -4, cursor: "pointer" },
25304
+ children: originalCellContent.type
25305
+ }
25306
+ );
25182
25307
  }
25183
25308
  return null;
25184
25309
  }
@@ -25186,23 +25311,18 @@ const ResponsiveTable = (props) => {
25186
25311
  const selectedCell = selectedCells[cellIndex];
25187
25312
  const cellColor = selectedCell?.value?.color || selectedCellColor;
25188
25313
  const cellType = selectedCell?.value?.type || "X";
25189
- const isLicenseType = cellType === "L";
25190
- const isReadonlyCell = selectedCell?.value?.readonly || disableCellSelection;
25191
25314
  return /* @__PURE__ */ jsx(
25192
25315
  Tag,
25193
25316
  {
25194
25317
  color: cellColor,
25195
- style: { margin: -4, cursor: isLicenseType || isReadonlyCell ? "not-allowed" : "pointer" },
25318
+ style: { margin: -4, cursor: "pointer" },
25196
25319
  children: cellType
25197
25320
  }
25198
25321
  );
25199
25322
  }
25200
- if (hasBackendBackground) {
25323
+ if (originalCellContent?.type) {
25201
25324
  return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "pointer" }, children: originalCellContent.type });
25202
25325
  }
25203
- if (hasBlockedContent) {
25204
- return /* @__PURE__ */ jsx(Tag, { color: originalCellContent.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent.type });
25205
- }
25206
25326
  return null;
25207
25327
  })();
25208
25328
  return /* @__PURE__ */ jsx(
@@ -25211,7 +25331,7 @@ const ResponsiveTable = (props) => {
25211
25331
  onClick: (e) => {
25212
25332
  e.stopPropagation();
25213
25333
  if (disableCellSelection) return;
25214
- if (!templateEditMode && isSelected && selectedCells[cellIndex]?.value?.type === "L") {
25334
+ if (!templateEditMode && !calendarMode && isSelected && selectedCells[cellIndex]?.value?.type === "L") {
25215
25335
  return;
25216
25336
  }
25217
25337
  handleCellClick(record, key);