1 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
4 | import classNames from 'classnames';
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import elementType from 'prop-types-extra/lib/elementType';
|
8 | import { bsClass, prefix, splitBsProps } from './utils/bootstrapUtils';
|
9 | import { DEVICE_SIZES } from './utils/StyleConfig';
|
10 | var propTypes = {
|
11 | componentClass: elementType,
|
12 |
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | xs: PropTypes.number,
|
21 |
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | sm: PropTypes.number,
|
30 |
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | md: PropTypes.number,
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | lg: PropTypes.number,
|
48 |
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | xsHidden: PropTypes.bool,
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | smHidden: PropTypes.bool,
|
66 |
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | mdHidden: PropTypes.bool,
|
75 |
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | lgHidden: PropTypes.bool,
|
84 |
|
85 | |
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | xsOffset: PropTypes.number,
|
93 |
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | smOffset: PropTypes.number,
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | mdOffset: PropTypes.number,
|
111 |
|
112 | |
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | lgOffset: PropTypes.number,
|
120 |
|
121 | |
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 | xsPush: PropTypes.number,
|
129 |
|
130 | |
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | smPush: PropTypes.number,
|
138 |
|
139 | |
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | mdPush: PropTypes.number,
|
147 |
|
148 | |
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | lgPush: PropTypes.number,
|
156 |
|
157 | |
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | xsPull: PropTypes.number,
|
165 |
|
166 | |
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | smPull: PropTypes.number,
|
174 |
|
175 | |
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 | mdPull: PropTypes.number,
|
183 |
|
184 | |
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 | lgPull: PropTypes.number
|
192 | };
|
193 | var defaultProps = {
|
194 | componentClass: 'div'
|
195 | };
|
196 |
|
197 | var Col =
|
198 |
|
199 | function (_React$Component) {
|
200 | _inheritsLoose(Col, _React$Component);
|
201 |
|
202 | function Col() {
|
203 | return _React$Component.apply(this, arguments) || this;
|
204 | }
|
205 |
|
206 | var _proto = Col.prototype;
|
207 |
|
208 | _proto.render = function render() {
|
209 | var _this$props = this.props,
|
210 | Component = _this$props.componentClass,
|
211 | className = _this$props.className,
|
212 | props = _objectWithoutPropertiesLoose(_this$props, ["componentClass", "className"]);
|
213 |
|
214 | var _splitBsProps = splitBsProps(props),
|
215 | bsProps = _splitBsProps[0],
|
216 | elementProps = _splitBsProps[1];
|
217 |
|
218 | var classes = [];
|
219 | DEVICE_SIZES.forEach(function (size) {
|
220 | function popProp(propSuffix, modifier) {
|
221 | var propName = "" + size + propSuffix;
|
222 | var propValue = elementProps[propName];
|
223 |
|
224 | if (propValue != null) {
|
225 | classes.push(prefix(bsProps, "" + size + modifier + "-" + propValue));
|
226 | }
|
227 |
|
228 | delete elementProps[propName];
|
229 | }
|
230 |
|
231 | popProp('', '');
|
232 | popProp('Offset', '-offset');
|
233 | popProp('Push', '-push');
|
234 | popProp('Pull', '-pull');
|
235 | var hiddenPropName = size + "Hidden";
|
236 |
|
237 | if (elementProps[hiddenPropName]) {
|
238 | classes.push("hidden-" + size);
|
239 | }
|
240 |
|
241 | delete elementProps[hiddenPropName];
|
242 | });
|
243 | return React.createElement(Component, _extends({}, elementProps, {
|
244 | className: classNames(className, classes)
|
245 | }));
|
246 | };
|
247 |
|
248 | return Col;
|
249 | }(React.Component);
|
250 |
|
251 | Col.propTypes = propTypes;
|
252 | Col.defaultProps = defaultProps;
|
253 | export default bsClass('col', Col); |
\ | No newline at end of file |