@omniumretail/component-library 1.3.28 → 1.3.30

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.
@@ -24861,7 +24861,10 @@ const ResponsiveTable = (props) => {
24861
24861
  useOrderedCellSelection = true,
24862
24862
  initialSelectedCells,
24863
24863
  selectedCellColor,
24864
- disableCellSelection
24864
+ disableCellSelection,
24865
+ templateEditMode,
24866
+ currentTemplateType,
24867
+ currentTemplateColor
24865
24868
  } = props;
24866
24869
  const [customFilters, setCustomFilters] = useState([]);
24867
24870
  const [customColumns, setCustomColumns] = useState([]);
@@ -24889,36 +24892,62 @@ const ResponsiveTable = (props) => {
24889
24892
  secondCell: { ...defaultCellStyle.secondCell, ...cellSelectionStyle?.secondCell }
24890
24893
  };
24891
24894
  const handleCellClick = (record, columnKey, value) => {
24892
- if (!enableCellSelection || !selectableColumns?.includes(columnKey) || disableCellSelection) return;
24893
- const isAlreadySelected = selectedCells.some(
24894
- (cell) => cell.rowKey === record[rowKeyValue] && cell.columnKey === columnKey
24895
- );
24896
- let newSelectedCells;
24897
- if (isAlreadySelected) {
24898
- newSelectedCells = selectedCells.filter(
24899
- (cell) => !(cell.rowKey === record[rowKeyValue] && cell.columnKey === columnKey)
24895
+ if (!enableCellSelection || !selectableColumns?.includes(columnKey)) return;
24896
+ if (disableCellSelection) return;
24897
+ const rowKey = record[rowKeyValue];
24898
+ if (useOrderedCellSelection) {
24899
+ const isAlreadySelected = selectedCells.some(
24900
+ (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24900
24901
  );
24902
+ let newSelectedCells;
24903
+ if (isAlreadySelected) {
24904
+ newSelectedCells = selectedCells.filter(
24905
+ (cell) => !(cell.rowKey === rowKey && cell.columnKey === columnKey)
24906
+ );
24907
+ } else {
24908
+ const cellData = {
24909
+ rowKey,
24910
+ columnKey,
24911
+ value: {
24912
+ type: "X",
24913
+ color: selectedCellColor || "grey"
24914
+ },
24915
+ rowData: record
24916
+ };
24917
+ const maxSelection = maxCellSelection || 2;
24918
+ if (cellSelectionMode === "single") {
24919
+ newSelectedCells = [cellData];
24920
+ } else if (selectedCells.length >= maxSelection) {
24921
+ newSelectedCells = [...selectedCells.slice(1), cellData];
24922
+ } else {
24923
+ newSelectedCells = [...selectedCells, cellData];
24924
+ }
24925
+ }
24926
+ setSelectedCells(newSelectedCells);
24927
+ onCellsSelected?.(newSelectedCells);
24901
24928
  } else {
24902
- const cellData = {
24903
- rowKey: record[rowKeyValue],
24904
- columnKey,
24905
- value: {
24906
- type: "X",
24907
- color: selectedCellColor || "grey"
24908
- },
24909
- rowData: record
24910
- };
24911
- const maxSelection = maxCellSelection || 2;
24912
- if (cellSelectionMode === "single") {
24913
- newSelectedCells = [cellData];
24914
- } else if (selectedCells.length >= maxSelection) {
24915
- newSelectedCells = [...selectedCells.slice(1), cellData];
24929
+ const cellIndex = selectedCells.findIndex(
24930
+ (cell) => cell.rowKey === rowKey && cell.columnKey === columnKey
24931
+ );
24932
+ let newSelectedCells;
24933
+ if (cellIndex >= 0) {
24934
+ newSelectedCells = selectedCells.filter((_, index) => index !== cellIndex);
24916
24935
  } else {
24917
- newSelectedCells = [...selectedCells, cellData];
24936
+ const newCell = {
24937
+ rowKey,
24938
+ columnKey,
24939
+ value: templateEditMode ? { type: currentTemplateType, color: currentTemplateColor } : { type: "X", color: selectedCellColor || "grey" },
24940
+ rowData: record
24941
+ };
24942
+ if (cellSelectionMode === "single") {
24943
+ newSelectedCells = [newCell];
24944
+ } else {
24945
+ newSelectedCells = [...selectedCells, newCell];
24946
+ }
24918
24947
  }
24948
+ setSelectedCells(newSelectedCells);
24949
+ onCellsSelected?.(newSelectedCells);
24919
24950
  }
24920
- setSelectedCells(newSelectedCells);
24921
- onCellsSelected?.(newSelectedCells);
24922
24951
  };
24923
24952
  useEffect(() => {
24924
24953
  if (cleanCellSelection) {
@@ -25055,7 +25084,7 @@ const ResponsiveTable = (props) => {
25055
25084
  (cell) => cell.rowKey === record[rowKeyValue] && cell.columnKey === key
25056
25085
  );
25057
25086
  const isSelected2 = cellIndex2 !== -1;
25058
- if (isDisabled) {
25087
+ if (isDisabled && !templateEditMode) {
25059
25088
  if (originalCellContent2?.type === "I" || isReadonly || originalCellContent2?.type === "L" || disableCellSelection) {
25060
25089
  return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4, cursor: "not-allowed" }, children: originalCellContent2.type });
25061
25090
  } else {
@@ -25075,6 +25104,31 @@ const ResponsiveTable = (props) => {
25075
25104
  );
25076
25105
  }
25077
25106
  }
25107
+ if (isDisabled && templateEditMode) {
25108
+ const cellContent = isSelected2 ? /* @__PURE__ */ jsx(
25109
+ Tag,
25110
+ {
25111
+ color: selectedCells[cellIndex2]?.value?.color || selectedCellColor,
25112
+ style: { margin: -4, cursor: "pointer" },
25113
+ children: selectedCells[cellIndex2]?.value?.type || "X"
25114
+ }
25115
+ ) : originalCellContent2?.type ? /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4 }, children: originalCellContent2.type }) : null;
25116
+ return /* @__PURE__ */ jsx(
25117
+ "div",
25118
+ {
25119
+ onClick: (e) => {
25120
+ e.stopPropagation();
25121
+ handleCellClick(record, key);
25122
+ },
25123
+ className: classNames(
25124
+ styles$7.selectableCell,
25125
+ isSelected2 && styles$7.selected,
25126
+ isSelected2 && styles$7.uniformSelection
25127
+ ),
25128
+ children: cellContent
25129
+ }
25130
+ );
25131
+ }
25078
25132
  if (isSelectable2) {
25079
25133
  const cellContent = (() => {
25080
25134
  if (isSelected2) {
@@ -25082,7 +25136,15 @@ const ResponsiveTable = (props) => {
25082
25136
  const cellColor = selectedCell?.value?.color || selectedCellColor;
25083
25137
  const cellType = selectedCell?.value?.type || "X";
25084
25138
  const isLicenseType = cellType === "L";
25085
- return /* @__PURE__ */ jsx(Tag, { color: cellColor, style: { margin: -4, cursor: isLicenseType ? "not-allowed" : "pointer" }, children: cellType });
25139
+ const isReadonlyCell = selectedCell?.value?.readonly || disableCellSelection;
25140
+ return /* @__PURE__ */ jsx(
25141
+ Tag,
25142
+ {
25143
+ color: cellColor,
25144
+ style: { margin: -4, cursor: (isLicenseType || isReadonlyCell) && !templateEditMode ? "not-allowed" : "pointer" },
25145
+ children: cellType
25146
+ }
25147
+ );
25086
25148
  }
25087
25149
  if (originalCellContent2) {
25088
25150
  return /* @__PURE__ */ jsx(Tag, { color: originalCellContent2.color, style: { margin: -4 }, children: originalCellContent2.type });
@@ -25095,7 +25157,7 @@ const ResponsiveTable = (props) => {
25095
25157
  onClick: (e) => {
25096
25158
  e.stopPropagation();
25097
25159
  if (disableCellSelection) return;
25098
- if (isSelected2 && selectedCells[cellIndex2]?.value?.type === "L") {
25160
+ if (!templateEditMode && isSelected2 && selectedCells[cellIndex2]?.value?.type === "L") {
25099
25161
  return;
25100
25162
  }
25101
25163
  handleCellClick(record, key);
@@ -25105,6 +25167,9 @@ const ResponsiveTable = (props) => {
25105
25167
  isSelected2 && styles$7.selected,
25106
25168
  isSelected2 && styles$7.uniformSelection
25107
25169
  ),
25170
+ style: {
25171
+ cursor: disableCellSelection ? "not-allowed" : void 0
25172
+ },
25108
25173
  children: cellContent
25109
25174
  }
25110
25175
  );