react-table-edit 0.7.4 → 0.7.6

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.d.mts CHANGED
@@ -65,6 +65,7 @@ type ISettingFormElement = {
65
65
  footerTemplate?: any;
66
66
  onChangeField?: any;
67
67
  openOnFocus?: boolean;
68
+ isClearable?: boolean;
68
69
  };
69
70
  type ISettingSelectElement = {
70
71
  isClearable?: boolean;
package/dist/index.d.ts CHANGED
@@ -65,6 +65,7 @@ type ISettingFormElement = {
65
65
  footerTemplate?: any;
66
66
  onChangeField?: any;
67
67
  openOnFocus?: boolean;
68
+ isClearable?: boolean;
68
69
  };
69
70
  type ISettingSelectElement = {
70
71
  isClearable?: boolean;
package/dist/index.js CHANGED
@@ -28,11 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // index.ts
31
- var Table_edit_exports = {};
32
- __export(Table_edit_exports, {
31
+ var Table_Edit_exports = {};
32
+ __export(Table_Edit_exports, {
33
33
  SelectTable: () => SelectTable,
34
34
  TabsMenuComponent: () => TabsMenuComponent,
35
- default: () => Table_edit_default,
35
+ default: () => Table_Edit_default,
36
36
  formartNumberic: () => formartNumberic,
37
37
  generateUUID: () => generateUUID,
38
38
  isNullOrUndefined: () => isNullOrUndefined,
@@ -49,7 +49,7 @@ __export(Table_edit_exports, {
49
49
  roundNumber: () => roundNumber,
50
50
  useOnClickOutside: () => useOnClickOutside
51
51
  });
52
- module.exports = __toCommonJS(Table_edit_exports);
52
+ module.exports = __toCommonJS(Table_Edit_exports);
53
53
 
54
54
  // test-app/src/component/table/index.tsx
55
55
  var import_react16 = require("react");
@@ -749,6 +749,7 @@ var EditForm = (0, import_react8.forwardRef)((props, ref) => {
749
749
  minWidth,
750
750
  onPaste,
751
751
  openOnFocus,
752
+ isClearable,
752
753
  labelSize = "label-small"
753
754
  } = props;
754
755
  const { innerWidth } = window;
@@ -1026,21 +1027,46 @@ var EditForm = (0, import_react8.forwardRef)((props, ref) => {
1026
1027
  ),
1027
1028
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "d-flex justify-content-between p-50", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: [
1028
1029
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-primary py-25", style: { fontSize: 12 }, children: footerTemplate ? footerTemplate(rowData) : "" }),
1029
- !onChangeField ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1030
- import_reactstrap6.Button,
1031
- {
1032
- ref: buttonRef,
1033
- color: "primary",
1034
- className: "btn btn-primary py-25 px-50",
1035
- onClick: handleSubmit(handleOnSubmit),
1036
- onKeyDown: (e) => {
1037
- if (e.code === "Tab") {
1038
- closeMenu();
1039
- }
1040
- },
1041
- children: t("Save")
1042
- }
1043
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, {})
1030
+ !onChangeField ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "d-flex justify-content-end", children: [
1031
+ isClearable && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1032
+ import_reactstrap6.Button,
1033
+ {
1034
+ ref: buttonRef,
1035
+ className: "btn me-50 py-25 px-50",
1036
+ outline: true,
1037
+ onClick: () => {
1038
+ itemsField.forEach((e) => {
1039
+ if (e.type === "numeric") {
1040
+ setValue(e.name, 0);
1041
+ } else {
1042
+ setValue(e.name, "");
1043
+ }
1044
+ });
1045
+ },
1046
+ onKeyDown: (e) => {
1047
+ if (e.code === "Tab") {
1048
+ closeMenu();
1049
+ }
1050
+ },
1051
+ children: t("Clear")
1052
+ }
1053
+ ),
1054
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1055
+ import_reactstrap6.Button,
1056
+ {
1057
+ ref: buttonRef,
1058
+ color: "primary",
1059
+ className: "btn btn-primary py-25 px-50",
1060
+ onClick: handleSubmit(handleOnSubmit),
1061
+ onKeyDown: (e) => {
1062
+ if (e.code === "Tab") {
1063
+ closeMenu();
1064
+ }
1065
+ },
1066
+ children: t("Save")
1067
+ }
1068
+ )
1069
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, {})
1044
1070
  ] })
1045
1071
  ] }) })
1046
1072
  }
@@ -3073,13 +3099,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3073
3099
  }
3074
3100
  };
3075
3101
  const getColumn = (col, index) => {
3076
- const column = contentColumns[col + index];
3102
+ const column = contentColumns.filter((e) => e.visible !== false)[col + index];
3077
3103
  if (column) {
3078
- if (column.visible !== false) {
3079
- return { ...column };
3080
- } else {
3081
- return getColumn(col, index + 1);
3082
- }
3104
+ return { ...column };
3083
3105
  }
3084
3106
  return void 0;
3085
3107
  };
