lucid-ui
Version:
A UI component library from AppNexus.
105 lines • 5.8 kB
JavaScript
;
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 (Object.prototype.hasOwnProperty.call(b, 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 __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
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);
};
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 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = __importDefault(require("lodash"));
var react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("react-peek/prop-types"));
var Validation_1 = __importDefault(require("../Validation/Validation"));
var TextField_1 = __importDefault(require("../TextField/TextField"));
var TextField_reducers_1 = __importDefault(require("../TextField/TextField.reducers"));
var style_helpers_1 = require("../../util/style-helpers");
var component_types_1 = require("../../util/component-types");
var cx = style_helpers_1.lucidClassNames.bind('&-TextFieldValidated');
var any = prop_types_1.default.any, object = prop_types_1.default.object, string = prop_types_1.default.string;
var TextFieldValidatedError = function (_props) {
return null;
};
TextFieldValidatedError.displayName = 'TextFieldValidated.Error';
TextFieldValidatedError.peek = {
description: "\n\t\tContent that will be displayed as an error message.\n\t",
};
TextFieldValidatedError.propName = 'Error';
var TextFieldValidated = /** @class */ (function (_super) {
__extends(TextFieldValidated, _super);
function TextFieldValidated() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.textFieldRef = react_1.default.createRef();
_this.focus = function () {
_this.textFieldRef.current && _this.textFieldRef.current.focus();
};
return _this;
}
TextFieldValidated.prototype.render = function () {
var _a = this.props, className = _a.className, style = _a.style, passThroughs = __rest(_a, ["className", "style"]);
var childProps;
if (this.props.Error) {
childProps = lodash_1.default.map(component_types_1.findTypes(this.props, TextFieldValidated.Error), 'props');
}
else if (this.props.Info) {
childProps = [this.props.Info];
}
return (react_1.default.createElement(Validation_1.default, { className: cx('&', className, {
'-info': !this.props.Error && this.props.Info,
}), style: style, Error: childProps },
react_1.default.createElement(TextField_1.default, __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(TextFieldValidated.propTypes), false), { ref: this.textFieldRef }))));
};
TextFieldValidated.displayName = 'TextFieldValidated';
TextFieldValidated.Error = TextFieldValidatedError;
TextFieldValidated.peek = {
description: "\n\t\t\t\t\tA composition of TextField and Validation.\n\t\t\t\t",
categories: ['controls', 'text'],
};
TextFieldValidated.reducers = TextField_reducers_1.default;
TextFieldValidated.propTypes = {
style: object(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t\t\tPassed to the root container.\n\t\t"], ["\n\t\t\tPassed to the root container.\n\t\t"]))),
className: string(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\t\t\tPassed to the root container.\n\t\t"], ["\n\t\t\tPassed to the root container.\n\t\t"]))),
Error: any(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\t\t\tProp alternative to Error child component\n\t\t"], ["\n\t\t\tProp alternative to Error child component\n\t\t"]))),
Info: string(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\t\t\tOptional information text that is styled less aggressively than an error\n\t\t"], ["\n\t\t\tOptional information text that is styled less aggressively than an error\n\t\t"]))),
};
TextFieldValidated.defaultProps = TextField_1.default.defaultProps;
return TextFieldValidated;
}(react_1.default.Component));
exports.default = TextFieldValidated;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
//# sourceMappingURL=TextFieldValidated.js.map