qbs-react-grid 1.1.42 → 1.1.43
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.
|
@@ -14,9 +14,7 @@ var MenuDropDown = function MenuDropDown(_ref) {
|
|
|
14
14
|
var menuButtonRef = useRef(null);
|
|
15
15
|
var menuRef = useRef(null);
|
|
16
16
|
var dropRef = useRef(null);
|
|
17
|
-
|
|
18
|
-
dropdownPosition = _useState2[0],
|
|
19
|
-
setDropdownPosition = _useState2[1];
|
|
17
|
+
// const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
|
|
20
18
|
useEffect(function () {
|
|
21
19
|
var handleClickOutside = function handleClickOutside(event) {
|
|
22
20
|
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
@@ -47,46 +45,50 @@ var MenuDropDown = function MenuDropDown(_ref) {
|
|
|
47
45
|
});
|
|
48
46
|
return (_result$length = result === null || result === void 0 ? void 0 : result.length) != null ? _result$length : 0;
|
|
49
47
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
menuPosition = _useState3[0],
|
|
57
|
-
setMenuPosition = _useState3[1];
|
|
48
|
+
// const [menuPosition, setMenuPosition] = useState({
|
|
49
|
+
// top: 0,
|
|
50
|
+
// left: 0,
|
|
51
|
+
// bottom: 0,
|
|
52
|
+
// right: 0
|
|
53
|
+
// });
|
|
58
54
|
var toggleMenu = function toggleMenu() {
|
|
59
|
-
if (!openMenu && menuButtonRef.current) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
55
|
+
// if (!openMenu && menuButtonRef.current) {
|
|
56
|
+
// const rect = menuButtonRef.current.getBoundingClientRect();
|
|
57
|
+
// const topSpace = rect.top;
|
|
58
|
+
// const bottomSpace = window.innerHeight - rect.bottom;
|
|
59
|
+
// const leftSpace = rect.left;
|
|
60
|
+
// const rightSpace = window.innerWidth - rect.right;
|
|
61
|
+
|
|
62
|
+
// const dropdownHeight = 200;
|
|
63
|
+
// const dropdownWidth = 200;
|
|
64
|
+
|
|
65
|
+
// let newPosition = 'bottom-right';
|
|
66
|
+
|
|
67
|
+
// if (bottomSpace < dropdownHeight && topSpace > dropdownHeight) {
|
|
68
|
+
// newPosition = 'top-right';
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
// if (rightSpace < dropdownWidth && leftSpace > dropdownWidth) {
|
|
72
|
+
// newPosition = newPosition.replace('right', 'left');
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
// if (topSpace < dropdownHeight && bottomSpace < dropdownHeight) {
|
|
76
|
+
// newPosition = leftSpace > rightSpace ? 'bottom-left' : 'bottom-right';
|
|
77
|
+
// }
|
|
78
|
+
|
|
79
|
+
// setDropdownPosition(newPosition);
|
|
80
|
+
// setMenuPosition({
|
|
81
|
+
// top: rect.top + window.scrollY,
|
|
82
|
+
// left: rect.left + window.scrollX,
|
|
83
|
+
// bottom: window.innerHeight - rect.bottom,
|
|
84
|
+
// right: window.innerWidth - rect.right
|
|
85
|
+
// });
|
|
86
|
+
// }
|
|
85
87
|
setTimeout(function () {
|
|
86
88
|
setOpenMenu(!openMenu);
|
|
87
89
|
}, 200);
|
|
88
90
|
};
|
|
89
|
-
|
|
91
|
+
// const buttonWidth = menuButtonRef.current ? menuButtonRef.current.offsetWidth : 0;
|
|
90
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
91
93
|
className: "qbs-table-menu-dropdown",
|
|
92
94
|
ref: menuRef
|
|
@@ -96,13 +98,15 @@ var MenuDropDown = function MenuDropDown(_ref) {
|
|
|
96
98
|
ref: menuButtonRef
|
|
97
99
|
}, /*#__PURE__*/React.createElement(ThreeDotIcon, null)), openMenu && /*#__PURE__*/React.createElement("div", {
|
|
98
100
|
className: 'qbs-table-qbs-table-menu-dropdown-content',
|
|
99
|
-
ref: dropRef
|
|
100
|
-
style
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
101
|
+
ref: dropRef
|
|
102
|
+
// style={{
|
|
103
|
+
// top: dropdownPosition.startsWith('bottom') ? `${menuPosition.top + 20}px` : 'auto',
|
|
104
|
+
// bottom: dropdownPosition.startsWith('top') ? `${menuPosition.bottom + 20}px` : 'auto',
|
|
105
|
+
// left: dropdownPosition.endsWith('right') ? `${menuPosition.left + 10}px` : 'auto',
|
|
106
|
+
// right: dropdownPosition.endsWith('left')
|
|
107
|
+
// ? `${window.innerWidth - menuPosition.left - buttonWidth + 10}px`
|
|
108
|
+
// : 'auto'
|
|
109
|
+
// }}
|
|
106
110
|
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
107
111
|
var _item$hide2;
|
|
108
112
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex)) && /*#__PURE__*/React.createElement("a", {
|
|
@@ -20,9 +20,7 @@ var MenuDropDown = function MenuDropDown(_ref) {
|
|
|
20
20
|
var menuButtonRef = (0, _react.useRef)(null);
|
|
21
21
|
var menuRef = (0, _react.useRef)(null);
|
|
22
22
|
var dropRef = (0, _react.useRef)(null);
|
|
23
|
-
|
|
24
|
-
dropdownPosition = _useState2[0],
|
|
25
|
-
setDropdownPosition = _useState2[1];
|
|
23
|
+
// const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
|
|
26
24
|
(0, _react.useEffect)(function () {
|
|
27
25
|
var handleClickOutside = function handleClickOutside(event) {
|
|
28
26
|
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
@@ -53,46 +51,50 @@ var MenuDropDown = function MenuDropDown(_ref) {
|
|
|
53
51
|
});
|
|
54
52
|
return (_result$length = result === null || result === void 0 ? void 0 : result.length) != null ? _result$length : 0;
|
|
55
53
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
menuPosition = _useState3[0],
|
|
63
|
-
setMenuPosition = _useState3[1];
|
|
54
|
+
// const [menuPosition, setMenuPosition] = useState({
|
|
55
|
+
// top: 0,
|
|
56
|
+
// left: 0,
|
|
57
|
+
// bottom: 0,
|
|
58
|
+
// right: 0
|
|
59
|
+
// });
|
|
64
60
|
var toggleMenu = function toggleMenu() {
|
|
65
|
-
if (!openMenu && menuButtonRef.current) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
61
|
+
// if (!openMenu && menuButtonRef.current) {
|
|
62
|
+
// const rect = menuButtonRef.current.getBoundingClientRect();
|
|
63
|
+
// const topSpace = rect.top;
|
|
64
|
+
// const bottomSpace = window.innerHeight - rect.bottom;
|
|
65
|
+
// const leftSpace = rect.left;
|
|
66
|
+
// const rightSpace = window.innerWidth - rect.right;
|
|
67
|
+
|
|
68
|
+
// const dropdownHeight = 200;
|
|
69
|
+
// const dropdownWidth = 200;
|
|
70
|
+
|
|
71
|
+
// let newPosition = 'bottom-right';
|
|
72
|
+
|
|
73
|
+
// if (bottomSpace < dropdownHeight && topSpace > dropdownHeight) {
|
|
74
|
+
// newPosition = 'top-right';
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
// if (rightSpace < dropdownWidth && leftSpace > dropdownWidth) {
|
|
78
|
+
// newPosition = newPosition.replace('right', 'left');
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
// if (topSpace < dropdownHeight && bottomSpace < dropdownHeight) {
|
|
82
|
+
// newPosition = leftSpace > rightSpace ? 'bottom-left' : 'bottom-right';
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
// setDropdownPosition(newPosition);
|
|
86
|
+
// setMenuPosition({
|
|
87
|
+
// top: rect.top + window.scrollY,
|
|
88
|
+
// left: rect.left + window.scrollX,
|
|
89
|
+
// bottom: window.innerHeight - rect.bottom,
|
|
90
|
+
// right: window.innerWidth - rect.right
|
|
91
|
+
// });
|
|
92
|
+
// }
|
|
91
93
|
setTimeout(function () {
|
|
92
94
|
setOpenMenu(!openMenu);
|
|
93
95
|
}, 200);
|
|
94
96
|
};
|
|
95
|
-
|
|
97
|
+
// const buttonWidth = menuButtonRef.current ? menuButtonRef.current.offsetWidth : 0;
|
|
96
98
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
97
99
|
className: "qbs-table-menu-dropdown",
|
|
98
100
|
ref: menuRef
|
|
@@ -102,13 +104,15 @@ var MenuDropDown = function MenuDropDown(_ref) {
|
|
|
102
104
|
ref: menuButtonRef
|
|
103
105
|
}, /*#__PURE__*/_react["default"].createElement(_icons.ThreeDotIcon, null)), openMenu && /*#__PURE__*/_react["default"].createElement("div", {
|
|
104
106
|
className: 'qbs-table-qbs-table-menu-dropdown-content',
|
|
105
|
-
ref: dropRef
|
|
106
|
-
style
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
107
|
+
ref: dropRef
|
|
108
|
+
// style={{
|
|
109
|
+
// top: dropdownPosition.startsWith('bottom') ? `${menuPosition.top + 20}px` : 'auto',
|
|
110
|
+
// bottom: dropdownPosition.startsWith('top') ? `${menuPosition.bottom + 20}px` : 'auto',
|
|
111
|
+
// left: dropdownPosition.endsWith('right') ? `${menuPosition.left + 10}px` : 'auto',
|
|
112
|
+
// right: dropdownPosition.endsWith('left')
|
|
113
|
+
// ? `${window.innerWidth - menuPosition.left - buttonWidth + 10}px`
|
|
114
|
+
// : 'auto'
|
|
115
|
+
// }}
|
|
112
116
|
}, actionDropDown === null || actionDropDown === void 0 ? void 0 : actionDropDown.map(function (item) {
|
|
113
117
|
var _item$hide2;
|
|
114
118
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !(item !== null && item !== void 0 && item.hidden) && !(item !== null && item !== void 0 && (_item$hide2 = item.hide) !== null && _item$hide2 !== void 0 && _item$hide2.call(item, rowData, rowIndex)) && /*#__PURE__*/_react["default"].createElement("a", {
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ const MenuDropDown: React.FC<Props> = ({
|
|
|
25
25
|
const menuButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
26
26
|
const menuRef = useRef<HTMLDivElement | null>(null);
|
|
27
27
|
const dropRef = useRef<HTMLDivElement | null>(null);
|
|
28
|
-
const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
|
|
28
|
+
// const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
const handleClickOutside = (event: MouseEvent) => {
|
|
31
31
|
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
|
@@ -55,50 +55,50 @@ const MenuDropDown: React.FC<Props> = ({
|
|
|
55
55
|
);
|
|
56
56
|
return result?.length ?? 0;
|
|
57
57
|
};
|
|
58
|
-
const [menuPosition, setMenuPosition] = useState({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
58
|
+
// const [menuPosition, setMenuPosition] = useState({
|
|
59
|
+
// top: 0,
|
|
60
|
+
// left: 0,
|
|
61
|
+
// bottom: 0,
|
|
62
|
+
// right: 0
|
|
63
|
+
// });
|
|
64
64
|
const toggleMenu = () => {
|
|
65
|
-
if (!openMenu && menuButtonRef.current) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
// if (!openMenu && menuButtonRef.current) {
|
|
66
|
+
// const rect = menuButtonRef.current.getBoundingClientRect();
|
|
67
|
+
// const topSpace = rect.top;
|
|
68
|
+
// const bottomSpace = window.innerHeight - rect.bottom;
|
|
69
|
+
// const leftSpace = rect.left;
|
|
70
|
+
// const rightSpace = window.innerWidth - rect.right;
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// const dropdownHeight = 200;
|
|
73
|
+
// const dropdownWidth = 200;
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// let newPosition = 'bottom-right';
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
// if (bottomSpace < dropdownHeight && topSpace > dropdownHeight) {
|
|
78
|
+
// newPosition = 'top-right';
|
|
79
|
+
// }
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
// if (rightSpace < dropdownWidth && leftSpace > dropdownWidth) {
|
|
82
|
+
// newPosition = newPosition.replace('right', 'left');
|
|
83
|
+
// }
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
// if (topSpace < dropdownHeight && bottomSpace < dropdownHeight) {
|
|
86
|
+
// newPosition = leftSpace > rightSpace ? 'bottom-left' : 'bottom-right';
|
|
87
|
+
// }
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
89
|
+
// setDropdownPosition(newPosition);
|
|
90
|
+
// setMenuPosition({
|
|
91
|
+
// top: rect.top + window.scrollY,
|
|
92
|
+
// left: rect.left + window.scrollX,
|
|
93
|
+
// bottom: window.innerHeight - rect.bottom,
|
|
94
|
+
// right: window.innerWidth - rect.right
|
|
95
|
+
// });
|
|
96
|
+
// }
|
|
97
97
|
setTimeout(() => {
|
|
98
98
|
setOpenMenu(!openMenu);
|
|
99
99
|
}, 200);
|
|
100
100
|
};
|
|
101
|
-
const buttonWidth = menuButtonRef.current ? menuButtonRef.current.offsetWidth : 0;
|
|
101
|
+
// const buttonWidth = menuButtonRef.current ? menuButtonRef.current.offsetWidth : 0;
|
|
102
102
|
return (
|
|
103
103
|
<div className="qbs-table-menu-dropdown" ref={menuRef}>
|
|
104
104
|
{handleShowHideMenu() > 0 && (
|
|
@@ -110,16 +110,14 @@ const MenuDropDown: React.FC<Props> = ({
|
|
|
110
110
|
<div
|
|
111
111
|
className={'qbs-table-qbs-table-menu-dropdown-content'}
|
|
112
112
|
ref={dropRef}
|
|
113
|
-
style={{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
: 'auto'
|
|
122
|
-
}}
|
|
113
|
+
// style={{
|
|
114
|
+
// top: dropdownPosition.startsWith('bottom') ? `${menuPosition.top + 20}px` : 'auto',
|
|
115
|
+
// bottom: dropdownPosition.startsWith('top') ? `${menuPosition.bottom + 20}px` : 'auto',
|
|
116
|
+
// left: dropdownPosition.endsWith('right') ? `${menuPosition.left + 10}px` : 'auto',
|
|
117
|
+
// right: dropdownPosition.endsWith('left')
|
|
118
|
+
// ? `${window.innerWidth - menuPosition.left - buttonWidth + 10}px`
|
|
119
|
+
// : 'auto'
|
|
120
|
+
// }}
|
|
123
121
|
>
|
|
124
122
|
{actionDropDown?.map(item => (
|
|
125
123
|
<>
|