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 2.72 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 __()); }; })(); 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 MIN_DATE = new Date(-8640000000000); var MAX_DATE = new Date(+8640000000000); var UpDateTime = (function (_super) { __extends(UpDateTime, _super); function UpDateTime(p, c) { var _this = _super.call(this, p, c) || this; _this.onChangeDate = function (date) { var current = _this.state.value; if (current != null) { date.setHours(current.getHours()); date.setMinutes(current.getMinutes()); } _this.setState({ value: date }); _this.handleChangeEvent(date); }; _this.onChangeTime = function (time) { var current = _this.state.value; if (current != null) { time.setDate(current.getDate()); time.setMonth(current.getMonth()); time.setFullYear(current.getFullYear()); } _this.setState({ value: time }); _this.handleChangeEvent(time); }; _this.getValue = _this.getValue.bind(_this); _this.state = { value: p.value }; return _this; } UpDateTime.prototype.renderControl = function () { return React.createElement(styles_1.default, { format: this.props.format, value: this.state.value, hasError: this.props.hasError, onChangeDate: this.onChangeDate, disabled: this.props.disabled, minDate: this.props.minDate ? this.props.minDate : MIN_DATE, maxDate: this.props.maxDate ? this.props.maxDate : MAX_DATE, onChangeTime: this.onChangeTime }); }; UpDateTime.prototype.getValue = function (newDate) { return newDate; }; UpDateTime.defaultProps = { format: "DD/MM/YYYY", showError: true }; return UpDateTime; }(BaseControl_1.BaseControlComponent)); exports.default = UpDateTime; //# sourceMappingURL=UpDateTime.js.map