@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.
84 lines (72 loc) • 3.2 kB
JavaScript
;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.StyledFormFeedback = void 0;
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _defaultTheme = _interopRequireDefault(require("../defaultTheme"));
var _consts = _interopRequireDefault(require("./consts"));
var StyledFormFeedback = (0, _styledComponents.default)(function (_ref) {
var theme = _ref.theme,
type = _ref.type,
props = (0, _objectWithoutProperties2.default)(_ref, ["theme", "type"]);
return /*#__PURE__*/React.createElement("div", props);
}).withConfig({
displayName: "FormFeedback__StyledFormFeedback",
componentId: "sc-1lhzkwp-0"
})(["color:", ";font-family:", ";font-size:", ";font-weight:", ";line-height:", ";width:100%;margin-top:2px;position:absolute;top:100%;max-height:", ";overflow:hidden;white-space:nowrap;text-overflow:ellipsis;& a{color:", ";font-weight:", ";text-decoration:underline;cursor:pointer;}strong,b{font-weight:", ";color:", ";}"], function (_ref2) {
var theme = _ref2.theme,
type = _ref2.type;
return type === _consts.default.ERROR ? theme.orbit.colorTextError : theme.orbit.colorTextSecondary;
}, function (_ref3) {
var theme = _ref3.theme;
return theme.orbit.fontFamily;
}, function (_ref4) {
var theme = _ref4.theme;
return theme.orbit.fontSizeFormFeedback;
}, function (_ref5) {
var theme = _ref5.theme,
type = _ref5.type;
return type === _consts.default.ERROR ? theme.orbit.fontWeightMedium : theme.orbit.fontWeightNormal;
}, function (_ref6) {
var theme = _ref6.theme;
return theme.orbit.lineHeightTextSmall;
}, function (_ref7) {
var theme = _ref7.theme;
return theme.orbit.lineHeightTextSmall;
}, function (_ref8) {
var theme = _ref8.theme,
type = _ref8.type;
return type === _consts.default.ERROR ? theme.orbit.colorTextError : theme.orbit.colorTextPrimary;
}, function (_ref9) {
var theme = _ref9.theme;
return theme.orbit.fontWeightMedium;
}, function (_ref10) {
var theme = _ref10.theme;
return theme.fontWeightMedium;
}, function (_ref11) {
var theme = _ref11.theme;
return theme.paletteInkNormal;
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
exports.StyledFormFeedback = StyledFormFeedback;
StyledFormFeedback.defaultProps = {
theme: _defaultTheme.default
};
var FormFeedback = function FormFeedback(_ref12) {
var error = _ref12.error,
help = _ref12.help,
dataTest = _ref12.dataTest;
var isHelp = help && !error;
if (!error && !help) return null;
return /*#__PURE__*/React.createElement(StyledFormFeedback, {
type: isHelp ? "help" : error && "error",
"data-test": dataTest,
"aria-live": "polite"
}, isHelp ? help : error && error);
};
var _default = FormFeedback;
exports.default = _default;