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

63 lines 3.46 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 }); var React = require("react"); var utils_1 = require("../utils"); var VerticalLines = (function (_super) { __extends(VerticalLines, _super); function VerticalLines() { return _super !== null && _super.apply(this, arguments) || this; } VerticalLines.prototype.shouldComponentUpdate = function (nextProps, nextState) { return !(nextProps.canvasTimeStart === this.props.canvasTimeStart && nextProps.canvasTimeEnd === this.props.canvasTimeEnd && nextProps.canvasWidth === this.props.canvasWidth && nextProps.lineHeight === this.props.lineHeight && nextProps.lineCount === this.props.lineCount && nextProps.minUnit === this.props.minUnit && nextProps.timeSteps === this.props.timeSteps && nextProps.fixedHeader === this.props.fixedHeader && nextProps.height === this.props.height && nextProps.headerHeight === this.props.headerHeight); }; VerticalLines.prototype.render = function () { var _this = this; var _a = this.props, canvasTimeStart = _a.canvasTimeStart, canvasTimeEnd = _a.canvasTimeEnd, canvasWidth = _a.canvasWidth, minUnit = _a.minUnit, timeSteps = _a.timeSteps, height = _a.height, headerHeight = _a.headerHeight; var ratio = canvasWidth / (canvasTimeEnd - canvasTimeStart); var lines = []; utils_1.iterateTimes(canvasTimeStart, canvasTimeEnd, minUnit, timeSteps, function (time, nextTime) { var left = Math.round((time.valueOf() - canvasTimeStart) * ratio); var minUnitValue = time.get(minUnit === 'day' ? 'date' : minUnit); var firstOfType = minUnitValue === (minUnit === 'day' ? 1 : 0); var lineWidth = firstOfType ? 2 : 1; var labelWidth = Math.ceil((nextTime.valueOf() - time.valueOf()) * ratio) - lineWidth; var leftPush = _this.props.fixedHeader === 'fixed' && firstOfType ? -1 : 0; var classNames = 'rct-vl' + (firstOfType ? ' rct-vl-first' : '') + (minUnit === 'day' || minUnit === 'hour' || minUnit === 'minute' ? " rct-day-" + time.day() : ''); lines.push(React.createElement("div", { key: "line-" + time.valueOf(), className: classNames, style: { top: headerHeight + "px", left: left + leftPush + "px", width: labelWidth + "px", height: height - headerHeight + "px" } })); }); return (React.createElement("div", { className: 'rct-vertical-lines' }, lines)); }; VerticalLines.defaultProps = { fixedHeader: 'none', dayBackground: null }; return VerticalLines; }(React.Component)); exports.default = VerticalLines; //# sourceMappingURL=VerticalLines.js.map