@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
63 lines • 3.11 kB
JavaScript
;
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 });
require("normalize.css/normalize.css");
var React = require("react");
var BaseControl_1 = require("../_Common/BaseControl/BaseControl");
var styles_1 = require("./styles");
var theming_1 = require("../../../Common/theming");
var MIN_DATE = new Date(-8640000000000);
var MAX_DATE = new Date(+8640000000000);
var UpDate = (function (_super) {
__extends(UpDate, _super);
function UpDate(p, c) {
var _this = _super.call(this, p, c) || this;
_this.state = { value: _this.props.value };
return _this;
}
UpDate.prototype.shouldComponentUpdate = function (nextProps, nextState) {
var shouldUpdate = nextState.value != this.state.value || nextState.error != this.state.error;
if (shouldUpdate === false) {
shouldUpdate = this.props.disabled != nextProps.disabled
|| this.props.format != nextProps.format
|| this.props.maxDate != nextProps.maxDate
|| this.props.minDate != nextProps.minDate
|| this.props.readonly != nextProps.readonly
|| this.props.theme !== nextProps.theme;
}
return shouldUpdate;
};
UpDate.prototype.renderControl = function () {
var _a = this.props, format = _a.format, hasError = _a.hasError, disabled = _a.disabled, minDate = _a.minDate, maxDate = _a.maxDate, readonly = _a.readonly, others = __rest(_a, ["format", "hasError", "disabled", "minDate", "maxDate", "readonly"]);
return React.createElement(styles_1.default, { format: format, value: this.state.value, hasError: hasError || this.hasError(), onChange: this.handleChangeEvent, disabled: disabled, minDate: minDate ? minDate : MIN_DATE, maxDate: maxDate ? maxDate : MAX_DATE });
};
UpDate.prototype.getValue = function (newDate) {
return newDate;
};
UpDate.defaultProps = {
format: "DD/MM/YYYY",
showError: true,
theme: theming_1.default
};
return UpDate;
}(BaseControl_1.BaseControlComponent));
exports.default = UpDate;
//# sourceMappingURL=UpDate.js.map