react-table-edit 0.7.0 → 0.7.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.
package/dist/index.js CHANGED
@@ -993,8 +993,7 @@ var EditForm = (0, import_react8.forwardRef)((props, ref) => {
993
993
  style: { backgroundColor: "#FFF", textAlign: textAlign ?? "left" },
994
994
  placeholder,
995
995
  innerRef: inputRef,
996
- className: (0, import_classnames6.default)("input-display input-numeric"),
997
- invalid,
996
+ className: (0, import_classnames6.default)("input-display input-numeric", { "is-invalid": invalid }),
998
997
  value: displayValue,
999
998
  onClick: handleOnClick,
1000
999
  onKeyDown: (e) => handleOnKeyDown(e),
@@ -1681,7 +1680,9 @@ var SelectTable = (0, import_react12.forwardRef)((props, ref) => {
1681
1680
  flag = true;
1682
1681
  } else if (e.code === "Escape" || e.code === "Space") {
1683
1682
  if (dropdownOpen) {
1684
- onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
1683
+ if ((optionsLoad ? optionsLoad : options)[indexFocus]) {
1684
+ onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
1685
+ }
1685
1686
  }
1686
1687
  if (!searchTerm) {
1687
1688
  handleOpenClose();
@@ -2007,6 +2008,7 @@ var SelectTable = (0, import_react12.forwardRef)((props, ref) => {
2007
2008
  isOpen: dropdownOpen,
2008
2009
  toggle: () => {
2009
2010
  },
2011
+ onMouseDown: (e) => e.preventDefault(),
2010
2012
  children: [
2011
2013
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2012
2014
  import_reactstrap8.DropdownToggle,
@@ -2071,7 +2073,7 @@ var SelectTable = (0, import_react12.forwardRef)((props, ref) => {
2071
2073
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
2072
2074
  }
2073
2075
  ),
2074
- !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "select-table-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
2076
+ !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
2075
2077
  ]
2076
2078
  }
2077
2079
  ),
@@ -2536,7 +2538,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
2536
2538
  }
2537
2539
  }
2538
2540
  );
2539
- case "selectTable":
2541
+ case "select":
2540
2542
  let valueSelect;
2541
2543
  let optionsSelect = [];
2542
2544
  if (col.selectSettings?.optionsField) {
@@ -3094,7 +3096,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3094
3096
  dataSource.push(dataRow);
3095
3097
  }
3096
3098
  for (let index = 0; index < arrayCol.length; index++) {
3097
- const stringData = arrayCol[index];
3099
+ const stringData = arrayCol[index].toString().trim();
3098
3100
  const column = getColumn(col, index);
3099
3101
  if (column) {
3100
3102
  if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
@@ -3114,6 +3116,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3114
3116
  const date = new Date(stringData);
3115
3117
  if (!isNaN(date.getTime())) {
3116
3118
  dataRow[column.field] = date;
3119
+ if (column.callback) {
3120
+ column.callback(date, indexRow);
3121
+ }
3117
3122
  } else {
3118
3123
  notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
3119
3124
  }
@@ -3121,24 +3126,17 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3121
3126
  const number = Number(stringData);
3122
3127
  if (!isNaN(number)) {
3123
3128
  dataRow[column.field] = number;
3129
+ if (column.callback) {
3130
+ column.callback(number, indexRow);
3131
+ }
3124
3132
  } else {
3125
3133
  notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
3126
3134
  }
3127
- } else if (column.editType?.includes("select") && !column.selectSettings?.loadOptions) {
3128
- let optionSelect = [];
3129
- if (column.selectSettings?.optionsField) {
3130
- optionSelect = dataRow[column.selectSettings?.optionsField] ? dataRow[column.selectSettings?.optionsField] : [];
3131
- } else {
3132
- optionSelect = column.selectSettings?.options ? column.selectSettings?.validateOption ? column.selectSettings?.options.filter((item2) => column.selectSettings?.validateOption(item2, row)) : column.selectSettings?.options : [];
3133
- }
3134
- let valueAsyncSelect = !isNullOrUndefined(dataRow[column.field]) && dataRow[column.field] !== "" ? optionSelect?.find((val) => val[column.selectSettings?.fieldValue ?? "value"] === dataRow[column.field]) : void 0;
3135
- if (valueAsyncSelect) {
3136
- dataRow[column.field] = stringData;
3137
- } else {
3138
- notificationError(t("PasteExcelNotExist", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
3139
- }
3140
3135
  } else {
3141
3136
  dataRow[column.field] = stringData;
3137
+ if (column.callback) {
3138
+ column.callback(stringData, indexRow);
3139
+ }
3142
3140
  }
3143
3141
  }
3144
3142
  }
package/dist/index.mjs CHANGED
@@ -950,8 +950,7 @@ var EditForm = forwardRef((props, ref) => {
950
950
  style: { backgroundColor: "#FFF", textAlign: textAlign ?? "left" },
951
951
  placeholder,
952
952
  innerRef: inputRef,
953
- className: classNames2("input-display input-numeric"),
954
- invalid,
953
+ className: classNames2("input-display input-numeric", { "is-invalid": invalid }),
955
954
  value: displayValue,
956
955
  onClick: handleOnClick,
957
956
  onKeyDown: (e) => handleOnKeyDown(e),
@@ -1647,7 +1646,9 @@ var SelectTable = forwardRef2((props, ref) => {
1647
1646
  flag = true;
1648
1647
  } else if (e.code === "Escape" || e.code === "Space") {
1649
1648
  if (dropdownOpen) {
1650
- onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
1649
+ if ((optionsLoad ? optionsLoad : options)[indexFocus]) {
1650
+ onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
1651
+ }
1651
1652
  }
1652
1653
  if (!searchTerm) {
1653
1654
  handleOpenClose();
@@ -1973,6 +1974,7 @@ var SelectTable = forwardRef2((props, ref) => {
1973
1974
  isOpen: dropdownOpen,
1974
1975
  toggle: () => {
1975
1976
  },
1977
+ onMouseDown: (e) => e.preventDefault(),
1976
1978
  children: [
1977
1979
  /* @__PURE__ */ jsxs12(
1978
1980
  DropdownToggle2,
@@ -2037,7 +2039,7 @@ var SelectTable = forwardRef2((props, ref) => {
2037
2039
  children: /* @__PURE__ */ jsx12("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ jsx12("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
2038
2040
  }
2039
2041
  ),
2040
- !isDisabled && /* @__PURE__ */ jsx12("div", { className: "select-table-indicator", children: /* @__PURE__ */ jsx12("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx12("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
2042
+ !isDisabled && /* @__PURE__ */ jsx12("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx12("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx12("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
2041
2043
  ]
2042
2044
  }
2043
2045
  ),
@@ -2502,7 +2504,7 @@ var TableEdit = forwardRef3((props, ref) => {
2502
2504
  }
2503
2505
  }
2504
2506
  );
2505
- case "selectTable":
2507
+ case "select":
2506
2508
  let valueSelect;
2507
2509
  let optionsSelect = [];
2508
2510
  if (col.selectSettings?.optionsField) {
@@ -3060,7 +3062,7 @@ var TableEdit = forwardRef3((props, ref) => {
3060
3062
  dataSource.push(dataRow);
3061
3063
  }
3062
3064
  for (let index = 0; index < arrayCol.length; index++) {
3063
- const stringData = arrayCol[index];
3065
+ const stringData = arrayCol[index].toString().trim();
3064
3066
  const column = getColumn(col, index);
3065
3067
  if (column) {
3066
3068
  if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
@@ -3080,6 +3082,9 @@ var TableEdit = forwardRef3((props, ref) => {
3080
3082
  const date = new Date(stringData);
3081
3083
  if (!isNaN(date.getTime())) {
3082
3084
  dataRow[column.field] = date;
3085
+ if (column.callback) {
3086
+ column.callback(date, indexRow);
3087
+ }
3083
3088
  } else {
3084
3089
  notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
3085
3090
  }
@@ -3087,24 +3092,17 @@ var TableEdit = forwardRef3((props, ref) => {
3087
3092
  const number = Number(stringData);
3088
3093
  if (!isNaN(number)) {
3089
3094
  dataRow[column.field] = number;
3095
+ if (column.callback) {
3096
+ column.callback(number, indexRow);
3097
+ }
3090
3098
  } else {
3091
3099
  notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
3092
3100
  }
3093
- } else if (column.editType?.includes("select") && !column.selectSettings?.loadOptions) {
3094
- let optionSelect = [];
3095
- if (column.selectSettings?.optionsField) {
3096
- optionSelect = dataRow[column.selectSettings?.optionsField] ? dataRow[column.selectSettings?.optionsField] : [];
3097
- } else {
3098
- optionSelect = column.selectSettings?.options ? column.selectSettings?.validateOption ? column.selectSettings?.options.filter((item2) => column.selectSettings?.validateOption(item2, row)) : column.selectSettings?.options : [];
3099
- }
3100
- let valueAsyncSelect = !isNullOrUndefined(dataRow[column.field]) && dataRow[column.field] !== "" ? optionSelect?.find((val) => val[column.selectSettings?.fieldValue ?? "value"] === dataRow[column.field]) : void 0;
3101
- if (valueAsyncSelect) {
3102
- dataRow[column.field] = stringData;
3103
- } else {
3104
- notificationError(t("PasteExcelNotExist", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
3105
- }
3106
3101
  } else {
3107
3102
  dataRow[column.field] = stringData;
3103
+ if (column.callback) {
3104
+ column.callback(stringData, indexRow);
3105
+ }
3108
3106
  }
3109
3107
  }
3110
3108
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.7.0",
4
+ "version": "0.7.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",