@oliasoft-open-source/react-ui-library 3.2.0 → 3.3.0-beta-2

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35169,7 +35169,8 @@ const InputCell = (props) => {
35169
35169
  maxTooltipWidth: cell.maxTooltipWidth,
35170
35170
  right: columnAlignment === "right",
35171
35171
  testId,
35172
- tabIndex: cell.disabled ? -1 : 0
35172
+ tabIndex: cell.disabled ? -1 : 0,
35173
+ tooltip: cell.tooltip
35173
35174
  });
35174
35175
  };
35175
35176
  const SelectCell = (props) => {
@@ -35935,6 +35936,7 @@ const TableScrollWrapper = ({
35935
35936
  });
35936
35937
  };
35937
35938
  const Table = (props) => {
35939
+ var _a, _b, _c, _d;
35938
35940
  const {
35939
35941
  onListReorder,
35940
35942
  table: table2
@@ -35952,7 +35954,8 @@ const Table = (props) => {
35952
35954
  stickyHeaders,
35953
35955
  striped: striped2 = true,
35954
35956
  testId,
35955
- draggable: draggable2
35957
+ draggable: draggable2,
35958
+ onChangeAutoEmptyRow = null
35956
35959
  } = table2;
35957
35960
  const targetRef = useRef();
35958
35961
  const [dimensions, setDimensions] = useState({
@@ -35972,13 +35975,43 @@ const Table = (props) => {
35972
35975
  const rowActions = hasRowActions(rows, headers);
35973
35976
  const colSpan = columnCount + (rowActions ? 1 : 0);
35974
35977
  const [rowsMetaData, setRowsMetaData] = useState([]);
35978
+ const allRows = rows;
35979
+ const isLastPage = footer2 ? ((_a = footer2 == null ? void 0 : footer2.pagination) == null ? void 0 : _a.selectedPage) >= ((_b = footer2 == null ? void 0 : footer2.pagination) == null ? void 0 : _b.rowCount) / ((_d = (_c = footer2 == null ? void 0 : footer2.pagination) == null ? void 0 : _c.rowsPerPage) == null ? void 0 : _d.value) : true;
35980
+ if (onChangeAutoEmptyRow) {
35981
+ const lastRowCells = rows[rows.length - 1].cells;
35982
+ const newEmptyRowIndex = rows.length;
35983
+ const newEmptyCells = lastRowCells.map((cell, i) => {
35984
+ if (cell.type === "Input") {
35985
+ return {
35986
+ ...cell,
35987
+ value: "",
35988
+ onChange: (evt) => onChangeAutoEmptyRow(evt, newEmptyRowIndex, i),
35989
+ error: void 0,
35990
+ disabled: isLastPage ? i === 0 ? false : cell.disabled : true,
35991
+ tooltip: !isLastPage && "Just allowed in last page"
35992
+ };
35993
+ }
35994
+ return {
35995
+ ...cell,
35996
+ value: "",
35997
+ error: void 0,
35998
+ warning: void 0,
35999
+ disabled: true
36000
+ };
36001
+ });
36002
+ const newEmptyRow = {
36003
+ cells: newEmptyCells,
36004
+ testId: testId && `${testId}-last-empty-row`
36005
+ };
36006
+ allRows.push(newEmptyRow);
36007
+ }
35975
36008
  return draggable2 ? /* @__PURE__ */ jsx("div", {
35976
36009
  ref: targetRef,
35977
36010
  children: /* @__PURE__ */ jsx(DragDropContext, {
35978
36011
  onDragEnd: (result) => {
35979
- var _a, _b;
35980
- const from = (_a = result == null ? void 0 : result.source) == null ? void 0 : _a.index;
35981
- const to = (_b = result == null ? void 0 : result.destination) == null ? void 0 : _b.index;
36012
+ var _a2, _b2;
36013
+ const from = (_a2 = result == null ? void 0 : result.source) == null ? void 0 : _a2.index;
36014
+ const to = (_b2 = result == null ? void 0 : result.destination) == null ? void 0 : _b2.index;
35982
36015
  onListReorder({
35983
36016
  from,
35984
36017
  to
@@ -36022,7 +36055,7 @@ const Table = (props) => {
36022
36055
  }, `0_${rowIndex}`);
36023
36056
  })]
36024
36057
  }), /* @__PURE__ */ jsxs("tbody", {
36025
- children: [rows.slice(0, visibleRows).map((row2, rowIndex) => /* @__PURE__ */ jsx(PublicDraggable, {
36058
+ children: [allRows.slice(0, visibleRows).map((row2, rowIndex) => /* @__PURE__ */ jsx(PublicDraggable, {
36026
36059
  draggableId: rowIndex + "",
36027
36060
  index: rowIndex,
36028
36061
  isDragDisabled: row2.noDrag,
@@ -36084,7 +36117,7 @@ const Table = (props) => {
36084
36117
  }, `0_${rowIndex}`);
36085
36118
  })]
36086
36119
  }), /* @__PURE__ */ jsx("tbody", {
36087
- children: rows.slice(0, visibleRows).map((row2, rowIndex) => /* @__PURE__ */ jsx(Row, {
36120
+ children: allRows.slice(0, visibleRows).map((row2, rowIndex) => /* @__PURE__ */ jsx(Row, {
36088
36121
  rowIndex,
36089
36122
  row: row2,
36090
36123
  columnCount,
@@ -36129,7 +36162,9 @@ Table.propTypes = {
36129
36162
  }),
36130
36163
  bordered: propTypes$1.exports.bool,
36131
36164
  striped: propTypes$1.exports.bool,
36132
- testId: propTypes$1.exports.string
36165
+ testId: propTypes$1.exports.string,
36166
+ hasLastEmptyRow: propTypes$1.exports.bool,
36167
+ handleLastEmptyRow: propTypes$1.exports.func
36133
36168
  }).isRequired,
36134
36169
  onListReorder: propTypes$1.exports.func
36135
36170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "3.2.0",
3
+ "version": "3.3.0-beta-2",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",