1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 |
|
7 | var _class, _temp;
|
8 |
|
9 | import React, { Component, Children, cloneElement } from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 | import cx from 'classnames';
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var Row = (_temp = _class = function (_Component) {
|
18 | _inherits(Row, _Component);
|
19 |
|
20 | function Row() {
|
21 | _classCallCheck(this, Row);
|
22 |
|
23 | return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
24 | }
|
25 |
|
26 | Row.prototype.render = function render() {
|
27 | var _extends2, _extends3;
|
28 |
|
29 |
|
30 | var _props = this.props,
|
31 | prefix = _props.prefix,
|
32 | pure = _props.pure,
|
33 | wrap = _props.wrap,
|
34 | fixed = _props.fixed,
|
35 | gutter = _props.gutter,
|
36 | fixedWidth = _props.fixedWidth,
|
37 | align = _props.align,
|
38 | justify = _props.justify,
|
39 | hidden = _props.hidden,
|
40 | className = _props.className,
|
41 | Tag = _props.component,
|
42 | children = _props.children,
|
43 | rtl = _props.rtl,
|
44 | others = _objectWithoutProperties(_props, ['prefix', 'pure', 'wrap', 'fixed', 'gutter', 'fixedWidth', 'align', 'justify', 'hidden', 'className', 'component', 'children', 'rtl']);
|
45 |
|
46 |
|
47 | var hiddenClassObj = void 0;
|
48 | if (hidden === true) {
|
49 | var _hiddenClassObj;
|
50 |
|
51 | hiddenClassObj = (_hiddenClassObj = {}, _hiddenClassObj[prefix + 'row-hidden'] = true, _hiddenClassObj);
|
52 | } else if (typeof hidden === 'string') {
|
53 | var _hiddenClassObj2;
|
54 |
|
55 | hiddenClassObj = (_hiddenClassObj2 = {}, _hiddenClassObj2[prefix + 'row-' + hidden + '-hidden'] = !!hidden, _hiddenClassObj2);
|
56 | } else if (Array.isArray(hidden)) {
|
57 | hiddenClassObj = hidden.reduce(function (ret, point) {
|
58 | ret[prefix + 'row-' + point + '-hidden'] = !!point;
|
59 | return ret;
|
60 | }, {});
|
61 | }
|
62 |
|
63 | var newClassName = cx(_extends((_extends2 = {}, _extends2[prefix + 'row'] = true, _extends2[prefix + 'row-wrap'] = wrap, _extends2[prefix + 'row-fixed'] = fixed, _extends2[prefix + 'row-fixed-' + fixedWidth] = !!fixedWidth, _extends2[prefix + 'row-justify-' + justify] = !!justify, _extends2[prefix + 'row-align-' + align] = !!align, _extends2), hiddenClassObj, (_extends3 = {}, _extends3[className] = !!className, _extends3)));
|
64 |
|
65 | var newChildren = children;
|
66 | var gutterNumber = parseInt(gutter, 10);
|
67 | if (gutterNumber !== 0) {
|
68 | var halfGutterString = gutterNumber / 2 + 'px';
|
69 | others.style = _extends({
|
70 | marginLeft: '-' + halfGutterString,
|
71 | marginRight: '-' + halfGutterString
|
72 | }, others.style || {});
|
73 | newChildren = Children.map(children, function (child) {
|
74 | if (child && child.type && typeof child.type === 'function' && child.type.isNextCol) {
|
75 | var newChild = cloneElement(child, {
|
76 | style: _extends({
|
77 | paddingLeft: halfGutterString,
|
78 | paddingRight: halfGutterString
|
79 | }, child.style || {})
|
80 | });
|
81 | return newChild;
|
82 | }
|
83 |
|
84 | return child;
|
85 | });
|
86 | }
|
87 |
|
88 | return React.createElement(
|
89 | Tag,
|
90 | _extends({
|
91 | dir: rtl ? 'rtl' : 'ltr',
|
92 | role: 'row',
|
93 | className: newClassName
|
94 | }, others),
|
95 | newChildren
|
96 | );
|
97 | };
|
98 |
|
99 | return Row;
|
100 | }(Component), _class.propTypes = {
|
101 | prefix: PropTypes.string,
|
102 | pure: PropTypes.bool,
|
103 | rtl: PropTypes.bool,
|
104 | className: PropTypes.string,
|
105 | style: PropTypes.object,
|
106 | |
107 |
|
108 |
|
109 | children: PropTypes.node,
|
110 | |
111 |
|
112 |
|
113 | gutter: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
114 | |
115 |
|
116 |
|
117 | wrap: PropTypes.bool,
|
118 | |
119 |
|
120 |
|
121 | fixed: PropTypes.bool,
|
122 | |
123 |
|
124 |
|
125 |
|
126 | fixedWidth: PropTypes.oneOf(['xxs', 'xs', 's', 'm', 'l', 'xl']),
|
127 | |
128 |
|
129 |
|
130 |
|
131 | align: PropTypes.oneOf(['top', 'center', 'bottom', 'baseline', 'stretch']),
|
132 | |
133 |
|
134 |
|
135 |
|
136 | justify: PropTypes.oneOf(['start', 'center', 'end', 'space-between', 'space-around']),
|
137 | |
138 |
|
139 |
|
140 | hidden: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.array]),
|
141 | |
142 |
|
143 |
|
144 |
|
145 | component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
|
146 | }, _class.defaultProps = {
|
147 | prefix: 'next-',
|
148 | pure: false,
|
149 | fixed: false,
|
150 | gutter: 0,
|
151 | wrap: false,
|
152 | component: 'div'
|
153 | }, _temp);
|
154 | Row.displayName = 'Row';
|
155 | export { Row as default }; |
\ | No newline at end of file |