UNPKG

@dock365/reform-fabric-fields

Version:
64 lines 3.56 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 __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = __importStar(require("react")); var TextField_1 = require("office-ui-fabric-react/lib/TextField"); var ErrorHandlerHOC_1 = __importDefault(require("./ErrorHandlerHOC")); var validator_1 = require("@dock365/validator"); var MultilineTextField = /** @class */ (function (_super) { __extends(MultilineTextField, _super); function MultilineTextField(props) { return _super.call(this, props) || this; } MultilineTextField.prototype.render = function () { var _this = this; var showLength = this.props.customProps && this.props.customProps.showLength; var description = this.props.customProps && this.props.customProps.description; var valueLength = this.props.value && this.props.value.length || 0; var maxLength = this.props.validationRules && this.props.validationRules.type === validator_1.validationTypes.String && this.props.validationRules.maxLength || ""; var lengthDescription = showLength ? "" + valueLength + (maxLength && "/" + maxLength) : ""; var calculatedDescription = showLength || description ? (description ? "" + description + (lengthDescription && " - " + lengthDescription) : lengthDescription) : ""; return (React.createElement(TextField_1.TextField, { value: this.props.value || "", label: this.props.label, placeholder: this.props.placeholder, readOnly: this.props.readOnly, multiline: true, onChange: function (e, value) { if (_this.props.onChange) _this.props.onChange(_this.props.validationRules && _this.props.validationRules.type === validator_1.validationTypes.Number && Number(value) || value); }, onBlur: function (e) { var value = e.currentTarget.value; if (_this.props.onBlur) _this.props.onBlur(_this.props.validationRules && _this.props.validationRules.type === validator_1.validationTypes.Number && Number(value) || value); }, description: calculatedDescription, rows: this.props.customProps && this.props.customProps.rows || 4 })); }; return MultilineTextField; }(React.PureComponent)); exports.default = ErrorHandlerHOC_1.default(MultilineTextField); //# sourceMappingURL=MultilineTextField.js.map