react-table-edit 1.2.34 → 1.2.36

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.
package/dist/index.js CHANGED
@@ -3334,9 +3334,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3334
3334
  },
3335
3335
  onBlur: () => {
3336
3336
  if (floatValue !== row[col.field]) {
3337
- row[col.field] = floatValue;
3337
+ row[col.field] = !isNaN(floatValue) ? floatValue : 0;
3338
3338
  if (col.callback) {
3339
- col.callback(floatValue, indexRow);
3339
+ col.callback(row[col.field], indexRow);
3340
3340
  }
3341
3341
  handleDataChange(row, col, indexRow);
3342
3342
  }
@@ -3344,9 +3344,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3344
3344
  onKeyDown: (e) => {
3345
3345
  if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
3346
3346
  if (floatValue !== row[col.field]) {
3347
- row[col.field] = floatValue;
3347
+ row[col.field] = !isNaN(floatValue) ? floatValue : 0;
3348
3348
  if (col.callback) {
3349
- col.callback(floatValue, indexRow);
3349
+ col.callback(row[col.field], indexRow);
3350
3350
  }
3351
3351
  handleDataChange(row, col, indexRow);
3352
3352
  }
@@ -3418,9 +3418,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3418
3418
  {
3419
3419
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
3420
3420
  style: { textAlign: col.textAlign, height: 29 },
3421
- defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
3421
+ value: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
3422
3422
  className: (0, import_classnames14.default)("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
3423
- onBlur: (val) => {
3423
+ onChange: (val) => {
3424
3424
  if (row[col.field] != val.target?.value) {
3425
3425
  row[col.field] = val.target?.value;
3426
3426
  if (col.callback) {
@@ -3430,15 +3430,6 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3430
3430
  }
3431
3431
  },
3432
3432
  onKeyDown: (e) => {
3433
- if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
3434
- if (row[col.field] != e.target?.value) {
3435
- row[col.field] = e.target?.value;
3436
- handleDataChange(row, col, indexRow);
3437
- if (col.callback) {
3438
- col.callback(e.target.value, indexRow);
3439
- }
3440
- }
3441
- }
3442
3433
  checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
3443
3434
  },
3444
3435
  onPaste: (e) => {
@@ -4035,7 +4026,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
4035
4026
  `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
4036
4027
  ] }) : value }),
4037
4028
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { id: `error-${indexRow}-${indexCol}`, className: (0, import_classnames14.default)("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_becoxy_icons7.AlertCircle, { fontSize: 15.5 }) }),
4038
- !(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap11.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : col.editType === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
4029
+ !(typeDis === 1 && !refreshRow) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap11.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : col.editType === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
4039
4030
  " ",
4040
4031
  `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
4041
4032
  ] }) : value }),
@@ -4057,10 +4048,6 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
4057
4048
  ) }, indexCol);
4058
4049
  }
4059
4050
  };
4060
- const checkOverflow = (indexRow, indexCol) => {
4061
- const element = document.getElementById(`content-${idTable}-row${indexRow}col-${indexCol}`);
4062
- return element && element.scrollWidth > element.clientWidth;
4063
- };
4064
4051
  const renderFooterCol = (col, indexCol) => {
4065
4052
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4066
4053
  "td",
package/dist/index.mjs CHANGED
@@ -3304,9 +3304,9 @@ var TableEdit = forwardRef4((props, ref) => {
3304
3304
  },
3305
3305
  onBlur: () => {
3306
3306
  if (floatValue !== row[col.field]) {
3307
- row[col.field] = floatValue;
3307
+ row[col.field] = !isNaN(floatValue) ? floatValue : 0;
3308
3308
  if (col.callback) {
3309
- col.callback(floatValue, indexRow);
3309
+ col.callback(row[col.field], indexRow);
3310
3310
  }
3311
3311
  handleDataChange(row, col, indexRow);
3312
3312
  }
@@ -3314,9 +3314,9 @@ var TableEdit = forwardRef4((props, ref) => {
3314
3314
  onKeyDown: (e) => {
3315
3315
  if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
3316
3316
  if (floatValue !== row[col.field]) {
3317
- row[col.field] = floatValue;
3317
+ row[col.field] = !isNaN(floatValue) ? floatValue : 0;
3318
3318
  if (col.callback) {
3319
- col.callback(floatValue, indexRow);
3319
+ col.callback(row[col.field], indexRow);
3320
3320
  }
3321
3321
  handleDataChange(row, col, indexRow);
3322
3322
  }
@@ -3388,9 +3388,9 @@ var TableEdit = forwardRef4((props, ref) => {
3388
3388
  {
3389
3389
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
3390
3390
  style: { textAlign: col.textAlign, height: 29 },
3391
- defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
3391
+ value: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
3392
3392
  className: classnames9("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
3393
- onBlur: (val) => {
3393
+ onChange: (val) => {
3394
3394
  if (row[col.field] != val.target?.value) {
3395
3395
  row[col.field] = val.target?.value;
3396
3396
  if (col.callback) {
@@ -3400,15 +3400,6 @@ var TableEdit = forwardRef4((props, ref) => {
3400
3400
  }
3401
3401
  },
3402
3402
  onKeyDown: (e) => {
3403
- if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
3404
- if (row[col.field] != e.target?.value) {
3405
- row[col.field] = e.target?.value;
3406
- handleDataChange(row, col, indexRow);
3407
- if (col.callback) {
3408
- col.callback(e.target.value, indexRow);
3409
- }
3410
- }
3411
- }
3412
3403
  checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
3413
3404
  },
3414
3405
  onPaste: (e) => {
@@ -4005,7 +3996,7 @@ var TableEdit = forwardRef4((props, ref) => {
4005
3996
  `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
4006
3997
  ] }) : value }),
4007
3998
  /* @__PURE__ */ jsx16("span", { id: `error-${indexRow}-${indexCol}`, className: classnames9("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ jsx16(AlertCircle, { fontSize: 15.5 }) }),
4008
- !(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ jsx16(UncontrolledTooltip5, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : col.editType === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ jsxs15("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
3999
+ !(typeDis === 1 && !refreshRow) && /* @__PURE__ */ jsx16(UncontrolledTooltip5, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : col.editType === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ jsxs15("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
4009
4000
  " ",
4010
4001
  `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
4011
4002
  ] }) : value }),
@@ -4027,10 +4018,6 @@ var TableEdit = forwardRef4((props, ref) => {
4027
4018
  ) }, indexCol);
4028
4019
  }
4029
4020
  };
4030
- const checkOverflow = (indexRow, indexCol) => {
4031
- const element = document.getElementById(`content-${idTable}-row${indexRow}col-${indexCol}`);
4032
- return element && element.scrollWidth > element.clientWidth;
4033
- };
4034
4021
  const renderFooterCol = (col, indexCol) => {
4035
4022
  return /* @__PURE__ */ jsx16(Fragment20, { children: col.visible !== false && /* @__PURE__ */ jsx16(
4036
4023
  "td",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
- "version": "1.2.34",
3
+ "version": "1.2.36",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",