rsuite 5.12.0 → 5.13.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/CHANGELOG.md +10 -0
- package/Nav/styles/index.less +7 -1
- package/Navbar/styles/index.less +6 -1
- package/Sidenav/styles/index.less +7 -5
- package/cjs/Cascader/DropdownMenu.js +8 -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/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/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 +26 -0
- package/cjs/Nav/NavDropdownMenu.js +156 -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/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 +37 -0
- package/cjs/Navbar/NavbarDropdownMenu.js +155 -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/Picker/utils.js +22 -15
- 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 +72 -0
- package/cjs/Sidenav/SidenavItem.d.ts +3 -0
- package/cjs/Sidenav/SidenavItem.js +22 -14
- 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/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 +18 -9
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +18 -9
- package/dist/rsuite.js +275 -22
- 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/Cascader/DropdownMenu.js +8 -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/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/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 +26 -0
- package/esm/Nav/NavDropdownMenu.js +138 -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/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 +37 -0
- package/esm/Navbar/NavbarDropdownMenu.js +135 -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/Picker/utils.js +22 -14
- 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 +55 -0
- package/esm/Sidenav/SidenavItem.d.ts +3 -0
- package/esm/Sidenav/SidenavItem.js +23 -15
- 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/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/variables.less +1 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useCallback, useContext } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import deprecatePropType from '../utils/deprecatePropType';
|
|
6
|
+
import isNil from 'lodash/isNil';
|
|
7
|
+
import { createChainedFunction, shallowEqual, useClassNames } from '../utils';
|
|
8
|
+
import { NavbarContext } from './Navbar';
|
|
9
|
+
import DisclosureContext, { DisclosureActionTypes } from '../Disclosure/DisclosureContext';
|
|
10
|
+
import { useRenderDropdownItem } from '../Dropdown/useRenderDropdownItem';
|
|
11
|
+
import NavContext from '../Nav/NavContext';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
var NavbarDropdownItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
17
|
+
var navbar = useContext(NavbarContext);
|
|
18
|
+
var nav = useContext(NavContext);
|
|
19
|
+
|
|
20
|
+
if (!navbar || !nav) {
|
|
21
|
+
throw new Error('<Navbar.Dropdown.Item> must be rendered within a <Nav> component within a <Navbar> component.');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var _props$classPrefix = props.classPrefix,
|
|
25
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown-item' : _props$classPrefix,
|
|
26
|
+
className = props.className,
|
|
27
|
+
activeProp = props.active,
|
|
28
|
+
eventKey = props.eventKey,
|
|
29
|
+
onSelect = props.onSelect,
|
|
30
|
+
icon = props.icon,
|
|
31
|
+
_props$as = props.as,
|
|
32
|
+
Component = _props$as === void 0 ? 'li' : _props$as,
|
|
33
|
+
divider = props.divider,
|
|
34
|
+
panel = props.panel,
|
|
35
|
+
children = props.children,
|
|
36
|
+
disabled = props.disabled,
|
|
37
|
+
restProps = _objectWithoutPropertiesLoose(props, ["classPrefix", "className", "active", "eventKey", "onSelect", "icon", "as", "divider", "panel", "children", "disabled"]);
|
|
38
|
+
|
|
39
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
40
|
+
merge = _useClassNames.merge,
|
|
41
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
42
|
+
prefix = _useClassNames.prefix;
|
|
43
|
+
|
|
44
|
+
var handleSelectItem = useCallback(function (event) {
|
|
45
|
+
var _nav$onSelect;
|
|
46
|
+
|
|
47
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(eventKey, event);
|
|
48
|
+
(_nav$onSelect = nav.onSelect) === null || _nav$onSelect === void 0 ? void 0 : _nav$onSelect.call(nav, eventKey, event);
|
|
49
|
+
}, [onSelect, eventKey, nav]);
|
|
50
|
+
var disclosure = useContext(DisclosureContext);
|
|
51
|
+
|
|
52
|
+
var _ref = disclosure !== null && disclosure !== void 0 ? disclosure : [],
|
|
53
|
+
dispatchDisclosure = _ref[1];
|
|
54
|
+
|
|
55
|
+
var handleClickNavbarDropdownItem = useCallback(function (event) {
|
|
56
|
+
dispatchDisclosure === null || dispatchDisclosure === void 0 ? void 0 : dispatchDisclosure({
|
|
57
|
+
type: DisclosureActionTypes.Hide,
|
|
58
|
+
cascade: true
|
|
59
|
+
});
|
|
60
|
+
handleSelectItem === null || handleSelectItem === void 0 ? void 0 : handleSelectItem(event);
|
|
61
|
+
}, [dispatchDisclosure, handleSelectItem]);
|
|
62
|
+
var selected = activeProp || !isNil(eventKey) && shallowEqual(nav.activeKey, eventKey);
|
|
63
|
+
var renderDropdownItem = useRenderDropdownItem(Component);
|
|
64
|
+
|
|
65
|
+
if (divider) {
|
|
66
|
+
return renderDropdownItem(_extends({
|
|
67
|
+
ref: ref,
|
|
68
|
+
role: 'separator',
|
|
69
|
+
className: merge(prefix('divider'), className)
|
|
70
|
+
}, restProps));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (panel) {
|
|
74
|
+
return renderDropdownItem(_extends({
|
|
75
|
+
ref: ref,
|
|
76
|
+
className: merge(prefix('panel'), className),
|
|
77
|
+
children: children
|
|
78
|
+
}, restProps));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var classes = merge(className, withClassPrefix({
|
|
82
|
+
'with-icon': icon,
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
divider: divider,
|
|
85
|
+
panel: panel,
|
|
86
|
+
active: selected
|
|
87
|
+
}));
|
|
88
|
+
var dataAttributes = {
|
|
89
|
+
'data-event-key': eventKey
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (!isNil(eventKey) && typeof eventKey !== 'string') {
|
|
93
|
+
dataAttributes['data-event-key-type'] = typeof eventKey;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return renderDropdownItem(_extends({
|
|
97
|
+
ref: ref,
|
|
98
|
+
className: classes,
|
|
99
|
+
'aria-current': selected || undefined
|
|
100
|
+
}, dataAttributes, restProps, {
|
|
101
|
+
onClick: createChainedFunction(handleClickNavbarDropdownItem, restProps.onClick),
|
|
102
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
103
|
+
className: prefix('menu-icon')
|
|
104
|
+
}), children)
|
|
105
|
+
}));
|
|
106
|
+
});
|
|
107
|
+
NavbarDropdownItem.displayName = 'Navbar.Dropdown.Item';
|
|
108
|
+
NavbarDropdownItem.propTypes = {
|
|
109
|
+
as: PropTypes.elementType,
|
|
110
|
+
divider: PropTypes.bool,
|
|
111
|
+
panel: PropTypes.bool,
|
|
112
|
+
trigger: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['click', 'hover'])]),
|
|
113
|
+
open: deprecatePropType(PropTypes.bool),
|
|
114
|
+
active: PropTypes.bool,
|
|
115
|
+
disabled: PropTypes.bool,
|
|
116
|
+
pullLeft: deprecatePropType(PropTypes.bool),
|
|
117
|
+
submenu: PropTypes.element,
|
|
118
|
+
onSelect: PropTypes.func,
|
|
119
|
+
onClick: PropTypes.func,
|
|
120
|
+
icon: PropTypes.node,
|
|
121
|
+
eventKey: PropTypes.any,
|
|
122
|
+
className: PropTypes.string,
|
|
123
|
+
style: PropTypes.object,
|
|
124
|
+
children: PropTypes.node,
|
|
125
|
+
classPrefix: PropTypes.string,
|
|
126
|
+
tabIndex: PropTypes.number
|
|
127
|
+
};
|
|
128
|
+
export default NavbarDropdownItem;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StandardProps } from '../@types/common';
|
|
3
|
+
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
4
|
+
export interface NavbarDropdownMenuProps<T = any> extends StandardProps {
|
|
5
|
+
/** Define the title as a submenu */
|
|
6
|
+
title?: React.ReactNode;
|
|
7
|
+
/** The submenu expands from the left and defaults to the right */
|
|
8
|
+
pullLeft?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Only used for setting the default expand state when it's a submenu.
|
|
11
|
+
*/
|
|
12
|
+
eventKey?: T;
|
|
13
|
+
/** Set the icon */
|
|
14
|
+
icon?: React.ReactElement<IconProps>;
|
|
15
|
+
open?: boolean;
|
|
16
|
+
collapsible?: boolean;
|
|
17
|
+
expanded?: boolean;
|
|
18
|
+
active?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
activeKey?: T;
|
|
21
|
+
onToggle?: (open: boolean, eventKey?: T | undefined, event?: React.SyntheticEvent) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @private this component is not supposed to be used directly
|
|
25
|
+
* Instead it's rendered by a <Nav.Menu> within a <Navbar>
|
|
26
|
+
*
|
|
27
|
+
* <Navbar>
|
|
28
|
+
* <Nav>
|
|
29
|
+
* <Nav.Menu>
|
|
30
|
+
* <Nav.Menu title="menu"> -> This submenu will render <NavbarDropdownMenu> component
|
|
31
|
+
* </Nav.Menu>
|
|
32
|
+
* </Nav.Menu>
|
|
33
|
+
* </Nav>
|
|
34
|
+
* </Navbar>
|
|
35
|
+
*/
|
|
36
|
+
declare const NavbarDropdownMenu: React.ForwardRefExoticComponent<NavbarDropdownMenuProps<any> & Omit<React.HTMLAttributes<HTMLUListElement>, "title" | "onSelect"> & React.RefAttributes<HTMLElement>>;
|
|
37
|
+
export default NavbarDropdownMenu;
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @private this component is not supposed to be used directly
|
|
20
|
+
* Instead it's rendered by a <Nav.Menu> within a <Navbar>
|
|
21
|
+
*
|
|
22
|
+
* <Navbar>
|
|
23
|
+
* <Nav>
|
|
24
|
+
* <Nav.Menu>
|
|
25
|
+
* <Nav.Menu title="menu"> -> This submenu will render <NavbarDropdownMenu> component
|
|
26
|
+
* </Nav.Menu>
|
|
27
|
+
* </Nav.Menu>
|
|
28
|
+
* </Nav>
|
|
29
|
+
* </Navbar>
|
|
30
|
+
*/
|
|
31
|
+
var NavbarDropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
32
|
+
var navbar = useContext(NavbarContext);
|
|
33
|
+
var nav = useContext(NavContext);
|
|
34
|
+
|
|
35
|
+
if (!navbar || !nav) {
|
|
36
|
+
throw new Error('<Navbar.Dropdown.Menu> must be rendered within a <Nav> within a <Navbar> component.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var _onToggle = props.onToggle,
|
|
40
|
+
eventKey = props.eventKey,
|
|
41
|
+
title = props.title,
|
|
42
|
+
_props$classPrefix = props.classPrefix,
|
|
43
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu' : _props$classPrefix,
|
|
44
|
+
children = props.children,
|
|
45
|
+
rest = _objectWithoutPropertiesLoose(props, ["onToggle", "eventKey", "title", "classPrefix", "children"]);
|
|
46
|
+
|
|
47
|
+
var _useCustom = useCustom('DropdownMenu'),
|
|
48
|
+
rtl = _useCustom.rtl;
|
|
49
|
+
|
|
50
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
51
|
+
prefix = _useClassNames.prefix;
|
|
52
|
+
|
|
53
|
+
var _useClassNames2 = useClassNames('dropdown-menu'),
|
|
54
|
+
withMenuClassPrefix = _useClassNames2.withClassPrefix,
|
|
55
|
+
mergeMenuClassName = _useClassNames2.merge;
|
|
56
|
+
|
|
57
|
+
var _useClassNames3 = useClassNames('dropdown-item'),
|
|
58
|
+
mergeItemClassNames = _useClassNames3.merge,
|
|
59
|
+
withItemClassPrefix = _useClassNames3.withClassPrefix,
|
|
60
|
+
prefixItemClassName = _useClassNames3.prefix; // Parent menu exists. This is a submenu.
|
|
61
|
+
// Should render a `menuitem` that controls this submenu.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var _omit = omit(rest, ['trigger']),
|
|
65
|
+
icon = _omit.icon,
|
|
66
|
+
className = _omit.className,
|
|
67
|
+
disabled = _omit.disabled,
|
|
68
|
+
menuProps = _objectWithoutPropertiesLoose(_omit, ["icon", "className", "disabled"]);
|
|
69
|
+
|
|
70
|
+
var Icon = rtl ? AngleLeft : AngleRight;
|
|
71
|
+
return /*#__PURE__*/React.createElement(Disclosure, {
|
|
72
|
+
hideOnClickOutside: true,
|
|
73
|
+
trigger: ['click', 'mouseover'],
|
|
74
|
+
onToggle: function onToggle(open, event) {
|
|
75
|
+
return _onToggle === null || _onToggle === void 0 ? void 0 : _onToggle(open, undefined, event);
|
|
76
|
+
}
|
|
77
|
+
}, function (_ref, containerRef) {
|
|
78
|
+
var open = _ref.open,
|
|
79
|
+
props = _objectWithoutPropertiesLoose(_ref, ["open"]);
|
|
80
|
+
|
|
81
|
+
var classes = mergeItemClassNames(className, withItemClassPrefix({
|
|
82
|
+
disabled: disabled,
|
|
83
|
+
open: open,
|
|
84
|
+
submenu: true
|
|
85
|
+
}));
|
|
86
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
|
87
|
+
ref: mergeRefs(ref, containerRef),
|
|
88
|
+
className: classes
|
|
89
|
+
}, props), /*#__PURE__*/React.createElement(Disclosure.Button, null, function (_ref2, buttonRef) {
|
|
90
|
+
var open = _ref2.open,
|
|
91
|
+
buttonProps = _objectWithoutPropertiesLoose(_ref2, ["open"]);
|
|
92
|
+
|
|
93
|
+
var classes = mergeItemClassNames(className, prefixItemClassName(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["toggle"]))), withItemClassPrefix({
|
|
94
|
+
'with-icon': icon,
|
|
95
|
+
open: open,
|
|
96
|
+
disabled: disabled
|
|
97
|
+
}));
|
|
98
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
99
|
+
ref: mergeRefs(buttonRef, buttonRef),
|
|
100
|
+
className: classes,
|
|
101
|
+
"data-event-key": eventKey,
|
|
102
|
+
"data-event-key-type": typeof eventKey
|
|
103
|
+
}, buttonProps), icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
104
|
+
className: prefix('menu-icon')
|
|
105
|
+
}), title, /*#__PURE__*/React.createElement(Icon, {
|
|
106
|
+
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["toggle-icon"])))
|
|
107
|
+
}));
|
|
108
|
+
}), /*#__PURE__*/React.createElement(Disclosure.Content, null, function (_ref3, elementRef) {
|
|
109
|
+
var open = _ref3.open;
|
|
110
|
+
var menuClassName = mergeMenuClassName(className, withMenuClassPrefix());
|
|
111
|
+
return /*#__PURE__*/React.createElement("ul", _extends({
|
|
112
|
+
ref: elementRef,
|
|
113
|
+
className: menuClassName,
|
|
114
|
+
hidden: !open
|
|
115
|
+
}, menuProps), children);
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
NavbarDropdownMenu.displayName = 'Nav.Dropdown.Menu';
|
|
120
|
+
NavbarDropdownMenu.propTypes = {
|
|
121
|
+
active: PropTypes.bool,
|
|
122
|
+
activeKey: PropTypes.any,
|
|
123
|
+
className: PropTypes.string,
|
|
124
|
+
children: PropTypes.node,
|
|
125
|
+
icon: PropTypes.any,
|
|
126
|
+
classPrefix: PropTypes.string,
|
|
127
|
+
pullLeft: PropTypes.bool,
|
|
128
|
+
title: PropTypes.node,
|
|
129
|
+
open: PropTypes.bool,
|
|
130
|
+
eventKey: PropTypes.any,
|
|
131
|
+
expanded: PropTypes.bool,
|
|
132
|
+
collapsible: PropTypes.bool,
|
|
133
|
+
onToggle: PropTypes.func
|
|
134
|
+
};
|
|
135
|
+
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/Picker/utils.js
CHANGED
|
@@ -2,7 +2,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
2
2
|
import React, { useState, useImperativeHandle, useCallback } from 'react';
|
|
3
3
|
import kebabCase from 'lodash/kebabCase';
|
|
4
4
|
import trim from 'lodash/trim';
|
|
5
|
-
import isNil from 'lodash/isNil';
|
|
6
5
|
import isFunction from 'lodash/isFunction';
|
|
7
6
|
import isUndefined from 'lodash/isUndefined';
|
|
8
7
|
import omit from 'lodash/omit';
|
|
@@ -174,20 +173,29 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
174
173
|
return [];
|
|
175
174
|
}
|
|
176
175
|
|
|
177
|
-
var menu = isFunction(target) ? target() : target;
|
|
178
176
|
var currentKeys = keys;
|
|
179
177
|
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
if (layer < 1) {
|
|
179
|
+
var popup = isFunction(target) ? target() : target;
|
|
180
|
+
var rootMenu = popup === null || popup === void 0 ? void 0 : popup.querySelector('[data-layer="0"]');
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
setKeys(currentKeys);
|
|
187
|
-
}
|
|
182
|
+
if (rootMenu) {
|
|
183
|
+
var _rootMenu$querySelect;
|
|
188
184
|
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
currentKeys = Array.from((_rootMenu$querySelect = rootMenu.querySelectorAll(focusableQueryKey)) !== null && _rootMenu$querySelect !== void 0 ? _rootMenu$querySelect : []).map(function (item) {
|
|
186
|
+
var _item$dataset;
|
|
187
|
+
|
|
188
|
+
return (_item$dataset = item.dataset) === null || _item$dataset === void 0 ? void 0 : _item$dataset.key;
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
var _popup$querySelectorA;
|
|
192
|
+
|
|
193
|
+
currentKeys = Array.from((_popup$querySelectorA = popup === null || popup === void 0 ? void 0 : popup.querySelectorAll(focusableQueryKey)) !== null && _popup$querySelectorA !== void 0 ? _popup$querySelectorA : []).map(function (item) {
|
|
194
|
+
var _item$dataset2;
|
|
195
|
+
|
|
196
|
+
return (_item$dataset2 = item.dataset) === null || _item$dataset2 === void 0 ? void 0 : _item$dataset2.key;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
191
199
|
} // 1. It is necessary to traverse the `keys` instead of `data` here to preserve the order of the array.
|
|
192
200
|
// 2. The values in `keys` are all string, so the corresponding value of `data` should also be converted to string
|
|
193
201
|
|
|
@@ -197,7 +205,7 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
197
205
|
return "" + i[valueKey] === key;
|
|
198
206
|
});
|
|
199
207
|
});
|
|
200
|
-
}, [data, focusableQueryKey, keys, target, valueKey]);
|
|
208
|
+
}, [data, focusableQueryKey, keys, target, valueKey, layer]);
|
|
201
209
|
/**
|
|
202
210
|
* Get the index of the focus item.
|
|
203
211
|
*/
|
|
@@ -246,9 +254,9 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
246
254
|
var _Array$from;
|
|
247
255
|
|
|
248
256
|
return (_Array$from = Array.from(subMenu.querySelectorAll(focusableQueryKey))) === null || _Array$from === void 0 ? void 0 : _Array$from.map(function (item) {
|
|
249
|
-
var _item$
|
|
257
|
+
var _item$dataset3;
|
|
250
258
|
|
|
251
|
-
return (_item$
|
|
259
|
+
return (_item$dataset3 = item.dataset) === null || _item$dataset3 === void 0 ? void 0 : _item$dataset3.key;
|
|
252
260
|
});
|
|
253
261
|
}
|
|
254
262
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TypeAttributes, WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
4
|
+
export interface SidenavDropdownProps<T = any> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
5
|
+
/** Define the title as a submenu */
|
|
6
|
+
title?: React.ReactNode;
|
|
7
|
+
/** Set the icon */
|
|
8
|
+
icon?: React.ReactElement<IconProps>;
|
|
9
|
+
/** The placement of Menu */
|
|
10
|
+
placement?: TypeAttributes.Placement8;
|
|
11
|
+
/** Whether or not component is disabled */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** The style of the menu */
|
|
14
|
+
menuStyle?: React.CSSProperties;
|
|
15
|
+
/** A css class to apply to the Toggle DOM node */
|
|
16
|
+
toggleClassName?: string;
|
|
17
|
+
/** The value of the current option */
|
|
18
|
+
eventKey?: T;
|
|
19
|
+
/** You can use a custom element type for this toggle component */
|
|
20
|
+
toggleAs?: React.ElementType;
|
|
21
|
+
/** No caret variation */
|
|
22
|
+
noCaret?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Open the menu and control it
|
|
25
|
+
* @deprecated
|
|
26
|
+
*/
|
|
27
|
+
open?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Custom title
|
|
30
|
+
* @deprecated Use `renderToggle` instead.
|
|
31
|
+
*/
|
|
32
|
+
renderTitle?: (children?: React.ReactNode) => React.ReactNode;
|
|
33
|
+
/** Custom Toggle */
|
|
34
|
+
renderToggle?: (props: WithAsProps, ref: React.Ref<any>) => any;
|
|
35
|
+
/** The callback function that the menu closes */
|
|
36
|
+
onClose?: () => void;
|
|
37
|
+
/** Menu Pop-up callback function */
|
|
38
|
+
onOpen?: () => void;
|
|
39
|
+
/** Callback function for menu state switching */
|
|
40
|
+
onToggle?: (open: boolean) => void;
|
|
41
|
+
}
|
|
42
|
+
declare const ExpandedSidenavDropdown: RsRefForwardingComponent<'li', SidenavDropdownProps>;
|
|
43
|
+
export default ExpandedSidenavDropdown;
|