UNPKG

@up-group/react-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

65 lines 3.52 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var 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 function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var styles_1 = require("./styles"); var BaseControl_1 = require("../_Common/BaseControl/BaseControl"); var TypeStringControl_1 = require("../_Common/Validation/TypeStringControl"); var theming_1 = require("../../../Common/theming"); var UpInput = (function (_super) { __extends(UpInput, _super); function UpInput(p, c) { var _this = _super.call(this, p, c) || this; _this.inputHandleChangeEvent = function (event) { _this.handleChangeEvent(event); }; var _self = _this; if (_this.props.validation && _this.props.validation.length > 0) { _this.props.validation.map(function (value, index) { if (value && value.pattern) { _self._validationManager.addControl(new TypeStringControl_1.default(value.pattern, value.errorMessage)); } }); } return _this; } UpInput.prototype.getValue = function (event) { return (event == null) ? null : event.target != null ? event.target.value : event; }; UpInput.prototype.renderControl = function () { var _a = this.props, type = _a.type, onChange = _a.onChange, value = _a.value, validation = _a.validation, hasError = _a.hasError, iconName = _a.iconName, width = _a.width, disabled = _a.disabled, readonly = _a.readonly, tooltip = _a.tooltip, theme = _a.theme, maxLength = _a.maxLength, placeholder = _a.placeholder, others = __rest(_a, ["type", "onChange", "value", "validation", "hasError", "iconName", "width", "disabled", "readonly", "tooltip", "theme", "maxLength", "placeholder"]); var realIconName = iconName; if (realIconName == null && type != null) { realIconName = type; } return (React.createElement(styles_1.InputStyled, { value: this.state.value == null ? "" : this.state.value, iconName: realIconName, width: width, disabled: disabled, readonly: readonly, tooltip: tooltip, theme: theme, maxLength: maxLength, placeholder: placeholder, type: type || "text", hasError: this.props.hasError || this.hasError(), showError: this.props.showError, onChange: this.inputHandleChangeEvent }, this.props.children)); }; UpInput.defaultProps = { showError: true, theme: theming_1.default, width: "fill" }; return UpInput; }(BaseControl_1.BaseControlComponent)); exports.default = UpInput; //# sourceMappingURL=UpInput.js.map