azure-devops-ui
Version:
React components for building web UI in Azure DevOps
1 lines • 1.36 kB
JavaScript
import{__extends}from"tslib";import"../../../CommonImports";import"../../../Core/core.css";import*as React from"react";import*as DateUtil from"../../../Utilities/Date";import{Time}from"../Time/Time";import*as Resources from"../../../Resources.Widgets";import{format}from"../../../Core/Util/String";var Duration=function(r){function i(t){var e=r.call(this,t)||this;return e.getTimeString=function(){return DateUtil.duration(e.props.startDate,e.props.endDate)},e.getNextInterval=function(){return i.durationNextInterval(e.props.startDate,e.props.endDate)},e.state={tooltipProps:{}},e}return __extends(i,r),i.getDerivedStateFromProps=function(t){return{tooltipProps:void 0===t.tooltipProps?{renderContent:function(){return format(Resources.Started,DateUtil.tooltipString(t.startDate))}}:t.tooltipProps}},i.prototype.render=function(){return React.createElement(Time,{ariaHidden:this.props.ariaHidden,ariaLabel:this.props.ariaLabel||DateUtil.tooltipString(this.props.startDate),className:this.props.className,getNextInterval:this.getNextInterval,getTimeString:this.getTimeString,tabIndex:this.props.tabIndex,tooltipProps:this.state.tooltipProps})},i.durationNextInterval=function(t,e,r){return e?-1:(r=(e=r||new Date).getTime()-t.getTime(),DateUtil.minute,r<DateUtil.day?DateUtil.second:DateUtil.minute-r%DateUtil.minute)},i}(React.Component);export{Duration};