UNPKG

2.3 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6
7var _class, _temp;
8
9import React, { Component } from 'react';
10import PropTypes from 'prop-types';
11import classNames from 'classnames';
12import Menu from '../menu';
13
14/**
15 * Nav.Group
16 * @description 继承自 `Menu.Group` 的能力请查看 `Menu.Group` 文档
17 */
18var Group = (_temp = _class = function (_Component) {
19 _inherits(Group, _Component);
20
21 function Group() {
22 _classCallCheck(this, Group);
23
24 return _possibleConstructorReturn(this, _Component.apply(this, arguments));
25 }
26
27 Group.prototype.render = function render() {
28 var _classNames;
29
30 var _context = this.context,
31 prefix = _context.prefix,
32 iconOnly = _context.iconOnly;
33
34 var _props = this.props,
35 className = _props.className,
36 children = _props.children,
37 label = _props.label,
38 others = _objectWithoutProperties(_props, ['className', 'children', 'label']);
39
40 var newLabel = label;
41 if (iconOnly) {
42 // TODO: add a group icon ?
43 newLabel = [React.createElement(
44 'span',
45 { key: 'label' },
46 label
47 )];
48 }
49
50 var cls = classNames((_classNames = {}, _classNames[prefix + 'nav-group-label'] = true, _classNames[className] = !!className, _classNames));
51
52 return React.createElement(
53 Menu.Group,
54 _extends({ className: cls, label: newLabel }, others),
55 children
56 );
57 };
58
59 return Group;
60}(Component), _class.menuChildType = 'group', _class.propTypes = {
61 /**
62 * 自定义类名
63 */
64 className: PropTypes.string,
65 /**
66 * 标签内容
67 */
68 label: PropTypes.node,
69 /**
70 * 导航项和子导航
71 */
72 children: PropTypes.node
73}, _class.contextTypes = {
74 prefix: PropTypes.string,
75 iconOnly: PropTypes.bool
76}, _temp);
77Group.displayName = 'Group';
78
79
80export default Group;
\No newline at end of file