oolib 2.88.0 → 2.88.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.
@@ -22,13 +22,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.handleClearColContent = exports.handleInsertColBefore = exports.handleInsertColAfter = exports.handleDuplicateCol = exports.handleDeleteCol = exports.handleAddCol = void 0;
24
24
  var genHash_1 = require("../utils/genHash");
25
+ var genNewCell = function () { return ({
26
+ id: "cell_".concat((0, genHash_1.genHash)(8)),
27
+ }); };
25
28
  var handleAddColAtIdx = function (_a) {
26
29
  var value = _a.value, onChange = _a.onChange, id = _a.id, defaultColWidth = _a.defaultColWidth, colIdx = _a.colIdx;
27
30
  var data = value.data, colWidthConfig = value.colWidthConfig;
28
31
  var newData = __spreadArray([], data, true);
29
32
  newData = newData.map(function (row) {
30
33
  var newCellData = __spreadArray([], row.cellData, true);
31
- newCellData.splice(colIdx, 0, { id: "cell_".concat((0, genHash_1.genHash)(8)) });
34
+ newCellData.splice(colIdx, 0, genNewCell());
32
35
  return __assign(__assign({}, row), { cellData: newCellData });
33
36
  });
34
37
  var newColWidthValue = defaultColWidth + "px";
@@ -132,11 +135,20 @@ var handleClearColContent = function (_a) {
132
135
  var data = value.data, colWidthConfig = value.colWidthConfig;
133
136
  var newData = data.map(function (row) {
134
137
  var newCellData = __spreadArray([], row.cellData, true);
135
- var cellToClear = newCellData[colIdx];
136
- delete cellToClear.value;
137
- newCellData.splice(colIdx, 1, cellToClear);
138
+ // let cellToClear = newCellData[colIdx];
139
+ // delete cellToClear.value;
140
+ // console.log({cellToClear})
141
+ /**
142
+ * this genNewRow does one very important thing apart from the obvious of clearing the value:
143
+ * it creates a fresh new row id, which changes the 'react key' of the row being rendered, which
144
+ * ensures the the RTE used within the cell is reinitiated and the previous value in it is cleared.
145
+ * (since RTEs are not controlled components)
146
+ */
147
+ newCellData.splice(colIdx, 1, genNewCell());
148
+ // console.log({newCellData})
138
149
  return __assign(__assign({}, row), { cellData: newCellData });
139
150
  });
151
+ // console.log({newData})
140
152
  onChange &&
141
153
  onChange(id, { data: newData, colWidthConfig: colWidthConfig });
142
154
  };
@@ -82,6 +82,12 @@ var handleClearRowContent = function (_a) {
82
82
  var value = _a.value, rowIdx = _a.rowIdx, onChange = _a.onChange, id = _a.id;
83
83
  var data = value.data, colWidthConfig = value.colWidthConfig;
84
84
  var newData = __spreadArray([], data, true);
85
+ /**
86
+ * this genNewRow does one very important thing apart from the obvious of clearing the value:
87
+ * it creates a fresh new row id, which changes the 'react key' of the row being rendered, which
88
+ * ensures the the RTE used within the cell is reinitiated and the previous value in it is cleared.
89
+ * (since RTEs are not controlled components)
90
+ */
85
91
  var newRow = genNewRow({ data: newData, rowIdx: rowIdx });
86
92
  newData.splice(rowIdx, 1, newRow);
87
93
  onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
@@ -104,7 +104,7 @@ function SimpleTable(_a) {
104
104
  defaultColWidth: defaultColWidth,
105
105
  });
106
106
  }, [_value]), value = _e.value, enableColActions = _e.enableColActions, //returns all possible actions config if no config.colHeaderData is defined. else undefined\
107
- enableRowActions = _e.enableRowActions, canToggleColHeaderStyle = _e.canToggleColHeaderStyle;
107
+ enableRowActions = _e.enableRowActions;
108
108
  var _f = (0, useResizeTableColumns_1.useResizeTableColumns)({
109
109
  setColWidthConfig: function (setterFn) {
110
110
  var newColWidthConfig = setterFn(value.colWidthConfig);
@@ -24,11 +24,12 @@ exports.prepInitValueFromConfigIfNoValue = void 0;
24
24
  var makeArrayFromLength_1 = require("../../../utils/makeArrayFromLength");
25
25
  var genHash_1 = require("./genHash");
26
26
  var prepInitValueFromConfigIfNoValue = function (_a) {
27
- var _b, _c;
27
+ var _b, _c, _d;
28
28
  var _value = _a._value, config = _a.config, defaultColWidth = _a.defaultColWidth;
29
29
  //if colHeaderData is defined then that decides the noOfCols.
30
30
  var noOfCols = ((_b = config.colHeaderData) === null || _b === void 0 ? void 0 : _b.length) || config.noOfCols;
31
- var value = ((_c = _value === null || _value === void 0 ? void 0 : _value.data) === null || _c === void 0 ? void 0 : _c.length) > 0 //value exists in the correct shape
31
+ var noOfRows = ((_c = config.rowHeaderData) === null || _c === void 0 ? void 0 : _c.length) || config.noOfRows;
32
+ var value = ((_d = _value === null || _value === void 0 ? void 0 : _value.data) === null || _d === void 0 ? void 0 : _d.length) > 0 //value exists in the correct shape
32
33
  ? _value
33
34
  : Array.isArray(_value) && _value.length > 0 //value exists but in deprecated shape
34
35
  ? {
@@ -40,7 +41,7 @@ var prepInitValueFromConfigIfNoValue = function (_a) {
40
41
  } //backwards compat
41
42
  : {
42
43
  data: __spreadArray([], insertRowAndCellIds({
43
- noOfRows: config.noOfRows,
44
+ noOfRows: noOfRows,
44
45
  noOfCols: noOfCols,
45
46
  }), true),
46
47
  colWidthConfig: getInitColWidthConfigs({ noOfCols: noOfCols, defaultColWidth: defaultColWidth }),
@@ -48,7 +49,7 @@ var prepInitValueFromConfigIfNoValue = function (_a) {
48
49
  return {
49
50
  value: value,
50
51
  enableColActions: config.colHeaderData ? false : true,
51
- enableRowActions: true,
52
+ enableRowActions: config.rowHeaderData ? false : true,
52
53
  canToggleColHeaderStyle: !!!config.colHeaderData, // meaning its true if no config.colHeaderData is defined. else false
53
54
  };
54
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.88.0",
3
+ "version": "2.88.2",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",