UNPKG

6.04 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5exports.__esModule = true;
6exports.default = void 0;
7
8var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/extends"));
9
10var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectWithoutPropertiesLoose"));
11
12var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inheritsLoose"));
13
14var _classnames = _interopRequireDefault(require("classnames"));
15
16var _react = _interopRequireDefault(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _elementType = _interopRequireDefault(require("prop-types-extra/lib/elementType"));
21
22var _bootstrapUtils = require("./utils/bootstrapUtils");
23
24var _StyleConfig = require("./utils/StyleConfig");
25
26var propTypes = {
27 componentClass: _elementType.default,
28
29 /**
30 * The number of columns you wish to span
31 *
32 * for Extra small devices Phones (<768px)
33 *
34 * class-prefix `col-xs-`
35 */
36 xs: _propTypes.default.number,
37
38 /**
39 * The number of columns you wish to span
40 *
41 * for Small devices Tablets (≥768px)
42 *
43 * class-prefix `col-sm-`
44 */
45 sm: _propTypes.default.number,
46
47 /**
48 * The number of columns you wish to span
49 *
50 * for Medium devices Desktops (≥992px)
51 *
52 * class-prefix `col-md-`
53 */
54 md: _propTypes.default.number,
55
56 /**
57 * The number of columns you wish to span
58 *
59 * for Large devices Desktops (≥1200px)
60 *
61 * class-prefix `col-lg-`
62 */
63 lg: _propTypes.default.number,
64
65 /**
66 * Hide column
67 *
68 * on Extra small devices Phones
69 *
70 * adds class `hidden-xs`
71 */
72 xsHidden: _propTypes.default.bool,
73
74 /**
75 * Hide column
76 *
77 * on Small devices Tablets
78 *
79 * adds class `hidden-sm`
80 */
81 smHidden: _propTypes.default.bool,
82
83 /**
84 * Hide column
85 *
86 * on Medium devices Desktops
87 *
88 * adds class `hidden-md`
89 */
90 mdHidden: _propTypes.default.bool,
91
92 /**
93 * Hide column
94 *
95 * on Large devices Desktops
96 *
97 * adds class `hidden-lg`
98 */
99 lgHidden: _propTypes.default.bool,
100
101 /**
102 * Move columns to the right
103 *
104 * for Extra small devices Phones
105 *
106 * class-prefix `col-xs-offset-`
107 */
108 xsOffset: _propTypes.default.number,
109
110 /**
111 * Move columns to the right
112 *
113 * for Small devices Tablets
114 *
115 * class-prefix `col-sm-offset-`
116 */
117 smOffset: _propTypes.default.number,
118
119 /**
120 * Move columns to the right
121 *
122 * for Medium devices Desktops
123 *
124 * class-prefix `col-md-offset-`
125 */
126 mdOffset: _propTypes.default.number,
127
128 /**
129 * Move columns to the right
130 *
131 * for Large devices Desktops
132 *
133 * class-prefix `col-lg-offset-`
134 */
135 lgOffset: _propTypes.default.number,
136
137 /**
138 * Change the order of grid columns to the right
139 *
140 * for Extra small devices Phones
141 *
142 * class-prefix `col-xs-push-`
143 */
144 xsPush: _propTypes.default.number,
145
146 /**
147 * Change the order of grid columns to the right
148 *
149 * for Small devices Tablets
150 *
151 * class-prefix `col-sm-push-`
152 */
153 smPush: _propTypes.default.number,
154
155 /**
156 * Change the order of grid columns to the right
157 *
158 * for Medium devices Desktops
159 *
160 * class-prefix `col-md-push-`
161 */
162 mdPush: _propTypes.default.number,
163
164 /**
165 * Change the order of grid columns to the right
166 *
167 * for Large devices Desktops
168 *
169 * class-prefix `col-lg-push-`
170 */
171 lgPush: _propTypes.default.number,
172
173 /**
174 * Change the order of grid columns to the left
175 *
176 * for Extra small devices Phones
177 *
178 * class-prefix `col-xs-pull-`
179 */
180 xsPull: _propTypes.default.number,
181
182 /**
183 * Change the order of grid columns to the left
184 *
185 * for Small devices Tablets
186 *
187 * class-prefix `col-sm-pull-`
188 */
189 smPull: _propTypes.default.number,
190
191 /**
192 * Change the order of grid columns to the left
193 *
194 * for Medium devices Desktops
195 *
196 * class-prefix `col-md-pull-`
197 */
198 mdPull: _propTypes.default.number,
199
200 /**
201 * Change the order of grid columns to the left
202 *
203 * for Large devices Desktops
204 *
205 * class-prefix `col-lg-pull-`
206 */
207 lgPull: _propTypes.default.number
208};
209var defaultProps = {
210 componentClass: 'div'
211};
212
213var Col =
214/*#__PURE__*/
215function (_React$Component) {
216 (0, _inheritsLoose2.default)(Col, _React$Component);
217
218 function Col() {
219 return _React$Component.apply(this, arguments) || this;
220 }
221
222 var _proto = Col.prototype;
223
224 _proto.render = function render() {
225 var _this$props = this.props,
226 Component = _this$props.componentClass,
227 className = _this$props.className,
228 props = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["componentClass", "className"]);
229
230 var _splitBsProps = (0, _bootstrapUtils.splitBsProps)(props),
231 bsProps = _splitBsProps[0],
232 elementProps = _splitBsProps[1];
233
234 var classes = [];
235
236 _StyleConfig.DEVICE_SIZES.forEach(function (size) {
237 function popProp(propSuffix, modifier) {
238 var propName = "" + size + propSuffix;
239 var propValue = elementProps[propName];
240
241 if (propValue != null) {
242 classes.push((0, _bootstrapUtils.prefix)(bsProps, "" + size + modifier + "-" + propValue));
243 }
244
245 delete elementProps[propName];
246 }
247
248 popProp('', '');
249 popProp('Offset', '-offset');
250 popProp('Push', '-push');
251 popProp('Pull', '-pull');
252 var hiddenPropName = size + "Hidden";
253
254 if (elementProps[hiddenPropName]) {
255 classes.push("hidden-" + size);
256 }
257
258 delete elementProps[hiddenPropName];
259 });
260
261 return _react.default.createElement(Component, (0, _extends2.default)({}, elementProps, {
262 className: (0, _classnames.default)(className, classes)
263 }));
264 };
265
266 return Col;
267}(_react.default.Component);
268
269Col.propTypes = propTypes;
270Col.defaultProps = defaultProps;
271
272var _default = (0, _bootstrapUtils.bsClass)('col', Col);
273
274exports.default = _default;
275module.exports = exports["default"];
\No newline at end of file