@omniumretail/component-library 1.3.6 → 1.3.8

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.
@@ -24887,40 +24887,33 @@ const ResponsiveTable = (props) => {
24887
24887
  secondCell: { ...defaultCellStyle.secondCell, ...cellSelectionStyle?.secondCell }
24888
24888
  };
24889
24889
  const handleCellClick = (record, columnKey, value) => {
24890
- if (!enableCellSelection || !selectableColumns?.includes(columnKey)) {
24891
- return;
24892
- }
24893
- const normalizedValue = value?.data ? { type: value.data.type, color: value.data.color } : value;
24890
+ if (!enableCellSelection || !selectableColumns?.includes(columnKey)) return;
24894
24891
  const cellData = {
24895
24892
  rowKey: record[rowKeyValue],
24896
24893
  columnKey,
24897
- value: normalizedValue,
24894
+ value,
24898
24895
  rowData: record
24899
24896
  };
24900
- setSelectedCells((prev) => {
24901
- const isAlreadySelected = prev.some(
24902
- (cell) => cell.rowKey === cellData.rowKey && cell.columnKey === cellData.columnKey
24897
+ const isAlreadySelected = selectedCells.some(
24898
+ (cell) => cell.rowKey === cellData.rowKey && cell.columnKey === cellData.columnKey
24899
+ );
24900
+ let newSelectedCells;
24901
+ if (isAlreadySelected) {
24902
+ newSelectedCells = selectedCells.filter(
24903
+ (cell) => !(cell.rowKey === cellData.rowKey && cell.columnKey === cellData.columnKey)
24903
24904
  );
24904
- let newSelectedCells;
24905
- if (isAlreadySelected) {
24906
- newSelectedCells = prev.filter(
24907
- (cell) => !(cell.rowKey === cellData.rowKey && cell.columnKey === cellData.columnKey)
24908
- );
24905
+ } else {
24906
+ const maxSelection = maxCellSelection || 2;
24907
+ if (cellSelectionMode === "single") {
24908
+ newSelectedCells = [cellData];
24909
+ } else if (selectedCells.length >= maxSelection) {
24910
+ newSelectedCells = [...selectedCells.slice(1), cellData];
24909
24911
  } else {
24910
- const maxSelection = maxCellSelection || 2;
24911
- if (cellSelectionMode === "single") {
24912
- newSelectedCells = [cellData];
24913
- } else if (prev.length >= maxSelection) {
24914
- newSelectedCells = [...prev.slice(1), cellData];
24915
- } else {
24916
- newSelectedCells = [...prev, cellData];
24917
- }
24912
+ newSelectedCells = [...selectedCells, cellData];
24918
24913
  }
24919
- if (onCellsSelected) {
24920
- onCellsSelected(newSelectedCells);
24921
- }
24922
- return newSelectedCells;
24923
- });
24914
+ }
24915
+ setSelectedCells(newSelectedCells);
24916
+ onCellsSelected?.(newSelectedCells);
24924
24917
  };
24925
24918
  useEffect(() => {
24926
24919
  if (cleanCellSelection) {
@@ -25018,17 +25011,17 @@ const ResponsiveTable = (props) => {
25018
25011
  sorter: isColumnSortable,
25019
25012
  render: (value, record) => {
25020
25013
  const isSelectable = enableCellSelection && selectableColumns?.includes(key);
25014
+ const originalCellContent = record[key];
25021
25015
  const cellIndex = selectedCells.findIndex(
25022
25016
  (cell) => cell.rowKey === record[rowKeyValue] && cell.columnKey === key
25023
25017
  );
25024
25018
  const isSelected = cellIndex !== -1;
25025
- const originalCellContent = record[key];
25026
25019
  if (isSelectable) {
25027
25020
  if (renderSelectedCell && isSelected) {
25028
25021
  const cellData = {
25029
25022
  rowKey: record[rowKeyValue],
25030
25023
  columnKey: key,
25031
- value,
25024
+ value: originalCellContent,
25032
25025
  rowData: record
25033
25026
  };
25034
25027
  return /* @__PURE__ */ jsx(
@@ -25036,7 +25029,7 @@ const ResponsiveTable = (props) => {
25036
25029
  {
25037
25030
  onClick: (e) => {
25038
25031
  e.stopPropagation();
25039
- handleCellClick(record, key, value);
25032
+ handleCellClick(record, key, originalCellContent);
25040
25033
  },
25041
25034
  className: classNames(styles$7.selectableCell, styles$7.selected),
25042
25035
  children: renderSelectedCell(cellData, cellIndex, selectedCells.length)