4dde18a45cd112845514d89edd3b9af1.json 9.26 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/createSuper\";\nimport * as React from 'react';\nimport Statistic from './Statistic';\nimport { formatCountdown } from './utils';\nimport { cloneElement } from '../_util/reactNode';\nvar REFRESH_INTERVAL = 1000 / 30;\n\nfunction getTime(value) {\n  return new Date(value).getTime();\n}\n\nvar Countdown = /*#__PURE__*/function (_React$Component) {\n  _inherits(Countdown, _React$Component);\n\n  var _super = _createSuper(Countdown);\n\n  function Countdown() {\n    var _this;\n\n    _classCallCheck(this, Countdown);\n\n    _this = _super.apply(this, arguments);\n\n    _this.syncTimer = function () {\n      var value = _this.props.value;\n      var timestamp = getTime(value);\n\n      if (timestamp >= Date.now()) {\n        _this.startTimer();\n      } else {\n        _this.stopTimer();\n      }\n    };\n\n    _this.startTimer = function () {\n      if (_this.countdownId) return;\n      _this.countdownId = window.setInterval(function () {\n        _this.forceUpdate();\n      }, REFRESH_INTERVAL);\n    };\n\n    _this.stopTimer = function () {\n      var _this$props = _this.props,\n          onFinish = _this$props.onFinish,\n          value = _this$props.value;\n\n      if (_this.countdownId) {\n        clearInterval(_this.countdownId);\n        _this.countdownId = undefined;\n        var timestamp = getTime(value);\n\n        if (onFinish && timestamp < Date.now()) {\n          onFinish();\n        }\n      }\n    };\n\n    _this.formatCountdown = function (value, config) {\n      var format = _this.props.format;\n      return formatCountdown(value, _extends(_extends({}, config), {\n        format: format\n      }));\n    }; // Countdown do not need display the timestamp\n\n\n    _this.valueRender = function (node) {\n      return cloneElement(node, {\n        title: undefined\n      });\n    };\n\n    return _this;\n  }\n\n  _createClass(Countdown, [{\n    key: \"componentDidMount\",\n    value: function componentDidMount() {\n      this.syncTimer();\n    }\n  }, {\n    key: \"componentDidUpdate\",\n    value: function componentDidUpdate() {\n      this.syncTimer();\n    }\n  }, {\n    key: \"componentWillUnmount\",\n    value: function componentWillUnmount() {\n      this.stopTimer();\n    }\n  }, {\n    key: \"render\",\n    value: function render() {\n      return /*#__PURE__*/React.createElement(Statistic, _extends({\n        valueRender: this.valueRender\n      }, this.props, {\n        formatter: this.formatCountdown\n      }));\n    }\n  }]);\n\n  return Countdown;\n}(React.Component);\n\nCountdown.defaultProps = {\n  format: 'HH:mm:ss'\n};\nexport default Countdown;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/statistic/Countdown.js"],"names":["_extends","_classCallCheck","_createClass","_inherits","_createSuper","React","Statistic","formatCountdown","cloneElement","REFRESH_INTERVAL","getTime","value","Date","Countdown","_React$Component","_super","_this","apply","arguments","syncTimer","props","timestamp","now","startTimer","stopTimer","countdownId","window","setInterval","forceUpdate","_this$props","onFinish","clearInterval","undefined","config","format","valueRender","node","title","key","componentDidMount","componentDidUpdate","componentWillUnmount","render","createElement","formatter","Component","defaultProps"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,eAAP,MAA4B,uCAA5B;AACA,OAAOC,YAAP,MAAyB,oCAAzB;AACA,OAAOC,SAAP,MAAsB,iCAAtB;AACA,OAAOC,YAAP,MAAyB,oCAAzB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,SAASC,eAAT,QAAgC,SAAhC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,IAAIC,gBAAgB,GAAG,OAAO,EAA9B;;AAEA,SAASC,OAAT,CAAiBC,KAAjB,EAAwB;AACtB,SAAO,IAAIC,IAAJ,CAASD,KAAT,EAAgBD,OAAhB,EAAP;AACD;;AAED,IAAIG,SAAS,GAAG,aAAa,UAAUC,gBAAV,EAA4B;AACvDX,EAAAA,SAAS,CAACU,SAAD,EAAYC,gBAAZ,CAAT;;AAE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AA,SAAS,EAAE,KAAKrC;AADH,OAF4C,CAAvC,CAApB;AAKD;AARA,GAfqB,CAAZ,CAAZ;;AA0BA,SAAOM,SAAP;AACD,CA1F4B,CA0F3BR,KAAK,CAACwC,SA1FqB,CAA7B;;AA4FAhC,SAAS,CAACiC,YAAV,GAAyB;AACvBZ,EAAAA,MAAM,EAAE;AADe,CAAzB;AAGA,eAAerB,SAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/createSuper\";\nimport * as React from 'react';\nimport Statistic from './Statistic';\nimport { formatCountdown } from './utils';\nimport { cloneElement } from '../_util/reactNode';\nvar REFRESH_INTERVAL = 1000 / 30;\n\nfunction getTime(value) {\n  return new Date(value).getTime();\n}\n\nvar Countdown = /*#__PURE__*/function (_React$Component) {\n  _inherits(Countdown, _React$Component);\n\n  var _super = _createSuper(Countdown);\n\n  function Countdown() {\n    var _this;\n\n    _classCallCheck(this, Countdown);\n\n    _this = _super.apply(this, arguments);\n\n    _this.syncTimer = function () {\n      var value = _this.props.value;\n      var timestamp = getTime(value);\n\n      if (timestamp >= Date.now()) {\n        _this.startTimer();\n      } else {\n        _this.stopTimer();\n      }\n    };\n\n    _this.startTimer = function () {\n      if (_this.countdownId) return;\n      _this.countdownId = window.setInterval(function () {\n        _this.forceUpdate();\n      }, REFRESH_INTERVAL);\n    };\n\n    _this.stopTimer = function () {\n      var _this$props = _this.props,\n          onFinish = _this$props.onFinish,\n          value = _this$props.value;\n\n      if (_this.countdownId) {\n        clearInterval(_this.countdownId);\n        _this.countdownId = undefined;\n        var timestamp = getTime(value);\n\n        if (onFinish && timestamp < Date.now()) {\n          onFinish();\n        }\n      }\n    };\n\n    _this.formatCountdown = function (value, config) {\n      var format = _this.props.format;\n      return formatCountdown(value, _extends(_extends({}, config), {\n        format: format\n      }));\n    }; // Countdown do not need display the timestamp\n\n\n    _this.valueRender = function (node) {\n      return cloneElement(node, {\n        title: undefined\n      });\n    };\n\n    return _this;\n  }\n\n  _createClass(Countdown, [{\n    key: \"componentDidMount\",\n    value: function componentDidMount() {\n      this.syncTimer();\n    }\n  }, {\n    key: \"componentDidUpdate\",\n    value: function componentDidUpdate() {\n      this.syncTimer();\n    }\n  }, {\n    key: \"componentWillUnmount\",\n    value: function componentWillUnmount() {\n      this.stopTimer();\n    }\n  }, {\n    key: \"render\",\n    value: function render() {\n      return /*#__PURE__*/React.createElement(Statistic, _extends({\n        valueRender: this.valueRender\n      }, this.props, {\n        formatter: this.formatCountdown\n      }));\n    }\n  }]);\n\n  return Countdown;\n}(React.Component);\n\nCountdown.defaultProps = {\n  format: 'HH:mm:ss'\n};\nexport default Countdown;"]},"metadata":{},"sourceType":"module"}