react-table-edit 0.9.5 → 0.9.7

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
@@ -689,7 +689,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
689
689
  const listKeyUse = ["Escape", "Space", "Enter", "Tab", "NumpadEnter", "ArrowDown", "ArrowUp", "F9"];
690
690
  const handleOnKeyDown = (e) => {
691
691
  let key = "";
692
- if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code))) {
692
+ if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code) || (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter" || e.code === "Space") && !(optionsLoad ? optionsLoad : options)[indexFocus] || (e.code === "ArrowDown" || e.code === "ArrowUp") && (optionsLoad?.length ?? 0) === 0 && options.length === 0 || e.code === "Escape" && !(isClearable && value && !isDisabled))) {
693
693
  key = onKeyDown(e);
694
694
  if (key === "ArrowRight" || key === "ArrowLeft") {
695
695
  closeMenu();
@@ -700,8 +700,9 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
700
700
  if (e.code === "F9") {
701
701
  handleAdd();
702
702
  flag = true;
703
- } else if (e.code === "Escape" || e.code === "Space") {
704
- if (dropdownOpen) {
703
+ } else if (e.code === "Space") {
704
+ const newItem = (optionsLoad ? optionsLoad : options)[indexFocus];
705
+ if (dropdownOpen && newItem) {
705
706
  if ((optionsLoad ? optionsLoad : options)[indexFocus]) {
706
707
  onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
707
708
  }
@@ -710,14 +711,21 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
710
711
  handleOpenClose();
711
712
  flag = true;
712
713
  }
714
+ } else if (e.code === "Escape") {
715
+ if (dropdownOpen && isClearable && value && !isDisabled) {
716
+ onChange(void 0);
717
+ handleOpenClose();
718
+ flag = true;
719
+ }
713
720
  } else if (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter") {
714
- if (dropdownOpen) {
715
- onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
721
+ const newItem = (optionsLoad ? optionsLoad : options)[indexFocus];
722
+ if (dropdownOpen && newItem) {
723
+ onChange(newItem);
716
724
  handleOpenClose();
717
725
  flag = true;
718
726
  }
719
727
  } else if (e.code === "ArrowDown") {
720
- if (dropdownOpen) {
728
+ if (dropdownOpen && ((optionsLoad?.length ?? 0) > 0 || options.length > 0)) {
721
729
  let newIndex = 0;
722
730
  if (indexFocus >= 0) {
723
731
  newIndex = indexFocus + 1;
@@ -737,7 +745,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
737
745
  flag = true;
738
746
  }
739
747
  } else if (e.code === "ArrowUp") {
740
- if (dropdownOpen) {
748
+ if (dropdownOpen && ((optionsLoad?.length ?? 0) > 0 || options.length > 0)) {
741
749
  let newIndex = 0;
742
750
  if (indexFocus >= 0) {
743
751
  newIndex = indexFocus - 1;
@@ -1107,7 +1115,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1107
1115
  container: component,
1108
1116
  className: "formula-dropdown icon-dropdown p-0",
1109
1117
  style: {
1110
- width: menuWidth ? menuWidth : "min-content",
1118
+ width: "min-content",
1111
1119
  position: "fixed",
1112
1120
  borderRadius: 3,
1113
1121
  zIndex: 9999
@@ -2885,9 +2893,9 @@ var TableEdit = (0, import_react15.forwardRef)((props, ref) => {
2885
2893
  }
2886
2894
  }
2887
2895
  if ((tableElement.current?.scrollHeight ?? 0) > 0) {
2888
- if ((tableElement.current?.scrollTop ?? 0) > (row - 1) * 34) {
2889
- tableElement.current?.scrollTo({ behavior: "smooth", top: (row - 1) * 34 });
2890
- } else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 < row * 34 - (tableElement.current?.scrollTop ?? 0)) {
2896
+ if ((tableElement.current?.scrollTop ?? 0) > (row - 1) % (pagingSetting?.pageSize ?? 1) * 34) {
2897
+ tableElement.current?.scrollTo({ behavior: "smooth", top: (row - 1) % (pagingSetting?.pageSize ?? 1) * 34 });
2898
+ } else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 < row % (pagingSetting?.pageSize ?? 1) * 34 - (tableElement.current?.scrollTop ?? 0)) {
2891
2899
  tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
2892
2900
  }
2893
2901
  }
package/dist/index.mjs CHANGED
@@ -653,7 +653,7 @@ var SelectTable = forwardRef((props, ref) => {
653
653
  const listKeyUse = ["Escape", "Space", "Enter", "Tab", "NumpadEnter", "ArrowDown", "ArrowUp", "F9"];
654
654
  const handleOnKeyDown = (e) => {
655
655
  let key = "";
656
- if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code))) {
656
+ if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code) || (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter" || e.code === "Space") && !(optionsLoad ? optionsLoad : options)[indexFocus] || (e.code === "ArrowDown" || e.code === "ArrowUp") && (optionsLoad?.length ?? 0) === 0 && options.length === 0 || e.code === "Escape" && !(isClearable && value && !isDisabled))) {
657
657
  key = onKeyDown(e);
658
658
  if (key === "ArrowRight" || key === "ArrowLeft") {
659
659
  closeMenu();
@@ -664,8 +664,9 @@ var SelectTable = forwardRef((props, ref) => {
664
664
  if (e.code === "F9") {
665
665
  handleAdd();
666
666
  flag = true;
667
- } else if (e.code === "Escape" || e.code === "Space") {
668
- if (dropdownOpen) {
667
+ } else if (e.code === "Space") {
668
+ const newItem = (optionsLoad ? optionsLoad : options)[indexFocus];
669
+ if (dropdownOpen && newItem) {
669
670
  if ((optionsLoad ? optionsLoad : options)[indexFocus]) {
670
671
  onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
671
672
  }
@@ -674,14 +675,21 @@ var SelectTable = forwardRef((props, ref) => {
674
675
  handleOpenClose();
675
676
  flag = true;
676
677
  }
678
+ } else if (e.code === "Escape") {
679
+ if (dropdownOpen && isClearable && value && !isDisabled) {
680
+ onChange(void 0);
681
+ handleOpenClose();
682
+ flag = true;
683
+ }
677
684
  } else if (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter") {
678
- if (dropdownOpen) {
679
- onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
685
+ const newItem = (optionsLoad ? optionsLoad : options)[indexFocus];
686
+ if (dropdownOpen && newItem) {
687
+ onChange(newItem);
680
688
  handleOpenClose();
681
689
  flag = true;
682
690
  }
683
691
  } else if (e.code === "ArrowDown") {
684
- if (dropdownOpen) {
692
+ if (dropdownOpen && ((optionsLoad?.length ?? 0) > 0 || options.length > 0)) {
685
693
  let newIndex = 0;
686
694
  if (indexFocus >= 0) {
687
695
  newIndex = indexFocus + 1;
@@ -701,7 +709,7 @@ var SelectTable = forwardRef((props, ref) => {
701
709
  flag = true;
702
710
  }
703
711
  } else if (e.code === "ArrowUp") {
704
- if (dropdownOpen) {
712
+ if (dropdownOpen && ((optionsLoad?.length ?? 0) > 0 || options.length > 0)) {
705
713
  let newIndex = 0;
706
714
  if (indexFocus >= 0) {
707
715
  newIndex = indexFocus - 1;
@@ -1071,7 +1079,7 @@ var SelectTable = forwardRef((props, ref) => {
1071
1079
  container: component,
1072
1080
  className: "formula-dropdown icon-dropdown p-0",
1073
1081
  style: {
1074
- width: menuWidth ? menuWidth : "min-content",
1082
+ width: "min-content",
1075
1083
  position: "fixed",
1076
1084
  borderRadius: 3,
1077
1085
  zIndex: 9999
@@ -2849,9 +2857,9 @@ var TableEdit = forwardRef3((props, ref) => {
2849
2857
  }
2850
2858
  }
2851
2859
  if ((tableElement.current?.scrollHeight ?? 0) > 0) {
2852
- if ((tableElement.current?.scrollTop ?? 0) > (row - 1) * 34) {
2853
- tableElement.current?.scrollTo({ behavior: "smooth", top: (row - 1) * 34 });
2854
- } else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 < row * 34 - (tableElement.current?.scrollTop ?? 0)) {
2860
+ if ((tableElement.current?.scrollTop ?? 0) > (row - 1) % (pagingSetting?.pageSize ?? 1) * 34) {
2861
+ tableElement.current?.scrollTo({ behavior: "smooth", top: (row - 1) % (pagingSetting?.pageSize ?? 1) * 34 });
2862
+ } else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 < row % (pagingSetting?.pageSize ?? 1) * 34 - (tableElement.current?.scrollTop ?? 0)) {
2855
2863
  tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
2856
2864
  }
2857
2865
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.9.5",
4
+ "version": "0.9.7",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",