react-table-edit 0.9.6 → 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 +18 -10
- package/dist/index.mjs +18 -10
- package/package.json +1 -1
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 === "
|
|
704
|
-
|
|
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
|
-
|
|
715
|
-
|
|
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;
|
|
@@ -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 === "
|
|
668
|
-
|
|
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
|
-
|
|
679
|
-
|
|
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;
|
|
@@ -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
|
}
|