rsuite 5.12.0 → 5.14.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/Button/styles/index.less +1 -0
- package/CHANGELOG.md +49 -0
- package/Dropdown/styles/index.less +8 -3
- package/Grid/styles/index.less +42 -10
- package/Nav/styles/index.less +7 -1
- package/Navbar/styles/index.less +6 -1
- package/Sidenav/styles/index.less +52 -16
- package/Table/styles/index.less +0 -2
- package/Tooltip/styles/index.less +4 -4
- package/cjs/@types/common.d.ts +6 -0
- package/cjs/Cascader/DropdownMenu.js +8 -3
- package/cjs/Cascader/utils.d.ts +1 -1
- package/cjs/Col/Col.d.ts +25 -5
- package/cjs/Col/Col.js +9 -1
- package/cjs/CustomProvider/CustomProvider.d.ts +20 -7
- package/cjs/CustomProvider/CustomProvider.js +24 -3
- package/cjs/Disclosure/Disclosure.d.ts +1 -1
- package/cjs/Disclosure/DisclosureContext.d.ts +1 -1
- package/cjs/Dropdown/Dropdown.js +26 -110
- package/cjs/Dropdown/DropdownItem.js +14 -58
- package/cjs/Dropdown/DropdownMenu.js +32 -76
- package/cjs/Dropdown/DropdownToggle.js +4 -17
- package/cjs/Dropdown/useRenderDropdownItem.d.ts +1 -1
- package/cjs/Form/Form.d.ts +8 -8
- package/cjs/Form/test/Form.test.d.ts +1 -0
- package/cjs/Form/test/Form.test.js +18 -0
- package/cjs/Menu/Menu.d.ts +1 -0
- package/cjs/Menu/Menu.js +1 -0
- package/cjs/Menu/MenuItem.d.ts +1 -0
- package/cjs/Menu/MenuItem.js +1 -0
- package/cjs/Menu/Menubar.d.ts +3 -0
- package/cjs/Menu/Menubar.js +4 -0
- package/cjs/Modal/test/Modal.test.d.ts +1 -0
- package/cjs/Modal/test/Modal.test.js +14 -0
- package/cjs/Modal/utils.d.ts +1 -1
- package/cjs/Nav/Nav.d.ts +7 -2
- package/cjs/Nav/Nav.js +105 -5
- package/cjs/Nav/NavContext.d.ts +2 -8
- package/cjs/Nav/NavContext.js +1 -7
- package/cjs/Nav/NavDropdown.d.ts +71 -0
- package/cjs/Nav/NavDropdown.js +193 -0
- package/cjs/Nav/NavDropdownItem.d.ts +39 -0
- package/cjs/Nav/NavDropdownItem.js +141 -0
- package/cjs/Nav/NavDropdownMenu.d.ts +37 -0
- package/cjs/Nav/NavDropdownMenu.js +162 -0
- package/cjs/Nav/NavDropdownToggle.d.ts +21 -0
- package/cjs/Nav/NavDropdownToggle.js +74 -0
- package/cjs/Nav/NavItem.d.ts +2 -0
- package/cjs/Nav/NavItem.js +13 -26
- package/cjs/Nav/NavMenu.d.ts +38 -0
- package/cjs/Nav/NavMenu.js +122 -0
- package/cjs/Nav/test/Nav.test.d.ts +1 -0
- package/cjs/Nav/test/Nav.test.js +17 -0
- package/cjs/Navbar/NavbarDropdown.d.ts +57 -0
- package/cjs/Navbar/NavbarDropdown.js +147 -0
- package/cjs/Navbar/NavbarDropdownItem.d.ts +41 -0
- package/cjs/Navbar/NavbarDropdownItem.js +149 -0
- package/cjs/Navbar/NavbarDropdownMenu.d.ts +48 -0
- package/cjs/Navbar/NavbarDropdownMenu.js +161 -0
- package/cjs/Navbar/NavbarDropdownToggle.d.ts +19 -0
- package/cjs/Navbar/NavbarDropdownToggle.js +72 -0
- package/cjs/Navbar/NavbarItem.d.ts +5 -2
- package/cjs/Navbar/NavbarItem.js +10 -4
- package/cjs/Overlay/Modal.d.ts +1 -4
- package/cjs/Overlay/Overlay.d.ts +3 -1
- package/cjs/Overlay/Overlay.js +6 -2
- package/cjs/Overlay/OverlayTrigger.d.ts +8 -4
- package/cjs/Overlay/OverlayTrigger.js +32 -4
- package/cjs/Overlay/Position.d.ts +3 -1
- package/cjs/Overlay/Position.js +12 -4
- package/cjs/Overlay/positionUtils.d.ts +11 -4
- package/cjs/Overlay/positionUtils.js +48 -2
- package/cjs/Panel/Panel.js +9 -6
- package/cjs/Picker/utils.d.ts +1 -1
- package/cjs/Picker/utils.js +22 -15
- package/cjs/Popover/Popover.d.ts +2 -0
- package/cjs/Popover/Popover.js +6 -3
- package/cjs/Sidenav/ExpandedSidenavDropdown.d.ts +43 -0
- package/cjs/Sidenav/ExpandedSidenavDropdown.js +166 -0
- package/cjs/Sidenav/ExpandedSidenavDropdownItem.d.ts +31 -0
- package/cjs/Sidenav/ExpandedSidenavDropdownItem.js +141 -0
- package/cjs/Sidenav/ExpandedSidenavDropdownMenu.d.ts +26 -0
- package/cjs/Sidenav/ExpandedSidenavDropdownMenu.js +145 -0
- package/cjs/Sidenav/Sidenav.d.ts +8 -2
- package/cjs/Sidenav/Sidenav.js +1 -2
- package/cjs/Sidenav/SidenavDropdown.d.ts +30 -8
- package/cjs/Sidenav/SidenavDropdown.js +144 -73
- package/cjs/Sidenav/SidenavDropdownItem.d.ts +22 -5
- package/cjs/Sidenav/SidenavDropdownItem.js +88 -72
- package/cjs/Sidenav/SidenavDropdownMenu.d.ts +26 -16
- package/cjs/Sidenav/SidenavDropdownMenu.js +122 -90
- package/cjs/Sidenav/SidenavDropdownToggle.d.ts +19 -0
- package/cjs/Sidenav/SidenavDropdownToggle.js +73 -0
- package/cjs/Sidenav/SidenavItem.d.ts +7 -0
- package/cjs/Sidenav/SidenavItem.js +54 -37
- package/cjs/Sidenav/SidenavToggle.d.ts +5 -1
- package/cjs/Sidenav/SidenavToggle.js +25 -9
- package/cjs/Toggle/Toggle.d.ts +1 -1
- package/cjs/Tooltip/Tooltip.d.ts +3 -1
- package/cjs/Tooltip/Tooltip.js +8 -3
- package/cjs/Whisper/Whisper.d.ts +3 -5
- package/cjs/Whisper/Whisper.js +6 -1
- package/cjs/Whisper/test/Whisper.test.d.ts +1 -0
- package/cjs/Whisper/test/Whisper.test.js +23 -0
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +3 -2
- package/cjs/toaster/ToastContainer.d.ts +1 -0
- package/cjs/toaster/ToastContainer.js +4 -1
- package/cjs/toaster/index.d.ts +1 -0
- package/cjs/toaster/index.js +4 -1
- package/cjs/toaster/toaster.d.ts +0 -1
- package/cjs/toaster/useToaster.d.ts +12 -0
- package/cjs/toaster/useToaster.js +43 -0
- package/cjs/utils/constants.d.ts +1 -0
- package/cjs/utils/constants.js +3 -1
- package/cjs/utils/deprecateComponent.js +4 -6
- package/cjs/utils/deprecatePropType.d.ts +1 -5
- package/cjs/utils/deprecatePropType.js +7 -14
- package/cjs/utils/stringToObject.d.ts +1 -1
- package/cjs/utils/tplTransform.d.ts +1 -1
- package/cjs/utils/treeUtils.d.ts +3 -3
- package/cjs/utils/treeUtils.js +8 -10
- package/cjs/utils/useCustom.d.ts +1 -1
- package/cjs/utils/useCustom.js +5 -3
- package/cjs/utils/useFocus.d.ts +1 -1
- package/cjs/utils/useInternalId.d.ts +1 -1
- package/cjs/utils/useInternalId.js +2 -2
- package/cjs/utils/warnOnce.d.ts +9 -0
- package/cjs/utils/warnOnce.js +22 -0
- package/dist/rsuite-rtl.css +735 -56
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +735 -56
- package/dist/rsuite.js +363 -121
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +6 -0
- package/esm/Cascader/DropdownMenu.js +8 -3
- package/esm/Cascader/utils.d.ts +1 -1
- package/esm/Col/Col.d.ts +25 -5
- package/esm/Col/Col.js +10 -2
- package/esm/CustomProvider/CustomProvider.d.ts +20 -7
- package/esm/CustomProvider/CustomProvider.js +22 -3
- package/esm/Disclosure/Disclosure.d.ts +1 -1
- package/esm/Disclosure/DisclosureContext.d.ts +1 -1
- package/esm/Dropdown/Dropdown.js +25 -105
- package/esm/Dropdown/DropdownItem.js +13 -55
- package/esm/Dropdown/DropdownMenu.js +31 -76
- package/esm/Dropdown/DropdownToggle.js +4 -14
- package/esm/Dropdown/useRenderDropdownItem.d.ts +1 -1
- package/esm/Form/Form.d.ts +8 -8
- package/esm/Form/test/Form.test.d.ts +1 -0
- package/esm/Form/test/Form.test.js +11 -0
- package/esm/Menu/Menu.d.ts +1 -0
- package/esm/Menu/Menu.js +1 -0
- package/esm/Menu/MenuItem.d.ts +1 -0
- package/esm/Menu/MenuItem.js +1 -0
- package/esm/Menu/Menubar.d.ts +3 -0
- package/esm/Menu/Menubar.js +4 -0
- package/esm/Modal/test/Modal.test.d.ts +1 -0
- package/esm/Modal/test/Modal.test.js +9 -0
- package/esm/Modal/utils.d.ts +1 -1
- package/esm/Nav/Nav.d.ts +7 -2
- package/esm/Nav/Nav.js +96 -5
- package/esm/Nav/NavContext.d.ts +2 -8
- package/esm/Nav/NavContext.js +1 -6
- package/esm/Nav/NavDropdown.d.ts +71 -0
- package/esm/Nav/NavDropdown.js +170 -0
- package/esm/Nav/NavDropdownItem.d.ts +39 -0
- package/esm/Nav/NavDropdownItem.js +123 -0
- package/esm/Nav/NavDropdownMenu.d.ts +37 -0
- package/esm/Nav/NavDropdownMenu.js +143 -0
- package/esm/Nav/NavDropdownToggle.d.ts +21 -0
- package/esm/Nav/NavDropdownToggle.js +57 -0
- package/esm/Nav/NavItem.d.ts +2 -0
- package/esm/Nav/NavItem.js +13 -21
- package/esm/Nav/NavMenu.d.ts +38 -0
- package/esm/Nav/NavMenu.js +98 -0
- package/esm/Nav/test/Nav.test.d.ts +1 -0
- package/esm/Nav/test/Nav.test.js +11 -0
- package/esm/Navbar/NavbarDropdown.d.ts +57 -0
- package/esm/Navbar/NavbarDropdown.js +124 -0
- package/esm/Navbar/NavbarDropdownItem.d.ts +41 -0
- package/esm/Navbar/NavbarDropdownItem.js +128 -0
- package/esm/Navbar/NavbarDropdownMenu.d.ts +48 -0
- package/esm/Navbar/NavbarDropdownMenu.js +140 -0
- package/esm/Navbar/NavbarDropdownToggle.d.ts +19 -0
- package/esm/Navbar/NavbarDropdownToggle.js +55 -0
- package/esm/Navbar/NavbarItem.d.ts +5 -2
- package/esm/Navbar/NavbarItem.js +11 -4
- package/esm/Overlay/Modal.d.ts +1 -4
- package/esm/Overlay/Overlay.d.ts +3 -1
- package/esm/Overlay/Overlay.js +6 -2
- package/esm/Overlay/OverlayTrigger.d.ts +8 -4
- package/esm/Overlay/OverlayTrigger.js +33 -5
- package/esm/Overlay/Position.d.ts +3 -1
- package/esm/Overlay/Position.js +12 -4
- package/esm/Overlay/positionUtils.d.ts +11 -4
- package/esm/Overlay/positionUtils.js +46 -2
- package/esm/Panel/Panel.js +9 -6
- package/esm/Picker/utils.d.ts +1 -1
- package/esm/Picker/utils.js +22 -14
- package/esm/Popover/Popover.d.ts +2 -0
- package/esm/Popover/Popover.js +6 -3
- package/esm/Sidenav/ExpandedSidenavDropdown.d.ts +43 -0
- package/esm/Sidenav/ExpandedSidenavDropdown.js +140 -0
- package/esm/Sidenav/ExpandedSidenavDropdownItem.d.ts +31 -0
- package/esm/Sidenav/ExpandedSidenavDropdownItem.js +120 -0
- package/esm/Sidenav/ExpandedSidenavDropdownMenu.d.ts +26 -0
- package/esm/Sidenav/ExpandedSidenavDropdownMenu.js +121 -0
- package/esm/Sidenav/Sidenav.d.ts +8 -2
- package/esm/Sidenav/Sidenav.js +1 -2
- package/esm/Sidenav/SidenavDropdown.d.ts +30 -8
- package/esm/Sidenav/SidenavDropdown.js +145 -75
- package/esm/Sidenav/SidenavDropdownItem.d.ts +22 -5
- package/esm/Sidenav/SidenavDropdownItem.js +87 -71
- package/esm/Sidenav/SidenavDropdownMenu.d.ts +26 -16
- package/esm/Sidenav/SidenavDropdownMenu.js +122 -86
- package/esm/Sidenav/SidenavDropdownToggle.d.ts +19 -0
- package/esm/Sidenav/SidenavDropdownToggle.js +56 -0
- package/esm/Sidenav/SidenavItem.d.ts +7 -0
- package/esm/Sidenav/SidenavItem.js +53 -38
- package/esm/Sidenav/SidenavToggle.d.ts +5 -1
- package/esm/Sidenav/SidenavToggle.js +22 -9
- package/esm/Toggle/Toggle.d.ts +1 -1
- package/esm/Tooltip/Tooltip.d.ts +3 -1
- package/esm/Tooltip/Tooltip.js +8 -3
- package/esm/Whisper/Whisper.d.ts +3 -5
- package/esm/Whisper/Whisper.js +6 -1
- package/esm/Whisper/test/Whisper.test.d.ts +1 -0
- package/esm/Whisper/test/Whisper.test.js +16 -0
- package/esm/index.d.ts +3 -3
- package/esm/index.js +1 -1
- package/esm/toaster/ToastContainer.d.ts +1 -0
- package/esm/toaster/ToastContainer.js +1 -0
- package/esm/toaster/index.d.ts +1 -0
- package/esm/toaster/index.js +1 -0
- package/esm/toaster/toaster.d.ts +0 -1
- package/esm/toaster/useToaster.d.ts +12 -0
- package/esm/toaster/useToaster.js +34 -0
- package/esm/utils/constants.d.ts +1 -0
- package/esm/utils/constants.js +1 -0
- package/esm/utils/deprecateComponent.js +3 -4
- package/esm/utils/deprecatePropType.d.ts +1 -5
- package/esm/utils/deprecatePropType.js +3 -13
- package/esm/utils/stringToObject.d.ts +1 -1
- package/esm/utils/tplTransform.d.ts +1 -1
- package/esm/utils/treeUtils.d.ts +3 -3
- package/esm/utils/treeUtils.js +8 -10
- package/esm/utils/useCustom.d.ts +1 -1
- package/esm/utils/useCustom.js +5 -3
- package/esm/utils/useFocus.d.ts +1 -1
- package/esm/utils/useInternalId.d.ts +1 -1
- package/esm/utils/useInternalId.js +2 -2
- package/esm/utils/warnOnce.d.ts +9 -0
- package/esm/utils/warnOnce.js +18 -0
- package/package.json +1 -1
- package/styles/color-modes/dark.less +3 -0
- package/styles/color-modes/high-contrast.less +3 -0
- package/styles/color-modes/light.less +5 -2
- package/styles/variables.less +33 -12
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
|
|
5
|
+
var _templateObject, _templateObject2;
|
|
6
|
+
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import omit from 'lodash/omit';
|
|
9
|
+
import { mergeRefs, useClassNames } from '../utils';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import AngleLeft from '@rsuite/icons/legacy/AngleLeft';
|
|
12
|
+
import AngleRight from '@rsuite/icons/legacy/AngleRight';
|
|
13
|
+
import useCustom from '../utils/useCustom';
|
|
14
|
+
import { NavbarContext } from '.';
|
|
15
|
+
import Disclosure from '../Disclosure';
|
|
16
|
+
import NavContext from '../Nav/NavContext';
|
|
17
|
+
import deprecatePropType from '../utils/deprecatePropType';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @private this component is not supposed to be used directly
|
|
21
|
+
* Instead it's rendered by a <Nav.Menu> within a <Navbar>
|
|
22
|
+
*
|
|
23
|
+
* <Navbar>
|
|
24
|
+
* <Nav>
|
|
25
|
+
* <Nav.Menu>
|
|
26
|
+
* <Nav.Menu title="menu"> -> This submenu will render <NavbarDropdownMenu> component
|
|
27
|
+
* </Nav.Menu>
|
|
28
|
+
* </Nav.Menu>
|
|
29
|
+
* </Nav>
|
|
30
|
+
* </Navbar>
|
|
31
|
+
*/
|
|
32
|
+
var NavbarDropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
33
|
+
var navbar = useContext(NavbarContext);
|
|
34
|
+
var nav = useContext(NavContext);
|
|
35
|
+
|
|
36
|
+
if (!navbar || !nav) {
|
|
37
|
+
throw new Error('<Navbar.Dropdown.Menu> must be rendered within a <Nav> within a <Navbar> component.');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var _onToggle = props.onToggle,
|
|
41
|
+
eventKey = props.eventKey,
|
|
42
|
+
title = props.title,
|
|
43
|
+
_props$classPrefix = props.classPrefix,
|
|
44
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu' : _props$classPrefix,
|
|
45
|
+
children = props.children,
|
|
46
|
+
_props$openDirection = props.openDirection,
|
|
47
|
+
openDirection = _props$openDirection === void 0 ? 'end' : _props$openDirection,
|
|
48
|
+
rest = _objectWithoutPropertiesLoose(props, ["onToggle", "eventKey", "title", "classPrefix", "children", "openDirection"]);
|
|
49
|
+
|
|
50
|
+
var _useCustom = useCustom('DropdownMenu'),
|
|
51
|
+
rtl = _useCustom.rtl;
|
|
52
|
+
|
|
53
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
54
|
+
prefix = _useClassNames.prefix;
|
|
55
|
+
|
|
56
|
+
var _useClassNames2 = useClassNames('dropdown-menu'),
|
|
57
|
+
withMenuClassPrefix = _useClassNames2.withClassPrefix,
|
|
58
|
+
mergeMenuClassName = _useClassNames2.merge;
|
|
59
|
+
|
|
60
|
+
var _useClassNames3 = useClassNames('dropdown-item'),
|
|
61
|
+
mergeItemClassNames = _useClassNames3.merge,
|
|
62
|
+
withItemClassPrefix = _useClassNames3.withClassPrefix,
|
|
63
|
+
prefixItemClassName = _useClassNames3.prefix; // Parent menu exists. This is a submenu.
|
|
64
|
+
// Should render a `menuitem` that controls this submenu.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
var _omit = omit(rest, ['trigger']),
|
|
68
|
+
icon = _omit.icon,
|
|
69
|
+
className = _omit.className,
|
|
70
|
+
disabled = _omit.disabled,
|
|
71
|
+
menuProps = _objectWithoutPropertiesLoose(_omit, ["icon", "className", "disabled"]);
|
|
72
|
+
|
|
73
|
+
var Icon = rtl ? AngleLeft : AngleRight;
|
|
74
|
+
return /*#__PURE__*/React.createElement(Disclosure, {
|
|
75
|
+
hideOnClickOutside: true,
|
|
76
|
+
trigger: ['click', 'mouseover'],
|
|
77
|
+
onToggle: function onToggle(open, event) {
|
|
78
|
+
return _onToggle === null || _onToggle === void 0 ? void 0 : _onToggle(open, undefined, event);
|
|
79
|
+
}
|
|
80
|
+
}, function (_ref, containerRef) {
|
|
81
|
+
var open = _ref.open,
|
|
82
|
+
props = _objectWithoutPropertiesLoose(_ref, ["open"]);
|
|
83
|
+
|
|
84
|
+
var classes = mergeItemClassNames(className, withItemClassPrefix({
|
|
85
|
+
disabled: disabled,
|
|
86
|
+
open: open,
|
|
87
|
+
submenu: true
|
|
88
|
+
}));
|
|
89
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
|
90
|
+
ref: mergeRefs(ref, containerRef),
|
|
91
|
+
className: classes
|
|
92
|
+
}, props), /*#__PURE__*/React.createElement(Disclosure.Button, null, function (_ref2, buttonRef) {
|
|
93
|
+
var open = _ref2.open,
|
|
94
|
+
buttonProps = _objectWithoutPropertiesLoose(_ref2, ["open"]);
|
|
95
|
+
|
|
96
|
+
var classes = mergeItemClassNames(className, prefixItemClassName(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["toggle"]))), withItemClassPrefix({
|
|
97
|
+
'with-icon': icon,
|
|
98
|
+
open: open,
|
|
99
|
+
disabled: disabled
|
|
100
|
+
}));
|
|
101
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
102
|
+
ref: mergeRefs(buttonRef, buttonRef),
|
|
103
|
+
className: classes,
|
|
104
|
+
"data-event-key": eventKey,
|
|
105
|
+
"data-event-key-type": typeof eventKey
|
|
106
|
+
}, buttonProps), icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
107
|
+
className: prefix('menu-icon')
|
|
108
|
+
}), title, /*#__PURE__*/React.createElement(Icon, {
|
|
109
|
+
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["toggle-icon"])))
|
|
110
|
+
}));
|
|
111
|
+
}), /*#__PURE__*/React.createElement(Disclosure.Content, null, function (_ref3, elementRef) {
|
|
112
|
+
var open = _ref3.open;
|
|
113
|
+
var menuClassName = mergeMenuClassName(className, withMenuClassPrefix());
|
|
114
|
+
return /*#__PURE__*/React.createElement("ul", _extends({
|
|
115
|
+
ref: elementRef,
|
|
116
|
+
className: menuClassName,
|
|
117
|
+
hidden: !open,
|
|
118
|
+
"data-direction": openDirection
|
|
119
|
+
}, menuProps), children);
|
|
120
|
+
}));
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
NavbarDropdownMenu.displayName = 'Nav.Dropdown.Menu';
|
|
124
|
+
NavbarDropdownMenu.propTypes = {
|
|
125
|
+
active: PropTypes.bool,
|
|
126
|
+
activeKey: PropTypes.any,
|
|
127
|
+
className: PropTypes.string,
|
|
128
|
+
children: PropTypes.node,
|
|
129
|
+
icon: PropTypes.any,
|
|
130
|
+
classPrefix: PropTypes.string,
|
|
131
|
+
pullLeft: deprecatePropType(PropTypes.bool, 'Use openDirection="start" instead.'),
|
|
132
|
+
openDirection: PropTypes.oneOf(['start', 'end']),
|
|
133
|
+
title: PropTypes.node,
|
|
134
|
+
open: PropTypes.bool,
|
|
135
|
+
eventKey: PropTypes.any,
|
|
136
|
+
expanded: PropTypes.bool,
|
|
137
|
+
collapsible: PropTypes.bool,
|
|
138
|
+
onToggle: PropTypes.func
|
|
139
|
+
};
|
|
140
|
+
export default NavbarDropdownMenu;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Button from '../Button';
|
|
3
|
+
import { WithAsProps, RsRefForwardingComponent, TypeAttributes } from '../@types/common';
|
|
4
|
+
export interface NavbarDropdownToggleProps extends WithAsProps {
|
|
5
|
+
noCaret?: boolean;
|
|
6
|
+
renderToggle?: (props: WithAsProps, ref: React.Ref<any>) => any;
|
|
7
|
+
placement?: TypeAttributes.Placement8;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @private this component is not supposed to be used directly
|
|
11
|
+
* Instead it's rendered by a <Nav.Menu> call
|
|
12
|
+
*
|
|
13
|
+
* <Nav>
|
|
14
|
+
* <Nav.Menu> -> This will render <NavDropdown> component that renders a <NavDropdownToggle>
|
|
15
|
+
* </Nav.Menu>
|
|
16
|
+
* </Nav>
|
|
17
|
+
*/
|
|
18
|
+
declare const NavbarDropdownToggle: RsRefForwardingComponent<typeof Button, NavbarDropdownToggleProps>;
|
|
19
|
+
export default NavbarDropdownToggle;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import ArrowDownLineIcon from '@rsuite/icons/ArrowDownLine';
|
|
6
|
+
import { useClassNames } from '../utils';
|
|
7
|
+
import NavbarItem from './NavbarItem';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @private this component is not supposed to be used directly
|
|
11
|
+
* Instead it's rendered by a <Nav.Menu> call
|
|
12
|
+
*
|
|
13
|
+
* <Nav>
|
|
14
|
+
* <Nav.Menu> -> This will render <NavDropdown> component that renders a <NavDropdownToggle>
|
|
15
|
+
* </Nav.Menu>
|
|
16
|
+
* </Nav>
|
|
17
|
+
*/
|
|
18
|
+
var NavbarDropdownToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
+
var _props$as = props.as,
|
|
20
|
+
Component = _props$as === void 0 ? NavbarItem : _props$as,
|
|
21
|
+
className = props.className,
|
|
22
|
+
_props$classPrefix = props.classPrefix,
|
|
23
|
+
classPrefix = _props$classPrefix === void 0 ? 'navbar-item' : _props$classPrefix,
|
|
24
|
+
renderToggle = props.renderToggle,
|
|
25
|
+
children = props.children,
|
|
26
|
+
noCaret = props.noCaret,
|
|
27
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "renderToggle", "children", "noCaret"]);
|
|
28
|
+
|
|
29
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
30
|
+
prefix = _useClassNames.prefix,
|
|
31
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
32
|
+
merge = _useClassNames.merge;
|
|
33
|
+
|
|
34
|
+
var classes = merge(className, withClassPrefix({
|
|
35
|
+
'no-caret': noCaret
|
|
36
|
+
}));
|
|
37
|
+
var toggle = /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
38
|
+
ref: ref,
|
|
39
|
+
className: classes
|
|
40
|
+
}), children, !noCaret && /*#__PURE__*/React.createElement(ArrowDownLineIcon, {
|
|
41
|
+
className: prefix('caret')
|
|
42
|
+
}));
|
|
43
|
+
return renderToggle ? renderToggle(rest, ref) : toggle;
|
|
44
|
+
});
|
|
45
|
+
NavbarDropdownToggle.displayName = 'Navbar.Dropdown.Toggle';
|
|
46
|
+
NavbarDropdownToggle.propTypes = {
|
|
47
|
+
className: PropTypes.string,
|
|
48
|
+
children: PropTypes.node,
|
|
49
|
+
classPrefix: PropTypes.string,
|
|
50
|
+
noCaret: PropTypes.bool,
|
|
51
|
+
as: PropTypes.elementType,
|
|
52
|
+
renderToggle: PropTypes.func,
|
|
53
|
+
placement: PropTypes.oneOf(['bottomStart', 'bottomEnd', 'topStart', 'topEnd', 'leftStart', 'rightStart', 'leftEnd', 'rightEnd'])
|
|
54
|
+
};
|
|
55
|
+
export default NavbarDropdownToggle;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
3
3
|
import { RsRefForwardingComponent, WithAsProps } from '../@types/common';
|
|
4
|
-
export interface
|
|
4
|
+
export interface NavbarItemProps<T = string> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
|
|
5
5
|
/** Activation status */
|
|
6
6
|
active?: boolean;
|
|
7
7
|
/** Disabled status */
|
|
@@ -15,5 +15,8 @@ export interface NavItemProps<T = string> extends WithAsProps, Omit<React.HTMLAt
|
|
|
15
15
|
/** Select the callback function that the event triggers. */
|
|
16
16
|
onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
declare const NavbarItem: RsRefForwardingComponent<'a', NavbarItemProps>;
|
|
19
22
|
export default NavbarItem;
|
package/esm/Navbar/NavbarItem.js
CHANGED
|
@@ -7,6 +7,10 @@ import Ripple from '../Ripple';
|
|
|
7
7
|
import SafeAnchor from '../SafeAnchor';
|
|
8
8
|
import { shallowEqual, useClassNames } from '../utils';
|
|
9
9
|
import NavContext from '../Nav/NavContext';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
10
14
|
var NavbarItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
15
|
var _props$as = props.as,
|
|
12
16
|
Component = _props$as === void 0 ? SafeAnchor : _props$as,
|
|
@@ -23,9 +27,9 @@ var NavbarItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
23
27
|
onSelectProp = props.onSelect,
|
|
24
28
|
rest = _objectWithoutPropertiesLoose(props, ["as", "active", "disabled", "eventKey", "className", "classPrefix", "style", "children", "icon", "onClick", "onSelect"]);
|
|
25
29
|
|
|
26
|
-
var
|
|
27
|
-
activeKey =
|
|
28
|
-
onSelectFromNav =
|
|
30
|
+
var _ref = useContext(NavContext),
|
|
31
|
+
activeKey = _ref.activeKey,
|
|
32
|
+
onSelectFromNav = _ref.onSelect;
|
|
29
33
|
|
|
30
34
|
var active = activeProp !== null && activeProp !== void 0 ? activeProp : !isNil(eventKey) && shallowEqual(eventKey, activeKey);
|
|
31
35
|
var emitSelect = useCallback(function (event) {
|
|
@@ -34,6 +38,7 @@ var NavbarItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
34
38
|
}, [eventKey, onSelectProp, onSelectFromNav]);
|
|
35
39
|
|
|
36
40
|
var _useClassNames = useClassNames(classPrefix),
|
|
41
|
+
prefix = _useClassNames.prefix,
|
|
37
42
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
38
43
|
merge = _useClassNames.merge;
|
|
39
44
|
|
|
@@ -54,7 +59,9 @@ var NavbarItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
54
59
|
className: classes,
|
|
55
60
|
onClick: handleClick,
|
|
56
61
|
style: style
|
|
57
|
-
}), icon
|
|
62
|
+
}), icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
63
|
+
className: prefix('icon')
|
|
64
|
+
}), children, /*#__PURE__*/React.createElement(Ripple, null));
|
|
58
65
|
});
|
|
59
66
|
NavbarItem.displayName = 'Navbar.Item';
|
|
60
67
|
NavbarItem.propTypes = {
|
package/esm/Overlay/Modal.d.ts
CHANGED
|
@@ -37,9 +37,6 @@ export interface BaseModalProps extends WithAsProps, AnimationEventProps {
|
|
|
37
37
|
onOpen?: () => void;
|
|
38
38
|
/** Called when Modal is closed */
|
|
39
39
|
onClose?: (event: React.SyntheticEvent) => void;
|
|
40
|
-
}
|
|
41
|
-
interface ModalProps extends BaseModalProps {
|
|
42
|
-
children: (props: any, ref: any) => React.ReactElement;
|
|
43
40
|
container?: HTMLElement | (() => HTMLElement);
|
|
44
41
|
containerClassName?: string;
|
|
45
42
|
backdropTransitionTimeout?: number;
|
|
@@ -48,7 +45,7 @@ interface ModalProps extends BaseModalProps {
|
|
|
48
45
|
onEsc?: React.KeyboardEventHandler;
|
|
49
46
|
onBackdropClick?: React.MouseEventHandler;
|
|
50
47
|
}
|
|
51
|
-
declare const Modal: RsRefForwardingComponent<'div',
|
|
48
|
+
declare const Modal: RsRefForwardingComponent<'div', BaseModalProps>;
|
|
52
49
|
export declare const modalPropTypes: {
|
|
53
50
|
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
54
51
|
className: PropTypes.Requireable<string>;
|
package/esm/Overlay/Overlay.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { TypeAttributes, AnimationEventProps } from '../@types/common';
|
|
3
|
+
import { TypeAttributes, AnimationEventProps, CursorPosition } from '../@types/common';
|
|
4
4
|
export interface OverlayProps extends AnimationEventProps {
|
|
5
5
|
container?: HTMLElement | (() => HTMLElement | null) | null;
|
|
6
6
|
children: React.ReactElement | ((props: any, ref: any) => React.ReactElement);
|
|
@@ -14,6 +14,8 @@ export interface OverlayProps extends AnimationEventProps {
|
|
|
14
14
|
transition?: React.ElementType;
|
|
15
15
|
triggerTarget?: React.RefObject<any>;
|
|
16
16
|
onClose?: React.ReactEventHandler;
|
|
17
|
+
followCursor?: boolean;
|
|
18
|
+
cursorPosition?: CursorPosition | null;
|
|
17
19
|
}
|
|
18
20
|
export declare const overlayPropTypes: {
|
|
19
21
|
container: PropTypes.Requireable<any>;
|
package/esm/Overlay/Overlay.js
CHANGED
|
@@ -48,7 +48,9 @@ var Overlay = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
48
48
|
onExiting = props.onExiting,
|
|
49
49
|
onEnter = props.onEnter,
|
|
50
50
|
onEntering = props.onEntering,
|
|
51
|
-
onEntered = props.onEntered
|
|
51
|
+
onEntered = props.onEntered,
|
|
52
|
+
followCursor = props.followCursor,
|
|
53
|
+
cursorPosition = props.cursorPosition;
|
|
52
54
|
|
|
53
55
|
var _useState = useState(!open),
|
|
54
56
|
exited = _useState[0],
|
|
@@ -82,7 +84,9 @@ var Overlay = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
82
84
|
containerPadding: containerPadding,
|
|
83
85
|
triggerTarget: triggerTarget,
|
|
84
86
|
placement: placement,
|
|
85
|
-
preventOverflow: preventOverflow
|
|
87
|
+
preventOverflow: preventOverflow,
|
|
88
|
+
followCursor: followCursor,
|
|
89
|
+
cursorPosition: cursorPosition
|
|
86
90
|
};
|
|
87
91
|
|
|
88
92
|
var renderChildWithPosition = function renderChildWithPosition(transitionProps, transitionRef) {
|
|
@@ -50,16 +50,20 @@ export interface OverlayTriggerProps extends StandardProps, AnimationEventProps
|
|
|
50
50
|
onMouseOut?: React.MouseEventHandler;
|
|
51
51
|
/** Mouse over callback function */
|
|
52
52
|
onMouseOver?: React.MouseEventHandler;
|
|
53
|
+
/** Mouse move callback function */
|
|
54
|
+
onMouseMove?: React.MouseEventHandler;
|
|
53
55
|
/** Callback fired when open component */
|
|
54
56
|
onOpen?: () => void;
|
|
55
57
|
/** Callback fired when close component */
|
|
56
58
|
onClose?: () => void;
|
|
59
|
+
/** Whether speaker to follow the cursor */
|
|
60
|
+
followCursor?: boolean;
|
|
57
61
|
}
|
|
58
62
|
export interface OverlayTriggerInstance {
|
|
59
|
-
root: HTMLElement;
|
|
63
|
+
root: HTMLElement | undefined;
|
|
60
64
|
updatePosition: () => void;
|
|
61
|
-
open: () => void;
|
|
62
|
-
close: () => void;
|
|
65
|
+
open: (delay?: number) => void;
|
|
66
|
+
close: (delay?: number) => void;
|
|
63
67
|
}
|
|
64
|
-
declare const OverlayTrigger: React.ForwardRefExoticComponent<OverlayTriggerProps & React.RefAttributes<
|
|
68
|
+
declare const OverlayTrigger: React.ForwardRefExoticComponent<OverlayTriggerProps & React.RefAttributes<OverlayTriggerInstance>>;
|
|
65
69
|
export default OverlayTrigger;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import _isUndefined from "lodash/isUndefined";
|
|
4
|
-
import React, { useRef, useEffect, useImperativeHandle, useCallback, useContext } from 'react';
|
|
4
|
+
import React, { useRef, useEffect, useImperativeHandle, useCallback, useContext, useState } from 'react';
|
|
5
5
|
import get from 'lodash/get';
|
|
6
6
|
import isNil from 'lodash/isNil';
|
|
7
7
|
import contains from 'dom-lib/contains';
|
|
@@ -73,12 +73,15 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
73
73
|
rootClose = _props$rootClose === void 0 ? true : _props$rootClose,
|
|
74
74
|
onClick = props.onClick,
|
|
75
75
|
onMouseOver = props.onMouseOver,
|
|
76
|
+
onMouseMove = props.onMouseMove,
|
|
76
77
|
onMouseOut = props.onMouseOut,
|
|
77
78
|
onContextMenu = props.onContextMenu,
|
|
78
79
|
onFocus = props.onFocus,
|
|
79
80
|
onBlur = props.onBlur,
|
|
80
81
|
onClose = props.onClose,
|
|
81
|
-
|
|
82
|
+
followCursor = props.followCursor,
|
|
83
|
+
onExited = props.onExited,
|
|
84
|
+
rest = _objectWithoutPropertiesLoose(props, ["children", "container", "controlId", "defaultOpen", "trigger", "disabled", "readOnly", "plaintext", "open", "delay", "delayOpen", "delayClose", "enterable", "placement", "speaker", "rootClose", "onClick", "onMouseOver", "onMouseMove", "onMouseOut", "onContextMenu", "onFocus", "onBlur", "onClose", "followCursor", "onExited"]);
|
|
82
85
|
|
|
83
86
|
var _usePortal = usePortal({
|
|
84
87
|
container: container
|
|
@@ -90,7 +93,11 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
90
93
|
|
|
91
94
|
var _useControlled = useControlled(openProp, defaultOpen),
|
|
92
95
|
open = _useControlled[0],
|
|
93
|
-
setOpen = _useControlled[1];
|
|
96
|
+
setOpen = _useControlled[1];
|
|
97
|
+
|
|
98
|
+
var _useState = useState(null),
|
|
99
|
+
cursorPosition = _useState[0],
|
|
100
|
+
setCursorPosition = _useState[1]; // Delay the timer to close/open the overlay
|
|
94
101
|
// When the cursor moves from the trigger to the overlay, the overlay will be closed.
|
|
95
102
|
// In order to keep the overlay open, a timer is used to delay the closing.
|
|
96
103
|
|
|
@@ -138,6 +145,9 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
138
145
|
|
|
139
146
|
setOpen(false);
|
|
140
147
|
}, [delayClose, setOpen]);
|
|
148
|
+
var handleExited = useCallback(function () {
|
|
149
|
+
setCursorPosition(null);
|
|
150
|
+
}, []);
|
|
141
151
|
useImperativeHandle(ref, function () {
|
|
142
152
|
return {
|
|
143
153
|
get root() {
|
|
@@ -235,6 +245,16 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
235
245
|
handleCloseWhenLeave();
|
|
236
246
|
}
|
|
237
247
|
}, [handleCloseWhenLeave, trigger]);
|
|
248
|
+
var handledMoveOverlay = useCallback(function (event) {
|
|
249
|
+
setCursorPosition(function () {
|
|
250
|
+
return {
|
|
251
|
+
top: event.pageY,
|
|
252
|
+
left: event.pageX,
|
|
253
|
+
clientTop: event.clientX,
|
|
254
|
+
clientLeft: event.clientY
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
}, [open]);
|
|
238
258
|
var preventDefault = useCallback(function (event) {
|
|
239
259
|
event.preventDefault();
|
|
240
260
|
}, []);
|
|
@@ -244,7 +264,8 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
244
264
|
onMouseOver: onMouseOver,
|
|
245
265
|
onMouseOut: onMouseOut,
|
|
246
266
|
onFocus: onFocus,
|
|
247
|
-
onBlur: onBlur
|
|
267
|
+
onBlur: onBlur,
|
|
268
|
+
onMouseMove: onMouseMove
|
|
248
269
|
};
|
|
249
270
|
|
|
250
271
|
if (!disabled && !readOnly && !plaintext) {
|
|
@@ -282,6 +303,10 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
282
303
|
triggerEvents.onFocus = createChainedFunction(handleDelayedOpen, onFocus);
|
|
283
304
|
triggerEvents.onBlur = createChainedFunction(handleDelayedClose, onBlur);
|
|
284
305
|
}
|
|
306
|
+
|
|
307
|
+
if (trigger !== 'none') {
|
|
308
|
+
triggerEvents.onMouseMove = createChainedFunction(handledMoveOverlay, onMouseMove);
|
|
309
|
+
}
|
|
285
310
|
}
|
|
286
311
|
|
|
287
312
|
var renderOverlay = function renderOverlay() {
|
|
@@ -289,6 +314,7 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
289
314
|
rootClose: rootClose,
|
|
290
315
|
triggerTarget: triggerRef,
|
|
291
316
|
onClose: trigger !== 'none' ? createChainedFunction(handleClose, onClose) : undefined,
|
|
317
|
+
onExited: createChainedFunction(followCursor ? handleExited : undefined, onExited),
|
|
292
318
|
placement: placement,
|
|
293
319
|
container: container,
|
|
294
320
|
open: open
|
|
@@ -307,7 +333,9 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
307
333
|
|
|
308
334
|
return /*#__PURE__*/React.createElement(Overlay, _extends({}, overlayProps, {
|
|
309
335
|
ref: overlayRef,
|
|
310
|
-
childrenProps: speakerProps
|
|
336
|
+
childrenProps: speakerProps,
|
|
337
|
+
followCursor: followCursor,
|
|
338
|
+
cursorPosition: cursorPosition
|
|
311
339
|
}), typeof speaker === 'function' ? function (props, ref) {
|
|
312
340
|
return speaker(_extends({}, props, {
|
|
313
341
|
onClose: handleClose
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TypeAttributes } from '../@types/common';
|
|
2
|
+
import { CursorPosition, TypeAttributes } from '../@types/common';
|
|
3
3
|
export interface PositionChildProps {
|
|
4
4
|
className: string;
|
|
5
5
|
left?: number;
|
|
@@ -13,6 +13,8 @@ export interface PositionProps {
|
|
|
13
13
|
placement?: TypeAttributes.Placement;
|
|
14
14
|
preventOverflow?: boolean;
|
|
15
15
|
triggerTarget?: React.RefObject<any>;
|
|
16
|
+
followCursor?: boolean;
|
|
17
|
+
cursorPosition?: CursorPosition | null;
|
|
16
18
|
}
|
|
17
19
|
export interface PositionInstance {
|
|
18
20
|
updatePosition?: () => void;
|
package/esm/Overlay/Position.js
CHANGED
|
@@ -21,7 +21,9 @@ var usePosition = function usePosition(props, ref) {
|
|
|
21
21
|
_props$containerPaddi = props.containerPadding,
|
|
22
22
|
containerPadding = _props$containerPaddi === void 0 ? 0 : _props$containerPaddi,
|
|
23
23
|
container = props.container,
|
|
24
|
-
triggerTarget = props.triggerTarget
|
|
24
|
+
triggerTarget = props.triggerTarget,
|
|
25
|
+
followCursor = props.followCursor,
|
|
26
|
+
cursorPosition = props.cursorPosition;
|
|
25
27
|
var containerRef = useRef(null);
|
|
26
28
|
var lastTargetRef = useRef(null);
|
|
27
29
|
var overlayResizeObserver = useRef();
|
|
@@ -71,7 +73,7 @@ var usePosition = function usePosition(props, ref) {
|
|
|
71
73
|
|
|
72
74
|
var overlay = getDOMNode(ref.current);
|
|
73
75
|
var containerElement = getContainer(typeof container === 'function' ? container() : container !== null && container !== void 0 ? container : null, ownerDocument(ref.current).body);
|
|
74
|
-
var posi = utils.calcOverlayPosition(overlay, targetElement, containerElement);
|
|
76
|
+
var posi = utils.calcOverlayPosition(overlay, targetElement, containerElement, followCursor ? cursorPosition : undefined);
|
|
75
77
|
|
|
76
78
|
if (forceUpdateDOM && overlay) {
|
|
77
79
|
var _overlay$className, _overlay$className$ma;
|
|
@@ -93,7 +95,7 @@ var usePosition = function usePosition(props, ref) {
|
|
|
93
95
|
|
|
94
96
|
containerRef.current = containerElement;
|
|
95
97
|
lastTargetRef.current = targetElement;
|
|
96
|
-
}, [container, ref, triggerTarget, utils]);
|
|
98
|
+
}, [container, ref, triggerTarget, utils, followCursor, cursorPosition]);
|
|
97
99
|
useEffect(function () {
|
|
98
100
|
updatePosition(false);
|
|
99
101
|
var overlay = getDOMNode(ref.current);
|
|
@@ -138,7 +140,9 @@ var usePosition = function usePosition(props, ref) {
|
|
|
138
140
|
|
|
139
141
|
var Position = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
140
142
|
var children = props.children,
|
|
141
|
-
className = props.className
|
|
143
|
+
className = props.className,
|
|
144
|
+
followCursor = props.followCursor,
|
|
145
|
+
cursorPosition = props.cursorPosition;
|
|
142
146
|
var childRef = React.useRef(null);
|
|
143
147
|
|
|
144
148
|
var _usePosition = usePosition(props, childRef),
|
|
@@ -159,6 +163,10 @@ var Position = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
159
163
|
updatePosition: updatePosition
|
|
160
164
|
};
|
|
161
165
|
});
|
|
166
|
+
useEffect(function () {
|
|
167
|
+
if (!followCursor || !cursorPosition) return;
|
|
168
|
+
updatePosition();
|
|
169
|
+
}, [followCursor, cursorPosition, updatePosition]);
|
|
162
170
|
|
|
163
171
|
if (typeof children === 'function') {
|
|
164
172
|
var childProps = {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { TypeAttributes } from '../@types/common';
|
|
1
|
+
import { CursorPosition, TypeAttributes } from '../@types/common';
|
|
2
|
+
declare type Offset = {
|
|
3
|
+
top: number;
|
|
4
|
+
left: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
2
8
|
export interface PositionType {
|
|
3
9
|
positionLeft?: number;
|
|
4
10
|
positionTop?: number;
|
|
@@ -24,13 +30,14 @@ export interface Dimensions {
|
|
|
24
30
|
scrollY: number;
|
|
25
31
|
}
|
|
26
32
|
declare const _default: (props: UtilProps) => {
|
|
27
|
-
getPosition(target:
|
|
33
|
+
getPosition(target: HTMLElement, container: HTMLElement): {
|
|
28
34
|
top: number;
|
|
29
35
|
left: number;
|
|
30
36
|
height: number;
|
|
31
37
|
width: number;
|
|
32
|
-
} | null;
|
|
38
|
+
} | DOMRect | null;
|
|
39
|
+
getCursorOffsetPosition(target: HTMLElement, container: HTMLElement, cursorPosition: CursorPosition): Offset;
|
|
33
40
|
calcAutoPlacement(targetOffset: any, container: any, overlay: any): any;
|
|
34
|
-
calcOverlayPosition(overlayNode:
|
|
41
|
+
calcOverlayPosition(overlayNode: HTMLElement, target: HTMLElement, container: HTMLElement, cursorPosition?: CursorPosition | null): PositionType;
|
|
35
42
|
};
|
|
36
43
|
export default _default;
|
|
@@ -6,6 +6,8 @@ import getOffset from 'dom-lib/getOffset';
|
|
|
6
6
|
import scrollTop from 'dom-lib/scrollTop';
|
|
7
7
|
import scrollLeft from 'dom-lib/scrollLeft';
|
|
8
8
|
import _getPosition from 'dom-lib/getPosition';
|
|
9
|
+
import getStyle from 'dom-lib/getStyle';
|
|
10
|
+
import nodeName from 'dom-lib/nodeName';
|
|
9
11
|
export var AutoPlacement = {
|
|
10
12
|
left: 'Start',
|
|
11
13
|
right: 'End',
|
|
@@ -130,6 +132,48 @@ export default (function (props) {
|
|
|
130
132
|
var offset = container.tagName === 'BODY' ? getOffset(target) : _getPosition(target, container, false);
|
|
131
133
|
return offset;
|
|
132
134
|
},
|
|
135
|
+
getCursorOffsetPosition: function getCursorOffsetPosition(target, container, cursorPosition) {
|
|
136
|
+
var left = cursorPosition.left,
|
|
137
|
+
top = cursorPosition.top,
|
|
138
|
+
clientLeft = cursorPosition.clientLeft,
|
|
139
|
+
clientTop = cursorPosition.clientTop;
|
|
140
|
+
var offset = {
|
|
141
|
+
left: left,
|
|
142
|
+
top: top,
|
|
143
|
+
width: 10,
|
|
144
|
+
height: 10
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
if (getStyle(target, 'position') === 'fixed') {
|
|
148
|
+
offset.left = clientLeft;
|
|
149
|
+
offset.top = clientTop;
|
|
150
|
+
return offset;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (container.tagName === 'BODY') {
|
|
154
|
+
return offset;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var containerOffset = {
|
|
158
|
+
top: 0,
|
|
159
|
+
left: 0
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
if (nodeName(container) !== 'html') {
|
|
163
|
+
var nextParentOffset = getOffset(container);
|
|
164
|
+
|
|
165
|
+
if (nextParentOffset) {
|
|
166
|
+
containerOffset.top = nextParentOffset.top;
|
|
167
|
+
containerOffset.left = nextParentOffset.left;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
containerOffset.top += parseInt(getStyle(container, 'borderTopWidth'), 10) - scrollTop(container) || 0;
|
|
172
|
+
containerOffset.left += parseInt(getStyle(container, 'borderLeftWidth'), 10) - scrollLeft(container) || 0;
|
|
173
|
+
offset.left = left - containerOffset.left;
|
|
174
|
+
offset.top = top - containerOffset.top;
|
|
175
|
+
return offset;
|
|
176
|
+
},
|
|
133
177
|
calcAutoPlacement: function calcAutoPlacement(targetOffset, container, overlay) {
|
|
134
178
|
var _getContainerDimensio3 = getContainerDimensions(container),
|
|
135
179
|
width = _getContainerDimensio3.width,
|
|
@@ -194,8 +238,8 @@ export default (function (props) {
|
|
|
194
238
|
return "" + direction.key + AutoPlacement[align.key];
|
|
195
239
|
},
|
|
196
240
|
// Calculate the position of the overlay
|
|
197
|
-
calcOverlayPosition: function calcOverlayPosition(overlayNode, target, container) {
|
|
198
|
-
var childOffset = this.getPosition(target, container);
|
|
241
|
+
calcOverlayPosition: function calcOverlayPosition(overlayNode, target, container, cursorPosition) {
|
|
242
|
+
var childOffset = cursorPosition ? this.getCursorOffsetPosition(target, container, cursorPosition) : this.getPosition(target, container);
|
|
199
243
|
|
|
200
244
|
var _ref2 = getOffset(overlayNode),
|
|
201
245
|
overlayHeight = _ref2.height,
|
package/esm/Panel/Panel.js
CHANGED
|
@@ -40,23 +40,26 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
40
40
|
prefix = _useClassNames.prefix,
|
|
41
41
|
withClassPrefix = _useClassNames.withClassPrefix;
|
|
42
42
|
|
|
43
|
-
var _useControlled = useControlled(expandedProp, defaultExpanded),
|
|
44
|
-
expandedState = _useControlled[0],
|
|
45
|
-
setExpanded = _useControlled[1];
|
|
46
|
-
|
|
47
43
|
var _ref = useContext(PanelGroupContext) || {},
|
|
48
44
|
accordion = _ref.accordion,
|
|
49
45
|
activeKey = _ref.activeKey,
|
|
50
46
|
onGroupSelect = _ref.onGroupSelect;
|
|
51
47
|
|
|
48
|
+
var _useControlled = useControlled(expandedProp, defaultExpanded || typeof activeKey !== 'undefined' && activeKey === eventKey),
|
|
49
|
+
expandedState = _useControlled[0],
|
|
50
|
+
setExpanded = _useControlled[1];
|
|
51
|
+
|
|
52
52
|
var collapsible = collapsibleProp;
|
|
53
53
|
var headerRole = headerRoleProp;
|
|
54
54
|
var expanded = expandedState;
|
|
55
55
|
|
|
56
56
|
if (accordion) {
|
|
57
57
|
collapsible = true;
|
|
58
|
-
headerRole = 'button';
|
|
59
|
-
|
|
58
|
+
headerRole = 'button'; // Collapses all inactive panels.
|
|
59
|
+
|
|
60
|
+
if (typeof activeKey !== 'undefined' && activeKey !== eventKey) {
|
|
61
|
+
expanded = false;
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
var handleSelect = useCallback(function (event) {
|