rsuite 5.10.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/ButtonToolbar/styles/index.less +1 -1
- package/CHANGELOG.md +28 -0
- package/Nav/styles/index.less +7 -1
- package/Navbar/styles/index.less +6 -1
- package/README.md +4 -0
- package/Sidenav/styles/index.less +7 -5
- package/cjs/Cascader/DropdownMenu.js +8 -3
- package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -0
- package/cjs/DateRangePicker/DateRangePicker.js +4 -2
- 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/Form/Form.js +21 -7
- package/cjs/Form/FormContext.d.ts +18 -13
- package/cjs/Form/useSchemaModel.d.ts +9 -0
- package/cjs/Form/useSchemaModel.js +46 -0
- package/cjs/FormControl/FormControl.d.ts +3 -0
- package/cjs/FormControl/FormControl.js +9 -2
- package/cjs/FormControl/useRegisterModel.d.ts +4 -0
- package/cjs/FormControl/useRegisterModel.js +20 -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 +14 -3
- 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/dom.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 +19 -10
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +19 -10
- package/dist/rsuite.js +300 -25
- 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/DateRangePicker/DateRangePicker.d.ts +2 -0
- package/esm/DateRangePicker/DateRangePicker.js +4 -2
- 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/Form/Form.js +19 -7
- package/esm/Form/FormContext.d.ts +18 -13
- package/esm/Form/useSchemaModel.d.ts +9 -0
- package/esm/Form/useSchemaModel.js +39 -0
- package/esm/FormControl/FormControl.d.ts +3 -0
- package/esm/FormControl/FormControl.js +9 -6
- package/esm/FormControl/useRegisterModel.d.ts +4 -0
- package/esm/FormControl/useRegisterModel.js +14 -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 +13 -3
- 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/dom.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/variables.less +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { NavDropdownProps } from './NavDropdown';
|
|
3
|
+
import { NavDropdownMenuProps } from './NavDropdownMenu';
|
|
4
|
+
export interface NavMenuProps extends NavDropdownProps, Omit<NavDropdownMenuProps, 'onToggle'> {
|
|
5
|
+
}
|
|
6
|
+
export declare type NavMenuState = {
|
|
7
|
+
items: {
|
|
8
|
+
_id: any;
|
|
9
|
+
eventKey?: any;
|
|
10
|
+
active: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export declare type NavMenuContextProps = [NavMenuState, Dispatch<NavMenuAction>];
|
|
14
|
+
export declare const NavMenuContext: React.Context<NavMenuContextProps | null>;
|
|
15
|
+
export declare enum NavMenuActionType {
|
|
16
|
+
RegisterItem = 0,
|
|
17
|
+
UnregisterItem = 1
|
|
18
|
+
}
|
|
19
|
+
export declare type NavMenuAction = {
|
|
20
|
+
type: NavMenuActionType.RegisterItem;
|
|
21
|
+
payload: {
|
|
22
|
+
_id: any;
|
|
23
|
+
eventKey?: any;
|
|
24
|
+
active: boolean;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
type: NavMenuActionType.UnregisterItem;
|
|
28
|
+
payload: {
|
|
29
|
+
_id: any;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The <Nav.Menu> API
|
|
34
|
+
* When used as direct child of <Nav>, render the NavDropdown
|
|
35
|
+
* When used within another <Nav.Menu>, render the NavDropdownMenu
|
|
36
|
+
*/
|
|
37
|
+
declare const NavMenu: React.ForwardRefExoticComponent<NavMenuProps & React.RefAttributes<any>>;
|
|
38
|
+
export default NavMenu;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { useContext, useReducer } from 'react';
|
|
3
|
+
import NavDropdown from './NavDropdown';
|
|
4
|
+
import NavDropdownMenu from './NavDropdownMenu';
|
|
5
|
+
import { SidenavContext } from '../Sidenav/Sidenav';
|
|
6
|
+
import SidenavDropdown from '../Sidenav/SidenavDropdown';
|
|
7
|
+
import { NavbarContext } from '../Navbar';
|
|
8
|
+
import NavbarDropdown from '../Navbar/NavbarDropdown';
|
|
9
|
+
import NavbarDropdownMenu from '../Navbar/NavbarDropdownMenu';
|
|
10
|
+
import SidenavDropdownMenu from '../Sidenav/SidenavDropdownMenu';
|
|
11
|
+
export var NavMenuContext = /*#__PURE__*/React.createContext(null);
|
|
12
|
+
NavMenuContext.displayName = 'NavMenu.Context';
|
|
13
|
+
export var NavMenuActionType;
|
|
14
|
+
|
|
15
|
+
(function (NavMenuActionType) {
|
|
16
|
+
NavMenuActionType[NavMenuActionType["RegisterItem"] = 0] = "RegisterItem";
|
|
17
|
+
NavMenuActionType[NavMenuActionType["UnregisterItem"] = 1] = "UnregisterItem";
|
|
18
|
+
})(NavMenuActionType || (NavMenuActionType = {}));
|
|
19
|
+
|
|
20
|
+
var initilNavMenuState = {
|
|
21
|
+
items: []
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var reducer = function reducer(state, action) {
|
|
25
|
+
switch (action.type) {
|
|
26
|
+
case NavMenuActionType.RegisterItem:
|
|
27
|
+
return _extends({}, state, {
|
|
28
|
+
items: [].concat(state.items.filter(function (item) {
|
|
29
|
+
return item._id !== action.payload._id;
|
|
30
|
+
}), [action.payload])
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
case NavMenuActionType.UnregisterItem:
|
|
34
|
+
return _extends({}, state, {
|
|
35
|
+
items: state.items.filter(function (item) {
|
|
36
|
+
return item._id !== action.payload._id;
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
default:
|
|
41
|
+
throw new Error('Unrecognizable action type: ' + action.type);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The <Nav.Menu> API
|
|
46
|
+
* When used as direct child of <Nav>, render the NavDropdown
|
|
47
|
+
* When used within another <Nav.Menu>, render the NavDropdownMenu
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
var NavMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
52
|
+
var parentNavMenu = useContext(NavMenuContext);
|
|
53
|
+
var navMenuContext = useReducer(reducer, initilNavMenuState);
|
|
54
|
+
var navbar = useContext(NavbarContext);
|
|
55
|
+
var sidenav = useContext(SidenavContext);
|
|
56
|
+
|
|
57
|
+
if (!parentNavMenu) {
|
|
58
|
+
if (navbar) {
|
|
59
|
+
return /*#__PURE__*/React.createElement(NavMenuContext.Provider, {
|
|
60
|
+
value: navMenuContext
|
|
61
|
+
}, /*#__PURE__*/React.createElement(NavbarDropdown, _extends({
|
|
62
|
+
ref: ref
|
|
63
|
+
}, props)));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (sidenav) {
|
|
67
|
+
return /*#__PURE__*/React.createElement(NavMenuContext.Provider, {
|
|
68
|
+
value: navMenuContext
|
|
69
|
+
}, /*#__PURE__*/React.createElement(SidenavDropdown, _extends({
|
|
70
|
+
ref: ref
|
|
71
|
+
}, props)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return /*#__PURE__*/React.createElement(NavMenuContext.Provider, {
|
|
75
|
+
value: navMenuContext
|
|
76
|
+
}, /*#__PURE__*/React.createElement(NavDropdown, _extends({
|
|
77
|
+
ref: ref
|
|
78
|
+
}, props)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (navbar) {
|
|
82
|
+
return /*#__PURE__*/React.createElement(NavbarDropdownMenu, _extends({
|
|
83
|
+
ref: ref
|
|
84
|
+
}, props));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (sidenav) {
|
|
88
|
+
return /*#__PURE__*/React.createElement(SidenavDropdownMenu, _extends({
|
|
89
|
+
ref: ref
|
|
90
|
+
}, props));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return /*#__PURE__*/React.createElement(NavDropdownMenu, _extends({
|
|
94
|
+
ref: ref
|
|
95
|
+
}, props));
|
|
96
|
+
});
|
|
97
|
+
NavMenu.displayName = 'Nav.Menu';
|
|
98
|
+
export default NavMenu;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TypeAttributes, WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
4
|
+
import Button from '../Button';
|
|
5
|
+
import NavDropdownItem from '../Nav/NavDropdownItem';
|
|
6
|
+
import NavDropdownMenu from '../Nav/NavDropdownMenu';
|
|
7
|
+
export declare type NavbarDropdownTrigger = 'click' | 'hover' | 'contextMenu';
|
|
8
|
+
export interface NavbarDropdownProps<T = any> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'title'> {
|
|
9
|
+
/** Define the title as a submenu */
|
|
10
|
+
title?: React.ReactNode;
|
|
11
|
+
/** Set the icon */
|
|
12
|
+
icon?: React.ReactElement<IconProps>;
|
|
13
|
+
/** Triggering events */
|
|
14
|
+
trigger?: NavbarDropdownTrigger | readonly NavbarDropdownTrigger[];
|
|
15
|
+
/** The placement of Menu */
|
|
16
|
+
placement?: TypeAttributes.Placement8;
|
|
17
|
+
/** Whether or not component is disabled */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** The style of the menu */
|
|
20
|
+
menuStyle?: React.CSSProperties;
|
|
21
|
+
/** A css class to apply to the Toggle DOM node */
|
|
22
|
+
toggleClassName?: string;
|
|
23
|
+
/** You can use a custom element type for this toggle component */
|
|
24
|
+
toggleAs?: React.ElementType;
|
|
25
|
+
/** No caret variation */
|
|
26
|
+
noCaret?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Open the menu and control it
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
31
|
+
open?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated
|
|
34
|
+
*/
|
|
35
|
+
renderTitle?: (children: React.ReactNode) => React.ReactNode;
|
|
36
|
+
/** Custom Toggle */
|
|
37
|
+
renderToggle?: (props: WithAsProps, ref: React.Ref<any>) => any;
|
|
38
|
+
/** The callback function that the menu closes */
|
|
39
|
+
onClose?: () => void;
|
|
40
|
+
/** Menu Pop-up callback function */
|
|
41
|
+
onOpen?: () => void;
|
|
42
|
+
/** Callback function for menu state switching */
|
|
43
|
+
onToggle?: (open: boolean, eventKey?: T | undefined, event?: React.SyntheticEvent) => void;
|
|
44
|
+
}
|
|
45
|
+
export interface NavbarDropdownComponent extends RsRefForwardingComponent<'div', NavbarDropdownProps> {
|
|
46
|
+
<ToggleAs extends React.ElementType = typeof Button>(props: NavbarDropdownProps & {
|
|
47
|
+
ref?: React.Ref<any>;
|
|
48
|
+
toggleAs?: ToggleAs;
|
|
49
|
+
} & React.ComponentProps<ToggleAs>, context: any): JSX.Element | null;
|
|
50
|
+
Item: typeof NavDropdownItem;
|
|
51
|
+
Menu: typeof NavDropdownMenu;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
declare const NavbarDropdown: NavbarDropdownComponent;
|
|
57
|
+
export default NavbarDropdown;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import omit from 'lodash/omit';
|
|
6
|
+
import { mergeRefs, PLACEMENT_8, placementPolyfill, useClassNames } from '../utils';
|
|
7
|
+
import deprecatePropType from '../utils/deprecatePropType';
|
|
8
|
+
import kebabCase from 'lodash/kebabCase';
|
|
9
|
+
import { NavbarContext } from '.';
|
|
10
|
+
import Disclosure from '../Disclosure/Disclosure';
|
|
11
|
+
import NavDropdownItem from '../Nav/NavDropdownItem';
|
|
12
|
+
import NavDropdownMenu from '../Nav/NavDropdownMenu';
|
|
13
|
+
import NavbarDropdownToggle from './NavbarDropdownToggle';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
var NavbarDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
+
var navbar = useContext(NavbarContext);
|
|
20
|
+
|
|
21
|
+
if (!navbar) {
|
|
22
|
+
throw new Error('<Navbar.Dropdown> should be used within a <Navbar> component.');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var _props$as = props.as,
|
|
26
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
27
|
+
title = props.title,
|
|
28
|
+
onClose = props.onClose,
|
|
29
|
+
onOpen = props.onOpen,
|
|
30
|
+
_onToggle = props.onToggle,
|
|
31
|
+
_props$trigger = props.trigger,
|
|
32
|
+
trigger = _props$trigger === void 0 ? 'click' : _props$trigger,
|
|
33
|
+
_props$placement = props.placement,
|
|
34
|
+
placement = _props$placement === void 0 ? 'bottomStart' : _props$placement,
|
|
35
|
+
toggleAs = props.toggleAs,
|
|
36
|
+
toggleClassName = props.toggleClassName,
|
|
37
|
+
_props$classPrefix = props.classPrefix,
|
|
38
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown' : _props$classPrefix,
|
|
39
|
+
className = props.className,
|
|
40
|
+
disabled = props.disabled,
|
|
41
|
+
children = props.children,
|
|
42
|
+
menuStyle = props.menuStyle,
|
|
43
|
+
style = props.style,
|
|
44
|
+
toggleProps = _objectWithoutPropertiesLoose(props, ["as", "title", "onClose", "onOpen", "onToggle", "trigger", "placement", "toggleAs", "toggleClassName", "classPrefix", "className", "disabled", "children", "menuStyle", "style"]);
|
|
45
|
+
|
|
46
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
47
|
+
merge = _useClassNames.merge,
|
|
48
|
+
withClassPrefix = _useClassNames.withClassPrefix;
|
|
49
|
+
|
|
50
|
+
var _useClassNames2 = useClassNames('dropdown-menu'),
|
|
51
|
+
withMenuClassPrefix = _useClassNames2.withClassPrefix,
|
|
52
|
+
mergeMenuClassName = _useClassNames2.merge;
|
|
53
|
+
|
|
54
|
+
return /*#__PURE__*/React.createElement(Disclosure, {
|
|
55
|
+
trigger: trigger,
|
|
56
|
+
hideOnClickOutside: true,
|
|
57
|
+
onToggle: function onToggle(open) {
|
|
58
|
+
_onToggle === null || _onToggle === void 0 ? void 0 : _onToggle(open);
|
|
59
|
+
|
|
60
|
+
if (open) {
|
|
61
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
62
|
+
} else {
|
|
63
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, function (_ref, containerRef) {
|
|
67
|
+
var _withClassPrefix;
|
|
68
|
+
|
|
69
|
+
var open = _ref.open;
|
|
70
|
+
var classes = merge(className, withClassPrefix((_withClassPrefix = {}, _withClassPrefix["placement-" + kebabCase(placementPolyfill(placement))] = !!placement, _withClassPrefix.disabled = disabled, _withClassPrefix.open = open, _withClassPrefix)));
|
|
71
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
72
|
+
ref: mergeRefs(ref, containerRef),
|
|
73
|
+
className: classes,
|
|
74
|
+
style: style
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Disclosure.Button, null, function (buttonProps, buttonRef) {
|
|
76
|
+
return /*#__PURE__*/React.createElement(NavbarDropdownToggle, _extends({
|
|
77
|
+
ref: buttonRef,
|
|
78
|
+
as: toggleAs,
|
|
79
|
+
className: toggleClassName,
|
|
80
|
+
placement: placement,
|
|
81
|
+
disabled: disabled
|
|
82
|
+
}, omit(buttonProps, ['open']), toggleProps), title);
|
|
83
|
+
}), /*#__PURE__*/React.createElement(Disclosure.Content, null, function (_ref2, elementRef) {
|
|
84
|
+
var open = _ref2.open;
|
|
85
|
+
var menuClassName = mergeMenuClassName(className, withMenuClassPrefix());
|
|
86
|
+
return /*#__PURE__*/React.createElement("ul", {
|
|
87
|
+
ref: elementRef,
|
|
88
|
+
className: menuClassName,
|
|
89
|
+
style: menuStyle,
|
|
90
|
+
hidden: !open
|
|
91
|
+
}, children);
|
|
92
|
+
}));
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
NavbarDropdown.Item = NavDropdownItem;
|
|
96
|
+
NavbarDropdown.Menu = NavDropdownMenu;
|
|
97
|
+
NavbarDropdown.displayName = 'Navbar.Dropdown';
|
|
98
|
+
NavbarDropdown.propTypes = {
|
|
99
|
+
classPrefix: PropTypes.string,
|
|
100
|
+
trigger: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['click', 'hover', 'contextMenu'])]),
|
|
101
|
+
placement: PropTypes.oneOf(PLACEMENT_8),
|
|
102
|
+
title: PropTypes.node,
|
|
103
|
+
disabled: PropTypes.bool,
|
|
104
|
+
icon: PropTypes.node,
|
|
105
|
+
menuStyle: PropTypes.object,
|
|
106
|
+
className: PropTypes.string,
|
|
107
|
+
toggleClassName: PropTypes.string,
|
|
108
|
+
children: PropTypes.node,
|
|
109
|
+
open: deprecatePropType(PropTypes.bool),
|
|
110
|
+
eventKey: PropTypes.any,
|
|
111
|
+
as: PropTypes.elementType,
|
|
112
|
+
toggleAs: PropTypes.elementType,
|
|
113
|
+
noCaret: PropTypes.bool,
|
|
114
|
+
style: PropTypes.object,
|
|
115
|
+
onClose: PropTypes.func,
|
|
116
|
+
onOpen: PropTypes.func,
|
|
117
|
+
onToggle: PropTypes.func,
|
|
118
|
+
onMouseEnter: PropTypes.func,
|
|
119
|
+
onMouseLeave: PropTypes.func,
|
|
120
|
+
onContextMenu: PropTypes.func,
|
|
121
|
+
onClick: PropTypes.func,
|
|
122
|
+
renderToggle: PropTypes.func
|
|
123
|
+
};
|
|
124
|
+
export default NavbarDropdown;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RsRefForwardingComponent, WithAsProps } from '../@types/common';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
4
|
+
export interface NavbarDropdownItemProps<T = any> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
|
|
5
|
+
/** Active the current option */
|
|
6
|
+
active?: boolean;
|
|
7
|
+
/** Primary content */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** You can use a custom element for this component */
|
|
10
|
+
as?: React.ElementType;
|
|
11
|
+
/** Whether to display the divider */
|
|
12
|
+
divider?: boolean;
|
|
13
|
+
/** Disable the current option */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** The value of the current option */
|
|
16
|
+
eventKey?: T;
|
|
17
|
+
/** Displays a custom panel */
|
|
18
|
+
panel?: boolean;
|
|
19
|
+
/** Set the icon */
|
|
20
|
+
icon?: React.ReactElement<IconProps>;
|
|
21
|
+
/** The submenu that this menuitem controls (if exists) */
|
|
22
|
+
submenu?: React.ReactElement;
|
|
23
|
+
/**
|
|
24
|
+
* The sub-level menu appears from the right side by default, and when `pullLeft` is set, it appears from the left.
|
|
25
|
+
* @deprecated Submenus are now pointing the same direction.
|
|
26
|
+
*/
|
|
27
|
+
pullLeft?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the submenu is opened.
|
|
30
|
+
* @deprecated
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
open?: boolean;
|
|
34
|
+
/** Select the callback function for the current option */
|
|
35
|
+
onSelect?: (eventKey: T, event: React.SyntheticEvent) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
declare const NavbarDropdownItem: RsRefForwardingComponent<'li', NavbarDropdownItemProps>;
|
|
41
|
+
export default NavbarDropdownItem;
|
|
@@ -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;
|