jiku-ui
Version:
A Component Library for Vue.js.
1 lines • 6.14 kB
JavaScript
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=132)}({0:function(t,e,r){"use strict";function n(t,e,r,n,s,i,o,a){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=r,u._compiled=!0),n&&(u.functional=!0),i&&(u._scopeId="data-v-"+i),o?(c=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__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},u._ssrRegister=c):s&&(c=a?function(){s.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:s),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,c):[c]}return{exports:t,options:u}}r.d(e,"a",(function(){return n}))},132:function(t,e,r){"use strict";r.r(e);var n=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"hn-progress",class:["hn-progress--"+t.type,t.status?"is-"+t.status:"",{"hn-progress--without-text":!t.showText,"hn-progress--text-inside":t.textInside}],attrs:{role:"progressbar","aria-valuenow":t.percentage,"aria-valuemin":"0","aria-valuemax":"100"}},["line"===t.type?r("div",{staticClass:"hn-progress-bar"},[r("div",{staticClass:"hn-progress-bar__outer",style:{height:t.strokeWidth+"px"}},[r("div",{staticClass:"hn-progress-bar__inner",style:t.barStyle},[t.showText&&t.textInside?r("div",{staticClass:"hn-progress-bar__innerText"},[t._v(t._s(t.content))]):t._e()])])]):r("div",{staticClass:"hn-progress-circle",style:{height:t.width+"px",width:t.width+"px"}},[r("svg",{attrs:{viewBox:"0 0 100 100"}},[r("path",{staticClass:"hn-progress-circle__track",style:t.trailPathStyle,attrs:{d:t.trackPath,stroke:"#e5e9f2","stroke-width":t.relativeStrokeWidth,fill:"none"}}),r("path",{staticClass:"hn-progress-circle__path",style:t.circlePathStyle,attrs:{d:t.trackPath,stroke:t.stroke,fill:"none","stroke-linecap":"round","stroke-width":t.percentage?t.relativeStrokeWidth:0}})])]),t.showText&&!t.textInside?r("div",{staticClass:"hn-progress__text",style:{fontSize:t.progressTextSize+"px"}},[t.status?r("i",{class:t.iconClass}):[t._v(t._s(t.content))]],2):t._e()])};n._withStripped=!0;var s={name:"HnProgress",props:{type:{type:String,default:"line",validator:function(t){return["line","circle","dashboard"].indexOf(t)>-1}},percentage:{type:Number,default:0,required:!0,validator:function(t){return t>=0&&t<=100}},status:{type:String,validator:function(t){return["success","exception","warning"].indexOf(t)>-1}},strokeWidth:{type:Number,default:6},textInside:{type:Boolean,default:!1},width:{type:Number,default:88},showText:{type:Boolean,default:!0},color:{type:[String,Array,Function],default:""},format:Function},computed:{barStyle:function(){var t={};return t.width=this.percentage+"%",t.backgroundColor=this.getCurrentColor(this.percentage),t},relativeStrokeWidth:function(){return(this.strokeWidth/this.width*100).toFixed(1)},radius:function(){return"circle"===this.type||"dashboard"===this.type?parseInt(50-parseFloat(this.relativeStrokeWidth)/2,10):0},trackPath:function(){var t=this.radius,e="dashboard"===this.type;return"\n M 50 50\n m 0 "+(e?"":"-")+t+"\n a "+t+" "+t+" 0 1 1 0 "+(e?"-":"")+2*t+"\n a "+t+" "+t+" 0 1 1 0 "+(e?"":"-")+2*t+"\n "},perimeter:function(){return 2*Math.PI*this.radius},rate:function(){return"dashboard"===this.type?.75:1},strokeDashoffset:function(){return-1*this.perimeter*(1-this.rate)/2+"px"},trailPathStyle:function(){return{strokeDasharray:this.perimeter*this.rate+"px, "+this.perimeter+"px",strokeDashoffset:this.strokeDashoffset}},circlePathStyle:function(){return{strokeDasharray:this.perimeter*this.rate*(this.percentage/100)+"px, "+this.perimeter+"px",strokeDashoffset:this.strokeDashoffset,transition:"stroke-dasharray 0.6s ease 0s, stroke 0.6s ease"}},stroke:function(){var t=void 0;if(this.color)t=this.getCurrentColor(this.percentage);else switch(this.status){case"success":t="#13ce66";break;case"exception":t="#ff4949";break;case"warning":t="#e6a23c";break;default:t="#20a0ff"}return t},iconClass:function(){return"warning"===this.status?"hn-icon-warning":"line"===this.type?"success"===this.status?"hn-icon-circle-check":"hn-icon-circle-close":"success"===this.status?"hn-icon-check":"hn-icon-close"},progressTextSize:function(){return"line"===this.type?12+.4*this.strokeWidth:.111111*this.width+2},content:function(){return"function"==typeof this.format?this.format(this.percentage)||"":this.percentage+"%"}},methods:{getCurrentColor:function(t){return"function"==typeof this.color?this.color(t):"string"==typeof this.color?this.color:this.getLevelColor(t)},getLevelColor:function(t){for(var e=this.getColorArray().sort((function(t,e){return t.percentage-e.percentage})),r=0;r<e.length;r++)if(e[r].percentage>t)return e[r].color;return e[e.length-1].color},getColorArray:function(){var t=this.color,e=100/t.length;return t.map((function(t,r){return"string"==typeof t?{color:t,progress:(r+1)*e}:t}))}}},i=r(0),o=Object(i.a)(s,n,[],!1,null,null,null);o.options.__file="packages/progress/src/progress.vue";var a=o.exports;a.install=function(t){t.component(a.name,a)};e.default=a}}).default;