UNPKG

2.5 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
3import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
4import _inherits from 'babel-runtime/helpers/inherits';
5
6var _class, _temp;
7
8import React, { Component } from 'react';
9import PropTypes from 'prop-types';
10import classNames from 'classnames';
11import { polyfill } from 'react-lifecycles-compat';
12import ConfigProvider from '../config-provider';
13import { obj } from '../util';
14
15/**
16 * Divider
17 */
18var Divider = (_temp = _class = function (_Component) {
19 _inherits(Divider, _Component);
20
21 function Divider() {
22 _classCallCheck(this, Divider);
23
24 return _possibleConstructorReturn(this, _Component.apply(this, arguments));
25 }
26
27 Divider.prototype.render = function render() {
28 var _classNames;
29
30 var _props = this.props,
31 prefix = _props.prefix,
32 className = _props.className,
33 dashed = _props.dashed,
34 direction = _props.direction,
35 orientation = _props.orientation,
36 children = _props.children;
37
38 var others = obj.pickOthers(Divider.propTypes, this.props);
39
40 var cls = classNames((_classNames = {}, _classNames[prefix + 'divider'] = true, _classNames[prefix + 'divider-dashed'] = !!dashed, _classNames[prefix + 'divider-' + direction] = !!direction, _classNames[prefix + 'divider-with-text-' + orientation] = !!orientation && children, _classNames), className);
41
42 return React.createElement(
43 'div',
44 _extends({ role: 'separator', className: cls }, others),
45 children && React.createElement(
46 'span',
47 { className: prefix + 'divider-inner-text' },
48 children
49 )
50 );
51 };
52
53 return Divider;
54}(Component), _class.propTypes = {
55 prefix: PropTypes.string,
56 children: PropTypes.any,
57 className: PropTypes.string,
58 /**
59 * 是否为虚线
60 */
61 dashed: PropTypes.bool,
62 /**
63 * 线是水平还是垂直类型
64 */
65 direction: PropTypes.oneOf(['hoz', 'ver']),
66 /**
67 * 分割线标题的位置
68 */
69 orientation: PropTypes.oneOf(['left', 'right', 'center'])
70}, _class.defaultProps = {
71 prefix: 'next-',
72 direction: 'hoz',
73 orientation: 'center',
74 dashed: false
75}, _temp);
76Divider.displayName = 'Divider';
77
78
79export default ConfigProvider.config(polyfill(Divider));
\No newline at end of file