"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.defaultProps=exports.propTypes=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf3=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_react=_interopRequireWildcard(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_classnames=_interopRequireDefault(require("classnames")),_componentHelper=require("../../shared/component-helper"),_ProgressIndicatorCircular=_interopRequireDefault(require("./ProgressIndicatorCircular")),renderProps={on_complete:null},propTypes={visible:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),type:_propTypes.default.oneOf(["circular"]),no_animation:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),size:_propTypes.default.oneOf(["small","medium","large","huge"]),progress:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.number]),on_complete:_propTypes.default.func};exports.propTypes=propTypes;var defaultProps=(0,_objectSpread2.default)({visible:!0,type:"circular",no_animation:!1,size:"medium",progress:null},renderProps);exports.defaultProps=defaultProps;var ProgressIndicator=function(e){function s(){var e,r;(0,_classCallCheck2.default)(this,s);for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return r=(0,_possibleConstructorReturn2.default)(this,(e=(0,_getPrototypeOf3.default)(s)).call.apply(e,[this].concat(o))),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(r),"state",{_listenForPropChanges:!0}),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(r),"callOnCompleteHandler",function(){r.completeTimeout=setTimeout(function(){r.setState({complete:!0}),"function"==typeof r.props.on_complete&&(r.fadeOutTimeout=setTimeout(function(){(0,_componentHelper.dispatchCustomElementEvent)((0,_assertThisInitialized2.default)(r),"on_complete")},600))},200)}),r}return(0,_inherits2.default)(s,e),(0,_createClass2.default)(s,[{key:"componentWillUnmount",value:function(){clearTimeout(this.completeTimeout),clearTimeout(this.fadeOutTimeout)}},{key:"render",value:function(){var e=this.props,r=e.type,t=e.size,o=e.no_animation,i=e.on_complete,s=(e.progress,e.visible,e.complete,(0,_objectWithoutProperties2.default)(e,["type","size","no_animation","on_complete","progress","visible","complete"])),p=this.state,l=p.progress,a=p.visible,n=p.complete,u=(0,_objectSpread2.default)({},s),c=-1<parseFloat(l);return a&&!c&&(u.role="alert",u["aria-busy"]="true"),(0,_componentHelper.validateDOMAttributes)(this.props,u),_react.default.createElement("div",(0,_extends2.default)({className:(0,_classnames.default)("dnb-progress-indicator",a&&"dnb-progress-indicator--visible",n&&"dnb-progress-indicator--complete",(0,_componentHelper.isTrue)(o)&&"dnb-progress-indicator--no-animation")},u),"circular"===r&&_react.default.createElement(_ProgressIndicatorCircular.default,{size:t,progress:l,visible:a,complete:n,onComplete:i,callOnCompleteHandler:this.callOnCompleteHandler}))}}],[{key:"enableWebComponent",value:function(){(0,_componentHelper.registerElement)(s.tagName,s,defaultProps)}},{key:"getDerivedStateFromProps",value:function(e,r){return r._listenForPropChanges&&(r.visible=(0,_componentHelper.isTrue)(e.visible),r.visible&&(r.complete=!1),-1<parseFloat(e.progress)&&(r.progress=e.progress)),r._listenForPropChanges=!0,r}}]),s}(_react.PureComponent);exports.default=ProgressIndicator,(0,_defineProperty2.default)(ProgressIndicator,"tagName","dnb-progress-indicator"),(0,_defineProperty2.default)(ProgressIndicator,"defaultProps",defaultProps),ProgressIndicator.propTypes="production"!==process.env.NODE_ENV?propTypes:{};
//# sourceMappingURL=ProgressIndicator.js.map
