react-table-edit 1.1.7 → 1.1.9

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
@@ -979,7 +979,6 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
979
979
  });
980
980
  const RenderTable = (props2) => {
981
981
  const {} = props2;
982
- let countDisplay = 0;
983
982
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
984
983
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { style: { width: "100%" }, children: [
985
984
  !(noHeader || (columns?.length ?? 0) === 0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { className: "r-select-row", role: "row", children: [
@@ -1014,15 +1013,12 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1014
1013
  return renderHeaderCol(col, index);
1015
1014
  })
1016
1015
  ] }) }),
1017
- (optionsLoad ? optionsLoad : options).length > 0 && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
1018
- if (!isMulti && loadOptions || checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
1019
- const isSelected = isMulti && value?.some((x) => x === row[fieldValue ?? "value"]);
1020
- countDisplay++;
1021
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RenderElement, { isSelected, indexRow, row }, `select-table-${indexRow}`);
1022
- }
1016
+ (optionsLoad ? optionsLoad : options)?.length > 0 && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
1017
+ const isSelected = isMulti && value?.some((x) => x === row[fieldValue ?? "value"]);
1018
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RenderElement, { isSelected: isSelected ?? false, indexRow, row }, `select-table-${indexRow}`);
1023
1019
  }) }) })
1024
1020
  ] }),
1025
- countDisplay === 0 && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "r-no-data", children: [
1021
+ ((optionsLoad ? optionsLoad : options)?.length ?? 0) === 0 && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "r-no-data", children: [
1026
1022
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
1027
1023
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
1028
1024
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
@@ -1090,9 +1086,24 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1090
1086
  value: searchTerm,
1091
1087
  onPaste: (e) => onPaste && !dropdownOpen && onPaste(e),
1092
1088
  onChange: (val) => {
1093
- if (!isMulti && loadOptions && val.target.value) {
1094
- setIsLoading(true);
1095
- loadOptions(val.target.value, callbackLoadOption);
1089
+ if (val.target.value) {
1090
+ if (!isMulti && loadOptions && val.target.value) {
1091
+ setIsLoading(true);
1092
+ loadOptions(val.target.value, callbackLoadOption);
1093
+ } else {
1094
+ clearTimeout(timeOutElement);
1095
+ timeOutElement = setTimeout(() => {
1096
+ const arr = [];
1097
+ options.forEach((row) => {
1098
+ if (checkSearch(val.target.value, row, columns ? columns : defaultColumns)) {
1099
+ arr.push(row);
1100
+ }
1101
+ });
1102
+ setOptionsLoad(arr);
1103
+ }, 500);
1104
+ }
1105
+ } else {
1106
+ loadOptions(void 0);
1096
1107
  }
1097
1108
  setSearchTerm(val.target.value);
1098
1109
  },
package/dist/index.mjs CHANGED
@@ -940,7 +940,6 @@ var SelectTable = forwardRef((props, ref) => {
940
940
  });
941
941
  const RenderTable = (props2) => {
942
942
  const {} = props2;
943
- let countDisplay = 0;
944
943
  return /* @__PURE__ */ jsxs5(Fragment6, { children: [
945
944
  /* @__PURE__ */ jsxs5("table", { style: { width: "100%" }, children: [
946
945
  !(noHeader || (columns?.length ?? 0) === 0) && /* @__PURE__ */ jsx5("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ jsxs5("tr", { className: "r-select-row", role: "row", children: [
@@ -975,15 +974,12 @@ var SelectTable = forwardRef((props, ref) => {
975
974
  return renderHeaderCol(col, index);
976
975
  })
977
976
  ] }) }),
978
- (optionsLoad ? optionsLoad : options).length > 0 && !isLoading && /* @__PURE__ */ jsx5(Fragment6, { children: /* @__PURE__ */ jsx5("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
979
- if (!isMulti && loadOptions || checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
980
- const isSelected = isMulti && value?.some((x) => x === row[fieldValue ?? "value"]);
981
- countDisplay++;
982
- return /* @__PURE__ */ jsx5(RenderElement, { isSelected, indexRow, row }, `select-table-${indexRow}`);
983
- }
977
+ (optionsLoad ? optionsLoad : options)?.length > 0 && !isLoading && /* @__PURE__ */ jsx5(Fragment6, { children: /* @__PURE__ */ jsx5("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
978
+ const isSelected = isMulti && value?.some((x) => x === row[fieldValue ?? "value"]);
979
+ return /* @__PURE__ */ jsx5(RenderElement, { isSelected: isSelected ?? false, indexRow, row }, `select-table-${indexRow}`);
984
980
  }) }) })
985
981
  ] }),
986
- countDisplay === 0 && !isLoading && /* @__PURE__ */ jsxs5("div", { className: "r-no-data", children: [
982
+ ((optionsLoad ? optionsLoad : options)?.length ?? 0) === 0 && !isLoading && /* @__PURE__ */ jsxs5("div", { className: "r-no-data", children: [
987
983
  /* @__PURE__ */ jsx5("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxs5("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
988
984
  /* @__PURE__ */ jsx5("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
989
985
  /* @__PURE__ */ jsxs5("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
@@ -1051,9 +1047,24 @@ var SelectTable = forwardRef((props, ref) => {
1051
1047
  value: searchTerm,
1052
1048
  onPaste: (e) => onPaste && !dropdownOpen && onPaste(e),
1053
1049
  onChange: (val) => {
1054
- if (!isMulti && loadOptions && val.target.value) {
1055
- setIsLoading(true);
1056
- loadOptions(val.target.value, callbackLoadOption);
1050
+ if (val.target.value) {
1051
+ if (!isMulti && loadOptions && val.target.value) {
1052
+ setIsLoading(true);
1053
+ loadOptions(val.target.value, callbackLoadOption);
1054
+ } else {
1055
+ clearTimeout(timeOutElement);
1056
+ timeOutElement = setTimeout(() => {
1057
+ const arr = [];
1058
+ options.forEach((row) => {
1059
+ if (checkSearch(val.target.value, row, columns ? columns : defaultColumns)) {
1060
+ arr.push(row);
1061
+ }
1062
+ });
1063
+ setOptionsLoad(arr);
1064
+ }, 500);
1065
+ }
1066
+ } else {
1067
+ loadOptions(void 0);
1057
1068
  }
1058
1069
  setSearchTerm(val.target.value);
1059
1070
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "1.1.7",
4
+ "version": "1.1.9",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",