1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
11 |
|
12 | var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
13 |
|
14 | var _Button = _interopRequireDefault(require("./Button"));
|
15 |
|
16 | var _Loader = _interopRequireDefault(require("./Loader"));
|
17 |
|
18 | var _withStyles = require("../helpers/withStyles");
|
19 |
|
20 | var _reactWithStyles = require("react-with-styles");
|
21 |
|
22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23 |
|
24 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
25 |
|
26 | 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; }
|
27 |
|
28 | 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; }
|
29 |
|
30 | 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; }
|
31 |
|
32 | 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; }
|
33 |
|
34 | var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
|
35 | mainOption: _propTypes.default.object,
|
36 | disabled: _propTypes.default.bool,
|
37 | loading: _propTypes.default.bool,
|
38 | options: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
39 | children: _propTypes.default.any,
|
40 | onClick: _propTypes.default.func,
|
41 | fullWidth: _propTypes.default.bool,
|
42 | block: _propTypes.default.bool,
|
43 | compact: _propTypes.default.bool,
|
44 | inverse: _propTypes.default.bool,
|
45 | mono: _propTypes.default.bool,
|
46 | noSpacing: _propTypes.default.bool,
|
47 | shimmer: _propTypes.default.bool,
|
48 | soft: _propTypes.default.bool,
|
49 | primary: _propTypes.default.bool,
|
50 | rectangular: _propTypes.default.bool,
|
51 | secondary: _propTypes.default.bool,
|
52 | short: _propTypes.default.bool,
|
53 | transparent: _propTypes.default.bool,
|
54 | closeOnSelect: _propTypes.default.bool
|
55 | });
|
56 |
|
57 | var defaultProps = {
|
58 | mainOption: {
|
59 | label: '',
|
60 | value: null
|
61 | },
|
62 | options: []
|
63 | };
|
64 |
|
65 | var ComboButton = function ComboButton(_ref) {
|
66 | var styles = _ref.styles,
|
67 | css = _ref.css,
|
68 | theme = _ref.theme,
|
69 | mainOption = _ref.mainOption,
|
70 | disabled = _ref.disabled,
|
71 | loading = _ref.loading,
|
72 | options = _ref.options,
|
73 | className = _ref.className,
|
74 | children = _ref.children,
|
75 | _onClick = _ref.onClick,
|
76 | fullWidth = _ref.fullWidth,
|
77 | block = _ref.block,
|
78 | compact = _ref.compact,
|
79 | inverse = _ref.inverse,
|
80 | mono = _ref.mono,
|
81 | noSpacing = _ref.noSpacing,
|
82 | shimmer = _ref.shimmer,
|
83 | soft = _ref.soft,
|
84 | primary = _ref.primary,
|
85 | rectangular = _ref.rectangular,
|
86 | secondary = _ref.secondary,
|
87 | transparent = _ref.transparent,
|
88 | closeOnSelect = _ref.closeOnSelect,
|
89 | props = _objectWithoutProperties(_ref, ["styles", "css", "theme", "mainOption", "disabled", "loading", "options", "className", "children", "onClick", "fullWidth", "block", "compact", "inverse", "mono", "noSpacing", "shimmer", "soft", "primary", "rectangular", "secondary", "transparent", "closeOnSelect"]);
|
90 |
|
91 | return _react.default.createElement("div", _extends({}, props, css(styles.comboButton, loading && styles.comboButton_loading, disabled && styles.comboButton_disabled, fullWidth && styles.comboButton_fullWidth, block && styles.comboButton_block, inverse && styles.comboButton_inverse, mono && styles.comboButton_mono, noSpacing && styles.comboButton_noSpacing, shimmer && styles.comboButton_soft, soft && styles.comboButton_soft, primary && styles.comboButton_primary, rectangular && styles.comboButton_rectangular, secondary && styles.comboButton_secondary, transparent && styles.comboButton_transparent)), _react.default.createElement("div", css(styles.comboButton__content, loading && styles.comboButton__content_loading, shimmer && styles.comboButton__content_shimmer, rectangular && styles.comboButton__content_rectangular), _react.default.createElement(_Button.default, {
|
92 | noSpacing: true,
|
93 | short: true,
|
94 | fullWidth: block || fullWidth,
|
95 | compact: compact,
|
96 | mono: mono,
|
97 | soft: soft,
|
98 | primary: primary,
|
99 | rectangular: rectangular,
|
100 | secondary: secondary,
|
101 | transparent: transparent,
|
102 | inverse: inverse,
|
103 | noBorder: mono || secondary || inverse,
|
104 | onClick: function onClick() {
|
105 | return _onClick && _onClick(mainOption.value);
|
106 | }
|
107 | }, mainOption.label), _react.default.createElement("div", css(styles.comboButton__separator, (inverse || transparent || soft) && styles.comboButton__separator_dark, mono && styles.comboButton__separator_mono, secondary && styles.comboButton__separator_secondary)), _react.default.createElement(_Dropdown.default, {
|
108 | combo: true,
|
109 | button: true,
|
110 | noSpacing: true,
|
111 | short: true,
|
112 | compact: true,
|
113 | mono: mono,
|
114 | soft: soft,
|
115 | primary: primary,
|
116 | rectangular: rectangular,
|
117 | secondary: secondary,
|
118 | transparent: transparent,
|
119 | inverse: inverse,
|
120 | noBorder: mono || secondary || inverse,
|
121 | onSelectOption: function onSelectOption(option) {
|
122 | return _onClick && _onClick(option.value);
|
123 | },
|
124 | options: options,
|
125 | closeOnSelect: closeOnSelect
|
126 | }, children)), loading && _react.default.createElement("div", css(styles.comboButton__loader, shimmer && styles.comboButton__loader_shimmer, rectangular && styles.comboButton__content_rectangular), !shimmer && _react.default.createElement(_Loader.default, {
|
127 | small: true,
|
128 | primary: inverse && soft,
|
129 | secondary: secondary,
|
130 | mono: mono
|
131 | })));
|
132 | };
|
133 |
|
134 | ComboButton.propTypes = propTypes;
|
135 | ComboButton.defaultProps = defaultProps;
|
136 | var ComboButtonWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
|
137 | var color = _ref2.color,
|
138 | units = _ref2.units,
|
139 | animation = _ref2.animation,
|
140 | radius = _ref2.radius;
|
141 | return {
|
142 | comboButton: {
|
143 | height: units(2.5),
|
144 | borderRadius: radius,
|
145 | display: 'inline-block',
|
146 | position: 'relative',
|
147 | backgroundColor: color.secondary,
|
148 | paddingTop: units(0.25),
|
149 | paddingRight: units(0.125),
|
150 | paddingBottom: units(0.25),
|
151 | paddingLeft: units(0.125),
|
152 | marginTop: 0,
|
153 | marginRight: units(0.125),
|
154 | marginBottom: units(0.5),
|
155 | marginLeft: units(0.125),
|
156 | boxSizing: 'border-box'
|
157 | },
|
158 | comboButton_loading: {
|
159 | opacity: 1
|
160 | },
|
161 | comboButton__content: {
|
162 | display: 'flex',
|
163 | alignItems: 'center',
|
164 | overflow: 'hidden',
|
165 | borderRadius: radius
|
166 | },
|
167 | comboButton__content_shimmer: {
|
168 | minWidth: units(6)
|
169 | },
|
170 | comboButton__content_loading: {
|
171 | opacity: 0
|
172 | },
|
173 | comboButton__content_rectangular: {
|
174 | borderRadius: 0
|
175 | },
|
176 | comboButton__separator: {
|
177 | width: 1,
|
178 | height: units(1.5),
|
179 | marginRight: units(0.125),
|
180 | marginLeft: units(0.125),
|
181 | backgroundColor: color.fogStrong
|
182 | },
|
183 | comboButton__separator_dark: {
|
184 | backgroundColor: color.shadow
|
185 | },
|
186 | comboButton__separator_mono: {
|
187 | backgroundColor: color.black
|
188 | },
|
189 | comboButton__separator_secondary: {
|
190 | backgroundColor: color.secondary
|
191 | },
|
192 | comboButton__loader: {
|
193 | position: 'absolute',
|
194 | top: 0,
|
195 | right: 0,
|
196 | bottom: 0,
|
197 | left: 0,
|
198 | display: 'flex',
|
199 | alignItems: 'center',
|
200 | justifyContent: 'center',
|
201 | borderRadius: radius
|
202 | },
|
203 | comboButton__loader_shimmer: {
|
204 | backgroundColor: color.shimmer.from,
|
205 | animationDirection: 'alternate',
|
206 | animationDuration: '1s',
|
207 | animationFillMode: 'forwards',
|
208 | animationIterationCount: 'infinite',
|
209 | animationName: animation.shimmer,
|
210 | animationTimingFunction: 'ease-in-out'
|
211 | },
|
212 | comboButton_disabled: {
|
213 | opacity: .5,
|
214 | pointerEvents: 'none'
|
215 | },
|
216 | comboButton_soft: {
|
217 | backgroundColor: color.blueGrayLighter
|
218 | },
|
219 | comboButton_fullWidth: {
|
220 | width: '100%'
|
221 | },
|
222 | comboButton_block: {
|
223 | width: '100%',
|
224 | textAlign: 'left',
|
225 | marginRight: 0,
|
226 | marginLeft: 0
|
227 | },
|
228 | comboButton_inverse: {
|
229 | backgroundColor: color.white
|
230 | },
|
231 | comboButton_mono: {
|
232 | backgroundColor: color.transparent,
|
233 | borderColor: color.black,
|
234 | borderWidth: 1,
|
235 | borderStyle: 'solid'
|
236 | },
|
237 | comboButton_noSpacing: {
|
238 | marginBottom: 0
|
239 | },
|
240 | comboButton_primary: {
|
241 | backgroundColor: color.primary
|
242 | },
|
243 | comboButton_secondary: {
|
244 | backgroundColor: color.transparent,
|
245 | borderColor: color.secondary,
|
246 | borderWidth: 1,
|
247 | borderStyle: 'solid'
|
248 | },
|
249 | comboButton_transparent: {
|
250 | backgroundColor: color.transparent
|
251 | },
|
252 | comboButton_rectangular: {
|
253 | borderRadius: 0
|
254 | }
|
255 | };
|
256 | })(ComboButton);
|
257 | var _default = ComboButtonWithStyles;
|
258 | exports.default = _default; |
\ | No newline at end of file |