@@ -3087,27 +3109,28 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3087
3109
  const clipboard = (e.clipboardData || window.Clipboard).getData("text");
3088
3110
  const rowsClipboard = clipboard.trimEnd().split("\n");
3089
3111
  setIndexFocus(void 0);
3112
+ if (rowsClipboard.length > 200) {
3113
+ messageBoxError(t, "You can only paste up to 200 rows.");
3114
+ }
3090
3115
  if (rowsClipboard.length > 0) {
3091
3116
  const columnsDataChange = [];
3092
3117
  for (let index = 0; index < rowsClipboard[0].trimEnd().split(" ").length; index++) {
3093
3118
  const stringData = [];
3094
3119
  rowsClipboard.forEach((element) => {
3095
- if (element.trimEnd().split(" ")[index]) {
3120
+ if (element.trimEnd().split(" ")[index] && !stringData.includes(element.trimEnd().split(" ")[index].toString().trim())) {
3096
3121
  stringData.push(element.trimEnd().split(" ")[index].toString().trim());
3097
3122
  }
3098
3123
  });
3099
3124
  const column = getColumn(col, index);
3100
3125
  if (column) {
3101
- if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable) {
3102
- if (column.onPasteValidate) {
3103
- const rs = await column.onPasteValidate(stringData.join(","), 0, dataSource[currenRowIndex + 0]);
3104
- if (rs) {
3105
- column.resultValidate = rs;
3106
- }
3126
+ if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
3127
+ const rs = await column.onPasteValidate(stringData.join(","), 0, dataSource[currenRowIndex + 0]);
3128
+ if (rs) {
3129
+ column.resultValidate = rs;
3107
3130
  }
3108
3131
  }
3132
+ columnsDataChange.push(column);
3109
3133
  }
3110
- columnsDataChange.push(column);
3111
3134
  }
3112
3135
  for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
3113
3136
  const item = rowsClipboard[indexRow];
@@ -3121,8 +3144,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
3121
3144
  const stringData = colsClipboard[index].toString().trim();
3122
3145
  const column = columnsDataChange[index];
3123
3146
  if (column) {
3124
- console.log(!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow]));
3125
- if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) {
3147
+ if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable || column.onPaste) {
3126
3148
  if (column.onPasteValidate && column.resultValidate) {
3127
3149
  const rs = column.resultValidate.find((item2) => item2[column.selectSettings?.fieldValue] === stringData);
3128
3150
  if (rs) {
@@ -3776,7 +3798,7 @@ var TabsMenuComponent = ({
3776
3798
  };
3777
3799
 
3778
3800
  // index.ts
3779
- var Table_edit_default = table_default;
3801
+ var Table_Edit_default = table_default;
3780
3802
  // Annotate the CommonJS export names for ESM import in node:
3781
3803
  0 && (module.exports = {
3782
3804
  SelectTable,
package/dist/index.mjs CHANGED
@@ -706,6 +706,7 @@ var EditForm = forwardRef((props, ref) => {
706
706
  minWidth,
707
707
  onPaste,
708
708
  openOnFocus,
709
+ isClearable,
709
710
  labelSize = "label-small"
710
711
  } = props;
711
712
  const { innerWidth } = window;
@@ -983,21 +984,46 @@ var EditForm = forwardRef((props, ref) => {
983
984
  ),
984
985
  /* @__PURE__ */ jsxs7("div", { className: "d-flex justify-content-between p-50", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: [
985
986
  /* @__PURE__ */ jsx7("div", { className: "text-primary py-25", style: { fontSize: 12 }, children: footerTemplate ? footerTemplate(rowData) : "" }),
986
- !onChangeField ? /* @__PURE__ */ jsx7(Fragment7, { children: /* @__PURE__ */ jsx7(
987
- Button,
988
- {
989
- ref: buttonRef,
990
- color: "primary",
991
- className: "btn btn-primary py-25 px-50",
992
- onClick: handleSubmit(handleOnSubmit),
993
- onKeyDown: (e) => {
994
- if (e.code === "Tab") {
995
- closeMenu();
996
- }
997
- },
998
- children: t("Save")
999
- }
1000
- ) }) : /* @__PURE__ */ jsx7(Fragment7, {})
987
+ !onChangeField ? /* @__PURE__ */ jsxs7("div", { className: "d-flex justify-content-end", children: [
988
+ isClearable && /* @__PURE__ */ jsx7(
989
+ Button,
990
+ {
991
+ ref: buttonRef,
992
+ className: "btn me-50 py-25 px-50",
993
+ outline: true,
994
+ onClick: () => {
995
+ itemsField.forEach((e) => {
996
+ if (e.type === "numeric") {
997
+ setValue(e.name, 0);
998
+ } else {
999
+ setValue(e.name, "");
1000
+ }
1001
+ });
1002
+ },
1003
+ onKeyDown: (e) => {
1004
+ if (e.code === "Tab") {
1005
+ closeMenu();
1006
+ }
1007
+ },
1008
+ children: t("Clear")
1009
+ }
1010
+ ),
1011
+ /* @__PURE__ */ jsx7(
1012
+ Button,
1013
+ {
1014
+ ref: buttonRef,
1015
+ color: "primary",
1016
+ className: "btn btn-primary py-25 px-50",
1017
+ onClick: handleSubmit(handleOnSubmit),
1018
+ onKeyDown: (e) => {
1019
+ if (e.code === "Tab") {
1020
+ closeMenu();
1021
+ }
1022
+ },
1023
+ children: t("Save")
1024
+ }
1025
+ )
1026
+ ] }) : /* @__PURE__ */ jsx7(Fragment7, {})
1001
1027
  ] })
1002
1028
  ] }) })
1003
1029
  }
@@ -3039,13 +3065,9 @@ var TableEdit = forwardRef3((props, ref) => {
3039
3065
  }
3040
3066
  };
3041
3067
  const getColumn = (col, index) => {
3042
- const column = contentColumns[col + index];
3068
+ const column = contentColumns.filter((e) => e.visible !== false)[col + index];
3043
3069
  if (column) {
3044
- if (column.visible !== false) {
3045
- return { ...column };
3046
- } else {
3047
- return getColumn(col, index + 1);
3048
- }
3070
+ return { ...column };
3049
3071
  }
3050
3072
  return void 0;
3051
3073
  };
@@ -3053,27 +3075,28 @@ var TableEdit = forwardRef3((props, ref) => {
3053
3075
  const clipboard = (e.clipboardData || window.Clipboard).getData("text");
3054
3076
  const rowsClipboard = clipboard.trimEnd().split("\n");
3055
3077
  setIndexFocus(void 0);
3078
+ if (rowsClipboard.length > 200) {
3079
+ messageBoxError(t, "You can only paste up to 200 rows.");
3080
+ }
3056
3081
  if (rowsClipboard.length > 0) {
3057
3082
  const columnsDataChange = [];
3058
3083
  for (let index = 0; index < rowsClipboard[0].trimEnd().split(" ").length; index++) {
3059
3084
  const stringData = [];
3060
3085
  rowsClipboard.forEach((element) => {
3061
- if (element.trimEnd().split(" ")[index]) {
3086
+ if (element.trimEnd().split(" ")[index] && !stringData.includes(element.trimEnd().split(" ")[index].toString().trim())) {
3062
3087
  stringData.push(element.trimEnd().split(" ")[index].toString().trim());
3063
3088
  }
3064
3089
  });
3065
3090
  const column = getColumn(col, index);
3066
3091
  if (column) {
3067
- if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable) {
3068
- if (column.onPasteValidate) {
3069
- const rs = await column.onPasteValidate(stringData.join(","), 0, dataSource[currenRowIndex + 0]);
3070
- if (rs) {
3071
- column.resultValidate = rs;
3072
- }
3092
+ if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
3093
+ const rs = await column.onPasteValidate(stringData.join(","), 0, dataSource[currenRowIndex + 0]);
3094
+ if (rs) {
3095
+ column.resultValidate = rs;
3073
3096
  }
3074
3097
  }
3098
+ columnsDataChange.push(column);
3075
3099
  }
3076
- columnsDataChange.push(column);
3077
3100
  }
3078
3101
  for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
3079
3102
  const item = rowsClipboard[indexRow];
@@ -3087,8 +3110,7 @@ var TableEdit = forwardRef3((props, ref) => {
3087
3110
  const stringData = colsClipboard[index].toString().trim();
3088
3111
  const column = columnsDataChange[index];
3089
3112
  if (column) {
3090
- console.log(!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow]));
3091
- if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) {
3113
+ if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable || column.onPaste) {
3092
3114
  if (column.onPasteValidate && column.resultValidate) {
3093
3115
  const rs = column.resultValidate.find((item2) => item2[column.selectSettings?.fieldValue] === stringData);
3094
3116
  if (rs) {
@@ -3742,11 +3764,11 @@ var TabsMenuComponent = ({
3742
3764
  };
3743
3765
 
3744
3766
  // index.ts
3745
- var Table_edit_default = table_default;
3767
+ var Table_Edit_default = table_default;
3746
3768
  export {
3747
3769
  SelectTable,
3748
3770
  TabsMenuComponent,
3749
- Table_edit_default as default,
3771
+ Table_Edit_default as default,
3750
3772
  formartNumberic,
3751
3773
  generateUUID,
3752
3774
  isNullOrUndefined,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.7.4",
4
+ "version": "0.7.6",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",