index.js
5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var React = _interopRequireWildcard(require("react"));
var _rcMenu = _interopRequireWildcard(require("rc-menu"));
var _classnames = _interopRequireDefault(require("classnames"));
var _SubMenu = _interopRequireDefault(require("./SubMenu"));
var _MenuItem = _interopRequireDefault(require("./MenuItem"));
var _configProvider = require("../config-provider");
var _devWarning = _interopRequireDefault(require("../_util/devWarning"));
var _Sider = require("../layout/Sider");
var _motion = _interopRequireDefault(require("../_util/motion"));
var _reactNode = require("../_util/reactNode");
var _MenuContext = _interopRequireDefault(require("./MenuContext"));
var InternalMenu = /*#__PURE__*/function (_React$Component) {
(0, _inherits2["default"])(InternalMenu, _React$Component);
var _super = (0, _createSuper2["default"])(InternalMenu);
function InternalMenu(props) {
var _this;
(0, _classCallCheck2["default"])(this, InternalMenu);
_this = _super.call(this, props);
_this.renderMenu = function (_ref) {
var getPopupContainer = _ref.getPopupContainer,
getPrefixCls = _ref.getPrefixCls,
direction = _ref.direction;
var _this$props = _this.props,
customizePrefixCls = _this$props.prefixCls,
className = _this$props.className,
theme = _this$props.theme,
expandIcon = _this$props.expandIcon;
var defaultMotions = {
horizontal: {
motionName: 'slide-up'
},
inline: _motion["default"],
other: {
motionName: 'zoom-big'
}
};
var prefixCls = getPrefixCls('menu', customizePrefixCls);
var menuClassName = (0, _classnames["default"])("".concat(prefixCls, "-").concat(theme), (0, _defineProperty2["default"])({}, "".concat(prefixCls, "-inline-collapsed"), _this.getInlineCollapsed()), className);
return /*#__PURE__*/React.createElement(_MenuContext["default"].Provider, {
value: {
inlineCollapsed: _this.getInlineCollapsed() || false,
antdMenuTheme: theme,
direction: direction
}
}, /*#__PURE__*/React.createElement(_rcMenu["default"], (0, _extends2["default"])({
getPopupContainer: getPopupContainer
}, _this.props, {
className: menuClassName,
prefixCls: prefixCls,
direction: direction,
defaultMotions: defaultMotions,
expandIcon: (0, _reactNode.cloneElement)(expandIcon, {
className: "".concat(prefixCls, "-submenu-expand-icon")
})
})));
};
(0, _devWarning["default"])(!('inlineCollapsed' in props && props.mode !== 'inline'), 'Menu', '`inlineCollapsed` should only be used when `mode` is inline.');
(0, _devWarning["default"])(!(props.siderCollapsed !== undefined && 'inlineCollapsed' in props), 'Menu', '`inlineCollapsed` not control Menu under Sider. Should set `collapsed` on Sider instead.');
return _this;
}
(0, _createClass2["default"])(InternalMenu, [{
key: "getInlineCollapsed",
value: function getInlineCollapsed() {
var _this$props2 = this.props,
inlineCollapsed = _this$props2.inlineCollapsed,
siderCollapsed = _this$props2.siderCollapsed;
if (siderCollapsed !== undefined) {
return siderCollapsed;
}
return inlineCollapsed;
}
}, {
key: "render",
value: function render() {
return /*#__PURE__*/React.createElement(_configProvider.ConfigConsumer, null, this.renderMenu);
}
}]);
return InternalMenu;
}(React.Component);
InternalMenu.defaultProps = {
className: '',
theme: 'light',
focusable: false
}; // We should keep this as ref-able
var Menu = /*#__PURE__*/function (_React$Component2) {
(0, _inherits2["default"])(Menu, _React$Component2);
var _super2 = (0, _createSuper2["default"])(Menu);
function Menu() {
(0, _classCallCheck2["default"])(this, Menu);
return _super2.apply(this, arguments);
}
(0, _createClass2["default"])(Menu, [{
key: "render",
value: function render() {
var _this2 = this;
return /*#__PURE__*/React.createElement(_Sider.SiderContext.Consumer, null, function (context) {
return /*#__PURE__*/React.createElement(InternalMenu, (0, _extends2["default"])({}, _this2.props, context));
});
}
}]);
return Menu;
}(React.Component);
exports["default"] = Menu;
Menu.Divider = _rcMenu.Divider;
Menu.Item = _MenuItem["default"];
Menu.SubMenu = _SubMenu["default"];
Menu.ItemGroup = _rcMenu.ItemGroup;