react-table-edit 0.5.9 → 0.6.0

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
@@ -1867,10 +1867,13 @@ var SelectTable = (0, import_react13.forwardRef)((props, ref) => {
1867
1867
  children: [
1868
1868
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "select-table-container", children: [
1869
1869
  isMulti ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: (0, import_classnames11.default)("select-value is-mutil", { "d-none": searchTerm }), children: value?.map((ele, index) => {
1870
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
1871
- index === 0 ? "" : ", ",
1872
- ele[fieldLabel ?? "label"]
1873
- ] }, index);
1870
+ const element = options.find((e) => e[fieldValue ?? "value"] === ele);
1871
+ if (element) {
1872
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
1873
+ index === 0 ? "" : ", ",
1874
+ element[fieldLabel ?? "label"]
1875
+ ] }, index);
1876
+ }
1874
1877
  }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_classnames11.default)("select-value", { "d-none": searchTerm }), children: [
1875
1878
  value ? formatOptionLabel ? formatOptionLabel(value) : value[fieldLabel ?? "label"] : "",
1876
1879
  " "
@@ -1937,7 +1940,7 @@ var SelectTable = (0, import_react13.forwardRef)((props, ref) => {
1937
1940
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1938
1941
  import_reactstrap8.Input,
1939
1942
  {
1940
- checked: (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length,
1943
+ defaultChecked: (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length,
1941
1944
  type: "checkbox",
1942
1945
  className: (0, import_classnames11.default)("cursor-pointer", { "d-none": !isMulti }),
1943
1946
  style: { textAlign: "center", marginTop: 6 },
@@ -1962,7 +1965,7 @@ var SelectTable = (0, import_react13.forwardRef)((props, ref) => {
1962
1965
  ] }) }),
1963
1966
  (optionsLoad ? optionsLoad : options).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
1964
1967
  if (loadOptions || checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
1965
- const isSelected = isMulti && value?.some((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1968
+ const isSelected = isMulti && value?.some((x) => x === row[fieldValue ?? "value"]);
1966
1969
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1967
1970
  "tr",
1968
1971
  {
@@ -1976,16 +1979,18 @@ var SelectTable = (0, import_react13.forwardRef)((props, ref) => {
1976
1979
  style: { width: 40, textAlign: "center", padding: 0, paddingBottom: 6 },
1977
1980
  onClick: (e) => {
1978
1981
  if (isMulti) {
1979
- const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1982
+ const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
1980
1983
  if (index > -1) {
1981
1984
  value?.splice(index, 1);
1982
- onChange(value);
1985
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
1986
+ onChange(valueArr);
1983
1987
  } else {
1984
1988
  if (value) {
1985
- value?.push(row);
1986
- onChange(value);
1989
+ value?.push(row[fieldValue ?? "value"]);
1990
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
1991
+ onChange(valueArr);
1987
1992
  } else {
1988
- onChange([row]);
1993
+ onChange([row[fieldValue ?? "value"]]);
1989
1994
  }
1990
1995
  }
1991
1996
  e.stopPropagation();
@@ -2026,16 +2031,18 @@ var SelectTable = (0, import_react13.forwardRef)((props, ref) => {
2026
2031
  },
2027
2032
  onClick: (e) => {
2028
2033
  if (isMulti) {
2029
- const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
2034
+ const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
2030
2035
  if (index > -1) {
2031
2036
  value?.splice(index, 1);
2032
- onChange(value);
2037
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
2038
+ onChange(valueArr);
2033
2039
  } else {
2034
2040
  if (value) {
2035
- value?.push(row);
2036
- onChange(value);
2041
+ value?.push(row[fieldValue ?? "value"]);
2042
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
2043
+ onChange(valueArr);
2037
2044
  } else {
2038
- onChange([row]);
2045
+ onChange([row[fieldValue ?? "value"]]);
2039
2046
  }
2040
2047
  }
2041
2048
  } else {
package/dist/index.mjs CHANGED
@@ -1831,10 +1831,13 @@ var SelectTable = forwardRef2((props, ref) => {
1831
1831
  children: [
1832
1832
  /* @__PURE__ */ jsxs12("div", { className: "select-table-container", children: [
1833
1833
  isMulti ? /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsx13("div", { className: classnames6("select-value is-mutil", { "d-none": searchTerm }), children: value?.map((ele, index) => {
1834
- return /* @__PURE__ */ jsxs12("span", { children: [
1835
- index === 0 ? "" : ", ",
1836
- ele[fieldLabel ?? "label"]
1837
- ] }, index);
1834
+ const element = options.find((e) => e[fieldValue ?? "value"] === ele);
1835
+ if (element) {
1836
+ return /* @__PURE__ */ jsxs12("span", { children: [
1837
+ index === 0 ? "" : ", ",
1838
+ element[fieldLabel ?? "label"]
1839
+ ] }, index);
1840
+ }
1838
1841
  }) }) }) : /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsxs12("div", { className: classnames6("select-value", { "d-none": searchTerm }), children: [
1839
1842
  value ? formatOptionLabel ? formatOptionLabel(value) : value[fieldLabel ?? "label"] : "",
1840
1843
  " "
@@ -1901,7 +1904,7 @@ var SelectTable = forwardRef2((props, ref) => {
1901
1904
  children: /* @__PURE__ */ jsx13(
1902
1905
  Input6,
1903
1906
  {
1904
- checked: (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length,
1907
+ defaultChecked: (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length,
1905
1908
  type: "checkbox",
1906
1909
  className: classnames6("cursor-pointer", { "d-none": !isMulti }),
1907
1910
  style: { textAlign: "center", marginTop: 6 },
@@ -1926,7 +1929,7 @@ var SelectTable = forwardRef2((props, ref) => {
1926
1929
  ] }) }),
1927
1930
  (optionsLoad ? optionsLoad : options).length > 0 ? /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsx13("tbody", { className: "r-select-gridcontent", children: (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
1928
1931
  if (loadOptions || checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
1929
- const isSelected = isMulti && value?.some((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1932
+ const isSelected = isMulti && value?.some((x) => x === row[fieldValue ?? "value"]);
1930
1933
  return /* @__PURE__ */ jsxs12(
1931
1934
  "tr",
1932
1935
  {
@@ -1940,16 +1943,18 @@ var SelectTable = forwardRef2((props, ref) => {
1940
1943
  style: { width: 40, textAlign: "center", padding: 0, paddingBottom: 6 },
1941
1944
  onClick: (e) => {
1942
1945
  if (isMulti) {
1943
- const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1946
+ const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
1944
1947
  if (index > -1) {
1945
1948
  value?.splice(index, 1);
1946
- onChange(value);
1949
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
1950
+ onChange(valueArr);
1947
1951
  } else {
1948
1952
  if (value) {
1949
- value?.push(row);
1950
- onChange(value);
1953
+ value?.push(row[fieldValue ?? "value"]);
1954
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
1955
+ onChange(valueArr);
1951
1956
  } else {
1952
- onChange([row]);
1957
+ onChange([row[fieldValue ?? "value"]]);
1953
1958
  }
1954
1959
  }
1955
1960
  e.stopPropagation();
@@ -1990,16 +1995,18 @@ var SelectTable = forwardRef2((props, ref) => {
1990
1995
  },
1991
1996
  onClick: (e) => {
1992
1997
  if (isMulti) {
1993
- const index = value?.findIndex((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1998
+ const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
1994
1999
  if (index > -1) {
1995
2000
  value?.splice(index, 1);
1996
- onChange(value);
2001
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
2002
+ onChange(valueArr);
1997
2003
  } else {
1998
2004
  if (value) {
1999
- value?.push(row);
2000
- onChange(value);
2005
+ value?.push(row[fieldValue ?? "value"]);
2006
+ const valueArr = options.filter((ele) => value?.some((x) => x === ele[fieldValue ?? "value"]));
2007
+ onChange(valueArr);
2001
2008
  } else {
2002
- onChange([row]);
2009
+ onChange([row[fieldValue ?? "value"]]);
2003
2010
  }
2004
2011
  }
2005
2012
  } else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.5.9",
4
+ "version": "0.6.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",