UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

87 lines (84 loc) 3.04 kB
import * as React from "react"; import styled from "styled-components"; import Button from "../../Button"; import Minus from "../../icons/Minus"; import Plus from "../../icons/Plus"; import defaultTheme from "../../defaultTheme"; var StyledStepper = styled.div.withConfig({ displayName: "StepperStateless__StyledStepper", componentId: "dh3icj-0" })(["display:flex;width:100%;flex:1 1 auto;"]); var StyledStepperInput = styled.input.withConfig({ displayName: "StepperStateless__StyledStepperInput", componentId: "dh3icj-1" })(["width:100%;height:32px;padding:0;border:0;font-size:", ";font-weight:", ";color:", ";text-align:center;min-width:0;&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}&:focus{outline:none;}"], function (_ref) { var theme = _ref.theme; return theme.orbit.fontSizeInputNormal; }, function (_ref2) { var theme = _ref2.theme; return theme.orbit.fontWeightBold; }, function (_ref3) { var theme = _ref3.theme; return theme.orbit.paletteInkNormal; }); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledStepperInput.defaultProps = { theme: defaultTheme }; var StepperStateless = function StepperStateless(_ref4) { var disabled = _ref4.disabled, dataTest = _ref4.dataTest, value = _ref4.value, name = _ref4.name, minValue = _ref4.minValue, maxValue = _ref4.maxValue, _onKeyDown = _ref4.onKeyDown, onBlur = _ref4.onBlur, onFocus = _ref4.onFocus, onIncrement = _ref4.onIncrement, onDecrement = _ref4.onDecrement, titleIncrement = _ref4.titleIncrement, titleDecrement = _ref4.titleDecrement, disabledIncrement = _ref4.disabledIncrement, disabledDecrement = _ref4.disabledDecrement; return /*#__PURE__*/React.createElement(StyledStepper, { "data-test": dataTest }, /*#__PURE__*/React.createElement(Button, { disabled: disabled || disabledDecrement || typeof value === "number" && value <= +minValue, iconLeft: /*#__PURE__*/React.createElement(Minus, null), type: "secondary", size: "small", onClick: function onClick(ev) { if (onDecrement && !disabled) { onDecrement(ev); } }, title: titleDecrement }), /*#__PURE__*/React.createElement(StyledStepperInput, { name: name, disabled: disabled, type: "text", value: value || 0, min: minValue, max: maxValue, onKeyDown: function onKeyDown(ev) { if (_onKeyDown) { _onKeyDown(ev); } }, onBlur: onBlur, onFocus: onFocus, readOnly: true }), /*#__PURE__*/React.createElement(Button, { disabled: disabled || disabledIncrement || typeof value === "number" && value >= +maxValue, iconLeft: /*#__PURE__*/React.createElement(Plus, null), type: "secondary", size: "small", onClick: function onClick(ev) { if (onIncrement && !disabled) { onIncrement(ev); } }, title: titleIncrement })); }; export default StepperStateless;