UNPKG

react-life-design

Version:
70 lines 3.51 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var Input_styled_1 = require("./Input.styled"); var index_1 = require("../index"); var Input = (function (_super) { __extends(Input, _super); function Input() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { passwordType: false, }; _this.togglePassword = function (passwordType) { return _this.setState(({ passwordType: passwordType })); }; _this.renderIcon = function (type) { switch (type) { case 'password': { return (React.createElement(index_1.Icons.Eye, { onClick: function (passwordType) { return _this.togglePassword(passwordType); } })); } case 'search': { return (React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 18.414 18.414', className: 'search-icon' }, React.createElement("g", { fill: 'none', stroke: '#08a5d3', strokeLinecap: 'square', strokeWidth: '2' }, React.createElement("path", { d: 'M11.685 1a5.73 5.73 0 1 1-5.73 5.73A5.73 5.73 0 0 1 11.685 1z' }), React.createElement("path", { strokeMiterlimit: '10', d: 'M7.63 10.784L1.414 17' })))); } default: return null; } }; return _this; } Input.prototype.render = function () { var _a = this.props, feedback = _a.feedback, comment = _a.comment, label = _a.label, type = _a.type, placeholder = _a.placeholder, isInvalid = _a.isInvalid, isWarning = _a.isWarning; var passwordType = this.state.passwordType; var password = passwordType && { type: 'text' }; var moreInformationInInput = feedback || comment || isInvalid || isWarning; return (React.createElement(Input_styled_1.default.GroupInput, null, React.createElement(Input_styled_1.default.Input, __assign({}, this.props, { passwordType: passwordType }, password)), React.createElement("label", null, label || placeholder), React.createElement("span", { className: 'bar' }), (moreInformationInInput) && React.createElement("span", { className: 'feedback' }, moreInformationInInput), this.renderIcon(type))); }; return Input; }(React.PureComponent)); exports.default = Input; //# sourceMappingURL=Input.js.map