jiku-ui
Version:
A Component Library for Vue.js.
2 lines (1 loc) • 5.86 kB
JavaScript
module.exports=function(t){var n={};function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:i})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(e.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(i,o,function(n){return t[n]}.bind(null,o));return i},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=130)}({0:function(t,n,e){"use strict";function i(t,n,e,i,o,r,s,u){var a,l="function"==typeof t?t.options:t;if(n&&(l.render=n,l.staticRenderFns=e,l._compiled=!0),i&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),s?(a=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},l._ssrRegister=a):o&&(a=u?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),a)if(l.functional){l._injectStyles=a;var c=l.render;l.render=function(t,n){return a.call(n),c(t,n)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,a):[a]}return{exports:t,options:l}}e.d(n,"a",(function(){return i}))},130:function(t,n,e){"use strict";e.r(n);var i=function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("div",{staticClass:"hn-countdown",class:["hn-countdown--"+t.type,"hn-countdown--"+t.size]},[t._t("default",[t.showPrefix?e("div",{staticClass:"hn-countdown__prefix"},[t._v("\n "+t._s(t.prefix)+"\n ")]):t._e(),-1!==t.tplIndexOfDays?e("div",{staticClass:"hn-countdown__item"},[e("div",{staticClass:"hn-countdown-num hn-countdown-num--day"},[t._v("\n "+t._s(t.countDownData.d)+"\n ")]),e("div",{staticClass:"hn-countdown-tpl hn-countdown-tpl--day"},[t._v("\n "+t._s(t.getDot(t.tplIndexOfDays,t.tplIndexOfHours))+"\n ")])]):t._e(),-1!==t.tplIndexOfHours?e("div",{staticClass:"hn-countdown__item"},[e("div",{staticClass:"hn-countdown-num hn-countdown-num--hour"},[t._v("\n "+t._s(t.countDownData.h)+"\n ")]),e("div",{staticClass:"hn-countdown-tpl hn-countdown-tpl--hour"},[t._v("\n "+t._s(t.getDot(t.tplIndexOfHours,t.tplIndexOfMinutes))+"\n ")])]):t._e(),-1!==t.tplIndexOfMinutes?e("div",{staticClass:"hn-countdown__item"},[e("div",{staticClass:"hn-countdown-num hn-countdown-num--minute"},[t._v("\n "+t._s(t.countDownData.m)+"\n ")]),e("div",{staticClass:"hn-countdown-tpl hn-countdown-tpl--minute"},[t._v("\n "+t._s(t.getDot(t.tplIndexOfMinutes,t.tplIndexOfSeconds))+"\n ")])]):t._e(),-1!==t.tplIndexOfSeconds?e("div",{staticClass:"hn-countdown__item"},[e("div",{staticClass:"hn-countdown-num hn-countdown-num--second"},[t._v("\n "+t._s(t.countDownData.s)+"\n ")]),e("div",{staticClass:"hn-countdown-tpl hn-countdown-tpl--second"},[t._v("\n "+t._s(t.getDot(t.tplIndexOfSeconds,-1))+"\n ")])]):t._e()],{countDownData:t.countDownData})],2)};i._withStripped=!0;var o=e(62),r=e.n(o),s={name:"HnCountdown",components:{},props:{size:{type:String,default:"medium"},type:{type:String,default:"default"},totalTime:{type:[Number,String],default:0,validator:function(t){return t>=0}},endTime:[Number,String],interval:{type:Number,default:1e3,validator:function(t){return t>=0}},tpl:{type:String,default:"{h}:{m}:{s}"},stopAtThatTime:{type:Boolean,default:!0},showPrefix:{type:Boolean,default:!1},timingPrefix:{type:String,default:"-"},timeoutPrefix:{type:String,default:"+"}},data:function(){return{leftTime:0,timer:null}},computed:{timeUnits:function(){return this.tpl.match(/[^\{\}]+(?=\})/g)},countDownData:function(){var t=this.leftTime;return this.stopAtThatTime&&t<=0&&(t=0,this.$emit("finish"),this.clearInterval()),t=1e3*Math.ceil(t/1e3),r()(t,this.timeUnits)},tplIndexOfDays:function(){return this.tpl.indexOf("d")},tplIndexOfHours:function(){return this.tpl.indexOf("h")},tplIndexOfMinutes:function(){return this.tpl.indexOf("m")},tplIndexOfSeconds:function(){return this.tpl.indexOf("s")},isTimeOut:function(){return this.leftTime<=0},prefix:function(){return this.isTimeOut?this.timeoutPrefix:this.timingPrefix}},created:function(){this.initLeftTime()},mounted:function(){this.start()},beforeDestroy:function(){this.clearInterval()},methods:{getTimeStamp:function(t){if(!t)return Date.now();var n=t;return n=n>0?+n:n.toString().replace(/\-/g,"/"),new Date(n).getTime()},clearInterval:function(t){function n(){return t.apply(this,arguments)}return n.toString=function(){return t.toString()},n}((function(){clearInterval(this.timer),this.timer=null})),initLeftTime:function(){var t=Date.now(),n=this.getTimeStamp(this.endTime||t)+1e3*this.totalTime;this.leftTime=n-t},start:function(){var t=this;if(!this.timer){var n=this.leftTime+Date.now();this.stopAtThatTime&&this.isTimeOut||(this.timer=setInterval((function(){t.leftTime=n-Date.now()}),this.interval))}},pause:function(){this.timer&&this.clearInterval()},getDot:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return-1===n?this.tpl.slice(t+2):this.tpl.slice(t+2,n-1)}}},u=e(0),a=Object(u.a)(s,i,[],!1,null,null,null);a.options.__file="packages/countdown/src/main.vue";var l=a.exports;l.install=function(t){t.component(l.name,l)};n.default=l},62:function(t,n){t.exports=require("jiku-ui/lib/utils/parse-ms")}}).default;