UNPKG

5.23 kBJavaScriptView Raw
1import _defineProperty from 'babel-runtime/helpers/defineProperty';
2import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
3import _createClass from 'babel-runtime/helpers/createClass';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classnames from 'classnames';
7import React from 'react';
8import Icon from '../icon';
9var LeftArea = function LeftArea(props) {
10 var children = props.children,
11 style = props.style,
12 className = props.className;
13
14 var a_children = React.Children.toArray(children);
15 var c_children = a_children.slice(a_children.length - 2);
16 return React.createElement(
17 'a',
18 { className: classnames('bs-pull-left bs-bar-nav-btn', className), style: style },
19 c_children
20 );
21};
22var RightArea = function RightArea(props) {
23 var children = props.children,
24 style = props.style,
25 className = props.className;
26
27 var a_children = React.Children.toArray(children);
28 // console.log(a_children)
29 var c_children = a_children.slice(a_children.length - 2);
30 return React.createElement(
31 'a',
32 { className: classnames('bs-pull-right bs-bar-nav-btn', className), style: style },
33 c_children
34 );
35};
36export var TitleArea = function (_React$Component) {
37 _inherits(TitleArea, _React$Component);
38
39 function TitleArea() {
40 _classCallCheck(this, TitleArea);
41
42 var _this = _possibleConstructorReturn(this, (TitleArea.__proto__ || Object.getPrototypeOf(TitleArea)).apply(this, arguments));
43
44 _this.handleItemClick = function (e) {
45 e.preventDefault();
46 _this.props.onClick && _this.props.onClick(_this.props, e);
47 };
48 return _this;
49 }
50
51 _createClass(TitleArea, [{
52 key: 'render',
53 value: function render() {
54 var _props = this.props,
55 children = _props.children,
56 style = _props.style,
57 className = _props.className;
58
59 return React.createElement(
60 'div',
61 { className: classnames('bs-bar-title', className), onClick: this.handleItemClick, style: style },
62 children
63 );
64 }
65 }]);
66
67 return TitleArea;
68}(React.Component);
69export var Item = function (_React$Component2) {
70 _inherits(Item, _React$Component2);
71
72 function Item() {
73 _classCallCheck(this, Item);
74
75 var _this2 = _possibleConstructorReturn(this, (Item.__proto__ || Object.getPrototypeOf(Item)).apply(this, arguments));
76
77 _this2.handleItemClick = function (e) {
78 e.preventDefault();
79 _this2.props.onClick && _this2.props.onClick(_this2.props, e);
80 };
81 return _this2;
82 }
83
84 _createClass(Item, [{
85 key: 'render',
86 value: function render() {
87 var _props2 = this.props,
88 prefixCls = _props2.prefixCls,
89 style = _props2.style,
90 icon = _props2.icon,
91 iconStyle = _props2.iconStyle,
92 text = _props2.text;
93
94 return React.createElement(
95 'a',
96 { className: prefixCls, style: style, onClick: this.handleItemClick },
97 Icon && React.createElement(Icon, { type: icon, style: iconStyle }),
98 React.createElement(
99 'span',
100 { className: 'bs-bar-item-label' },
101 text
102 )
103 );
104 }
105 }]);
106
107 return Item;
108}(React.Component);
109Item.defaultProps = {
110 prefixCls: 'bs-bar-item'
111};
112
113var Header = function (_React$Component3) {
114 _inherits(Header, _React$Component3);
115
116 function Header() {
117 _classCallCheck(this, Header);
118
119 var _this3 = _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments));
120
121 _this3.onHandleTitleClick = function (e) {
122 e.preventDefault();
123 console.log(_this3.props.title);
124 _this3.props.onTitleClick && _this3.props.onTitleClick({
125 text: _this3.props.title
126 }, e);
127 };
128 return _this3;
129 }
130
131 _createClass(Header, [{
132 key: 'render',
133 value: function render() {
134 var _props3 = this.props,
135 className = _props3.className,
136 style = _props3.style,
137 fixStatus = _props3.fixStatus,
138 title = _props3.title,
139 _props3$prefixCls = _props3.prefixCls,
140 prefixCls = _props3$prefixCls === undefined ? 'bs-bar' : _props3$prefixCls;
141
142 return React.createElement(
143 'div',
144 { onClick: this.onHandleTitleClick, className: classnames(prefixCls + ' ' + prefixCls + '-nav', _defineProperty({}, prefixCls + '-nav-fixstatus', fixStatus), className), style: style },
145 title ? title : this.props.children
146 );
147 }
148 }]);
149
150 return Header;
151}(React.Component);
152
153export default Header;
154
155Header.Item = Item;
156Header.LeftArea = LeftArea;
157Header.TitleArea = TitleArea;
158Header.RightArea = RightArea;
\No newline at end of file