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.

95 lines (79 loc) 3.41 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _styledComponents = _interopRequireWildcard(require("styled-components")); var _defaultTheme = _interopRequireDefault(require("../defaultTheme")); var _AlertCircle = _interopRequireDefault(require("../icons/AlertCircle")); var _InformationCircle = _interopRequireDefault(require("../icons/InformationCircle")); var _rtl = require("../utils/rtl"); const StyledAsterisk = _styledComponents.default.span.withConfig({ displayName: "FormLabel__StyledAsterisk", componentId: "sc-qbinms-0" })(["", ""], ({ theme, filled }) => (0, _styledComponents.css)(["font-weight:", ";color:", ";font-size:", ";vertical-align:top;"], theme.orbit.fontWeightBold, !filled ? theme.orbit.colorTextError : theme.orbit.colorFormLabelFilled, theme.orbit.fontSizeFormLabel)); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledAsterisk.defaultProps = { theme: _defaultTheme.default }; const StyledInputErrorIcWrapper = _styledComponents.default.span.withConfig({ displayName: "FormLabel__StyledInputErrorIcWrapper", componentId: "sc-qbinms-1" })(["margin:", ";display:inline-flex;align-items:center;"], ({ theme }) => (0, _rtl.rtlSpacing)(`0 ${theme.orbit.spaceXXSmall} 0 0`)); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledInputErrorIcWrapper.defaultProps = { theme: _defaultTheme.default }; const FormLabel = (0, _styledComponents.default)(({ className, children, required, filled, dataTest, id, error, help, onMouseEnter, onMouseLeave, iconRef, inlineLabel, labelRef }) => /*#__PURE__*/React.createElement("span", { className: className, "data-test": dataTest, id: id, ref: labelRef }, !inlineLabel && (error || help) && /*#__PURE__*/React.createElement(StyledInputErrorIcWrapper, { ref: iconRef, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, error && /*#__PURE__*/React.createElement(_AlertCircle.default, { ariaLabel: "error", color: "critical", size: "small" }), !error && help && /*#__PURE__*/React.createElement(_InformationCircle.default, { ariaLabel: "help", color: "info", size: "small" })), required && !error && /*#__PURE__*/React.createElement(StyledAsterisk, { "aria-hidden": "true", filled: filled }, "*"), /*#__PURE__*/React.createElement("span", null, children))).withConfig({ displayName: "FormLabel", componentId: "sc-qbinms-2" })(["", ""], ({ theme, filled, disabled }) => (0, _styledComponents.css)(["display:flex;font-family:", ";font-size:", ";font-weight:", ";color:", ";line-height:", ";margin-bottom:", ";"], theme.orbit.fontFamily, theme.orbit.fontSizeFormLabel, theme.orbit.fontWeightMedium, !filled || disabled ? theme.orbit.colorFormLabel : theme.orbit.colorFormLabelFilled, theme.orbit.lineHeightTextSmall, theme.orbit.spaceXXSmall)); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 FormLabel.defaultProps = { theme: _defaultTheme.default }; var _default = FormLabel; exports.default = _default;