1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
4 | import _inherits from 'babel-runtime/helpers/inherits';
|
5 |
|
6 | var _class, _temp;
|
7 |
|
8 | import React, { Component } from 'react';
|
9 | import PropTypes from 'prop-types';
|
10 | import cx from 'classnames';
|
11 | import ConfigProvider from '../config-provider';
|
12 | import createFromIconfontCN from './icon-font';
|
13 | import { obj } from '../util';
|
14 |
|
15 |
|
16 |
|
17 | var Icon = (_temp = _class = function (_Component) {
|
18 | _inherits(Icon, _Component);
|
19 |
|
20 | function Icon() {
|
21 | _classCallCheck(this, Icon);
|
22 |
|
23 | return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
24 | }
|
25 |
|
26 | Icon.prototype.render = function render() {
|
27 | var _cx;
|
28 |
|
29 |
|
30 | var _props = this.props,
|
31 | prefix = _props.prefix,
|
32 | type = _props.type,
|
33 | size = _props.size,
|
34 | className = _props.className,
|
35 | rtl = _props.rtl,
|
36 | style = _props.style,
|
37 | children = _props.children;
|
38 |
|
39 | var others = obj.pickOthers(_extends({}, Icon.propTypes), this.props);
|
40 |
|
41 | var classes = cx((_cx = {}, _cx[prefix + 'icon'] = true, _cx[prefix + 'icon-' + type] = !!type, _cx['' + prefix + size] = !!size && typeof size === 'string', _cx[className] = !!className, _cx));
|
42 |
|
43 | if (rtl && ['arrow-left', 'arrow-right', 'arrow-double-left', 'arrow-double-right', 'switch', 'sorting', 'descending', 'ascending'].indexOf(type) !== -1) {
|
44 | others.dir = 'rtl';
|
45 | }
|
46 |
|
47 | var sizeStyle = typeof size === 'number' ? {
|
48 | width: size,
|
49 | height: size,
|
50 | lineHeight: size + 'px',
|
51 | fontSize: size
|
52 | } : {};
|
53 |
|
54 | return React.createElement(
|
55 | 'i',
|
56 | _extends({}, others, {
|
57 | style: _extends({}, sizeStyle, style),
|
58 | className: classes
|
59 | }),
|
60 | children
|
61 | );
|
62 | };
|
63 |
|
64 | return Icon;
|
65 | }(Component), _class.propTypes = _extends({}, ConfigProvider.propTypes, {
|
66 | |
67 |
|
68 |
|
69 | type: PropTypes.string,
|
70 | children: PropTypes.node,
|
71 | |
72 |
|
73 |
|
74 |
|
75 | size: PropTypes.oneOfType([PropTypes.oneOf(['xxs', 'xs', 'small', 'medium', 'large', 'xl', 'xxl', 'xxxl', 'inherit']), PropTypes.number]),
|
76 | className: PropTypes.string,
|
77 | style: PropTypes.object
|
78 | }), _class.defaultProps = {
|
79 | prefix: 'next-',
|
80 | size: 'medium'
|
81 | }, _class._typeMark = 'icon', _temp);
|
82 | Icon.displayName = 'Icon';
|
83 |
|
84 |
|
85 | Icon.createFromIconfontCN = createFromIconfontCN;
|
86 | export default ConfigProvider.config(Icon); |
\ | No newline at end of file |