1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireWildcard(require("react"));
|
9 |
|
10 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
11 |
|
12 | var _withStyles = require("../helpers/withStyles");
|
13 |
|
14 | var _reactWithStyles = require("react-with-styles");
|
15 |
|
16 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17 |
|
18 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
19 |
|
20 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
21 |
|
22 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
23 |
|
24 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
25 |
|
26 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
27 |
|
28 | var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
|
29 | disabled: _propTypes.default.bool,
|
30 | loading: _propTypes.default.bool,
|
31 | fullWidth: _propTypes.default.bool,
|
32 | block: _propTypes.default.bool,
|
33 | compact: _propTypes.default.bool,
|
34 | inverse: _propTypes.default.bool,
|
35 | mono: _propTypes.default.bool,
|
36 | noSpacing: _propTypes.default.bool,
|
37 | soft: _propTypes.default.bool,
|
38 | primary: _propTypes.default.bool,
|
39 | rectangular: _propTypes.default.bool,
|
40 | secondary: _propTypes.default.bool,
|
41 | shade: _propTypes.default.bool,
|
42 | shimmer: _propTypes.default.bool,
|
43 | short: _propTypes.default.bool,
|
44 | transparent: _propTypes.default.bool,
|
45 | type: _propTypes.default.string,
|
46 | noBorder: _propTypes.default.bool,
|
47 | children: _propTypes.default.node
|
48 | });
|
49 |
|
50 | var defaultProps = {
|
51 | type: 'button'
|
52 | };
|
53 |
|
54 | var ButtonGroup = function ButtonGroup(_ref) {
|
55 | var styles = _ref.styles,
|
56 | children = _ref.children,
|
57 | disabled = _ref.disabled,
|
58 | loading = _ref.loading,
|
59 | fullWidth = _ref.fullWidth,
|
60 | block = _ref.block,
|
61 | compact = _ref.compact,
|
62 | inverse = _ref.inverse,
|
63 | grouped = _ref.grouped,
|
64 | groupedFirst = _ref.groupedFirst,
|
65 | groupedLast = _ref.groupedLast,
|
66 | mono = _ref.mono,
|
67 | noSpacing = _ref.noSpacing,
|
68 | shade = _ref.shade,
|
69 | soft = _ref.soft,
|
70 | primary = _ref.primary,
|
71 | rectangular = _ref.rectangular,
|
72 | secondary = _ref.secondary,
|
73 | shimmer = _ref.shimmer,
|
74 | short = _ref.short,
|
75 | transparent = _ref.transparent,
|
76 | type = _ref.type,
|
77 | underlined = _ref.underlined,
|
78 | noBorder = _ref.noBorder,
|
79 | theme = _ref.theme,
|
80 | css = _ref.css,
|
81 | href = _ref.href,
|
82 | large = _ref.large,
|
83 | noWrap = _ref.noWrap,
|
84 | shadowLevel = _ref.shadowLevel,
|
85 | small = _ref.small,
|
86 | props = _objectWithoutProperties(_ref, ["styles", "children", "disabled", "loading", "fullWidth", "block", "compact", "inverse", "grouped", "groupedFirst", "groupedLast", "mono", "noSpacing", "shade", "soft", "primary", "rectangular", "secondary", "shimmer", "short", "transparent", "type", "underlined", "noBorder", "theme", "css", "href", "large", "noWrap", "shadowLevel", "small"]);
|
87 |
|
88 | return _react.default.createElement("div", css(styles.buttonGroup, loading && styles.button_loading, fullWidth && styles.button_fullWidth, block && styles.button_block, grouped && styles.button_grouped, groupedFirst && styles.button_groupedFirst, groupedLast && styles.button_groupedLast, noSpacing && styles.button_noSpacing), _react.Children.map(children, function (child, i) {
|
89 | var button = _react.default.cloneElement(child, {
|
90 | compact: compact,
|
91 | disabled: disabled,
|
92 | inverse: inverse,
|
93 | rectangular: rectangular || i > 0 && i < children.length - 1,
|
94 | grouped: true,
|
95 | groupedFirst: i === 0,
|
96 | groupedLast: i === children.length - 1,
|
97 | fullWidth: fullWidth,
|
98 | mono: mono,
|
99 | primary: primary,
|
100 | secondary: secondary,
|
101 | shade: shade,
|
102 | short: short,
|
103 | soft: soft,
|
104 | transparent: transparent,
|
105 | underlined: underlined
|
106 | });
|
107 |
|
108 | return fullWidth ? _react.default.createElement("div", css(styles.buttonContainer), button) : button;
|
109 | }));
|
110 | };
|
111 |
|
112 | ButtonGroup.propTypes = propTypes;
|
113 | ButtonGroup.defaultProps = defaultProps;
|
114 | var ButtonGroupWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
|
115 | var color = _ref2.color,
|
116 | units = _ref2.units,
|
117 | font = _ref2.font,
|
118 | animation = _ref2.animation,
|
119 | radius = _ref2.radius;
|
120 | return {
|
121 | buttonGroup: {
|
122 | marginBottom: units(0.5),
|
123 | boxSizing: 'border-box',
|
124 | display: 'flex'
|
125 | },
|
126 | button_soft: {
|
127 | backgroundColor: color.blueGrayLighter,
|
128 | color: color.primary,
|
129 | ':hover': {
|
130 | backgroundColor: color.blueGrayLight
|
131 | },
|
132 | ':active': {
|
133 | backgroundColor: color.blueGray
|
134 | }
|
135 | },
|
136 | button_fullWidth: {
|
137 | width: '100%'
|
138 | },
|
139 | button_loading: {
|
140 | opacity: 1,
|
141 | pointerEvents: 'none'
|
142 | },
|
143 | button_block: {
|
144 | width: '100%',
|
145 | textAlign: 'left',
|
146 | marginRight: 0,
|
147 | marginLeft: 0
|
148 | },
|
149 | button_compact: {
|
150 | paddingRight: units(0.75),
|
151 | paddingLeft: units(0.75)
|
152 | },
|
153 | button_shade: {
|
154 | background: color.shadowWeakest,
|
155 | ':hover': {
|
156 | background: color.shadowWeaker
|
157 | },
|
158 | ':active': {
|
159 | background: color.shadowWeak
|
160 | }
|
161 | },
|
162 | button_short: {
|
163 | height: units(2)
|
164 | },
|
165 | button_grouped: {
|
166 | marginRight: 1,
|
167 | marginBottom: 0,
|
168 | marginLeft: 1
|
169 | },
|
170 | button_groupedFirst: {
|
171 | borderRadius: "0 0 ".concat(radius, "px ").concat(radius, "px")
|
172 | },
|
173 | button_disabled: {
|
174 | opacity: .5,
|
175 | pointerEvents: 'none'
|
176 | },
|
177 | button_mono: {
|
178 | backgroundColor: color.transparent,
|
179 | borderColor: color.black,
|
180 | borderWidth: 1,
|
181 | borderStyle: 'solid',
|
182 | color: color.black,
|
183 | ':hover': {
|
184 | background: 'none'
|
185 | },
|
186 | ':active': {
|
187 | backgroundColor: color.grayLighter
|
188 | }
|
189 | },
|
190 | button_noSpacing: {
|
191 | marginBottom: 0
|
192 | },
|
193 | button_primary: {
|
194 | backgroundColor: color.primary,
|
195 | ':hover': {
|
196 | background: color.primarySaturated
|
197 | },
|
198 | ':active': {
|
199 | background: color.primaryDarker
|
200 | }
|
201 | },
|
202 | button_secondary: {
|
203 | backgroundColor: color.transparent,
|
204 | borderColor: color.secondary,
|
205 | borderWidth: 1,
|
206 | borderStyle: 'solid',
|
207 | color: color.secondary,
|
208 | ':hover': {
|
209 | color: color.secondarySaturated,
|
210 | backgroundColor: color.grayLightest
|
211 | },
|
212 | ':active': {
|
213 | borderColor: color.secondaryDarker,
|
214 | backgroundColor: color.grayLighter
|
215 | }
|
216 | },
|
217 | button_inverse: {
|
218 | backgroundColor: color.white,
|
219 | color: color.primary,
|
220 | borderWidth: 0,
|
221 | ':hover': {
|
222 | backgroundColor: color.blueGrayLight
|
223 | },
|
224 | ':active': {
|
225 | backgroundColor: color.blueGray
|
226 | }
|
227 | },
|
228 | button_transparent: {
|
229 | backgroundColor: color.transparent,
|
230 | color: color.primary,
|
231 | ':hover': {
|
232 | background: color.shadowWeakest
|
233 | },
|
234 | ':active': {
|
235 | background: color.shadowWeaker
|
236 | }
|
237 | },
|
238 | button_rectangular: {
|
239 | borderRadius: 0
|
240 | },
|
241 | button_noBorder: {
|
242 | border: 'none',
|
243 | borderWidth: 0
|
244 | },
|
245 | button__content: {
|
246 | display: 'flex',
|
247 | alignItems: 'center',
|
248 | justifyContent: 'flex-start',
|
249 | opacity: 1,
|
250 | transition: 'opacity .2s',
|
251 | whiteSpace: 'nowrap',
|
252 | userSelect: 'none'
|
253 | },
|
254 | button__content_loading: {
|
255 | opacity: 0
|
256 | },
|
257 | button__content_fullWidth: {
|
258 | justifyContent: 'center'
|
259 | },
|
260 | button__loader: {
|
261 | position: 'absolute',
|
262 | top: 0,
|
263 | right: 0,
|
264 | bottom: 0,
|
265 | left: 0,
|
266 | display: 'flex',
|
267 | alignItems: 'center',
|
268 | justifyContent: 'center'
|
269 | },
|
270 | buttonContainer: {
|
271 | flex: 1
|
272 | },
|
273 | shimmer: {
|
274 | position: 'absolute',
|
275 | width: '100%',
|
276 | height: '100%',
|
277 | top: 0,
|
278 | right: 0,
|
279 | bottom: 0,
|
280 | left: 0
|
281 | }
|
282 | };
|
283 | })(ButtonGroup);
|
284 | var _default = ButtonGroupWithStyles;
|
285 | exports.default = _default; |
\ | No newline at end of file |