UNPKG

@arche-mc2/arche-controls

Version:

We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get

83 lines 4.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var UpInput_1 = require("../Input/UpInput"); var SvgIcon_1 = require("../../Display/SvgIcon"); var typestyle_1 = require("typestyle"); var withTheme_1 = require("../../../Common/theming/withTheme"); var theming_1 = require("../../../Common/theming"); var classnames = require("classnames"); var utils_1 = require("../../../Common/utils"); var styles_1 = require("./styles"); var UpPassword = (function (_super) { tslib_1.__extends(UpPassword, _super); function UpPassword(p, c) { var _this = _super.call(this, p, c) || this; _this.toggleVisible = function (e) { _this.setState(function (prevState) { return ({ isVisible: !prevState.isVisible, }); }); }; _this.hide = function () { if (_this.isHidden || _this.updatingShow) { return; } _this.updatingHide = setTimeout(function () { return _this.setState({ isVisible: false }, function () { return (_this.updatingHide = null); }); }, 500); }; _this.show = function () { if (_this.isShown || _this.updatingShow) { return; } _this.updatingShow = setTimeout(function () { return _this.setState({ isVisible: true }, function () { return (_this.updatingShow = null); }); }, 0); }; _this.state = { isVisible: false, }; return _this; } Object.defineProperty(UpPassword.prototype, "isHidden", { get: function () { return this.state.isVisible === false; }, enumerable: true, configurable: true }); Object.defineProperty(UpPassword.prototype, "isShown", { get: function () { return this.state.isVisible === true; }, enumerable: true, configurable: true }); UpPassword.prototype.render = function () { var _this = this; var iconEyeOpen = 'eye'; var iconEyeClose = 'eye-off'; var type = this.state.isVisible === true ? this.props.type : 'password'; var themeStyles = this.props.theme.styles.get('input') || {}; var _a = this.props, showSuccess = _a.showSuccess, onBlur = _a.onBlur, showError = _a.showError, onFocus = _a.onFocus, onClickBehaviour = _a.showPasswordOnClick, rules = _a.rules, value = _a.value, focused = _a.focused, theme = _a.theme, others = tslib_1.__rest(_a, ["showSuccess", "onBlur", "showError", "onFocus", "showPasswordOnClick", "rules", "value", "focused", "theme"]); return (React.createElement(React.Fragment, null, React.createElement("div", { className: classnames(typestyle_1.style(themeStyles), styles_1.getStyles(this.props), 'up-password', onClickBehaviour ? styles_1.onSide : '') }, React.createElement("div", { style: { width: '100%' } }, React.createElement(UpInput_1.UpInput, tslib_1.__assign({}, others, { showSuccess: showSuccess, onBlur: onBlur, onFocus: onFocus, type: type, showValidationStatus: false, theme: theme }))), React.createElement(SvgIcon_1.default, { onMouseOver: !onClickBehaviour ? this.show : null, onMouseOut: !onClickBehaviour ? this.hide : null, onClick: onClickBehaviour ? this.toggleVisible : null, iconName: !!this.state.isVisible ? iconEyeOpen : iconEyeClose })), focused && !utils_1.isEmpty(rules) && (React.createElement("div", { className: classnames(styles_1.getRulesStyle(this.props), 'password-rules') }, rules.map(function (_a) { var text = _a.text, regex = _a.regex; return (React.createElement("div", { key: text, style: { display: 'flex', alignItems: 'center' } }, React.createElement("span", { className: styles_1.getRuleStatus(_this.props, regex) }), React.createElement("p", null, text))); }))))); }; UpPassword.defaultProps = { theme: theming_1.default, }; return UpPassword; }(React.Component)); exports.UpPassword = UpPassword; exports.default = withTheme_1.default(UpPassword); //# sourceMappingURL=UpPassword.js.map