react-yan-progress
Version:
This is a cascading progress bar component based on react
1 lines • 11.3 kB
JavaScript
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.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 o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));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="./build/",r(r.s=2)}([function(t,e){t.exports=require("react")},function(t,e,r){var n=r(3);"string"==typeof n&&(n=[[t.i,n,""]]);var o={hmr:!0,transform:void 0,insertInto:void 0};r(5)(n,o);n.locals&&(t.exports=n.locals)},function(t,e,r){"use strict";r.r(e);var n=r(0),o=r(1);function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function a(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var u={tip:[{text:"未提交X人",fillStyle:"#ccc"},{text:"已提交X人",fillStyle:"#9c3"},{text:"已批改X人",fillStyle:"#080"}]};function f(t){var e=t.total,r=t.done;return r<=0||e<=0?0:r>e?100:r/e*100}function p(t){var e=t.total,r=t.done,n=t.modify;return 0===f({total:e,done:r})?0:n>r?100:n/r*100}var d=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=a(this,c(e).call(this,t))).state={donePercent:f(t),modifyPercent:p(t),tip:t.tip instanceof Array?t.tip:u.tip},r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(e,n["Component"]),function(t,e,r){e&&s(t.prototype,e),r&&s(t,r)}(e,[{key:"componentWillReceiveProps",value:function(t){var e=t.done,r=t.modify;this.props.done!==e&&this.setState({donePercent:f({done:e,total:this.props.total})}),this.props.modify!==r&&this.setState({donePercent:p({modify:r,done:this.props.done})})}},{key:"render",value:function(){return n.createElement("div",{className:o["y-progress"],style:{backgroundColor:this.state.tip[0].fillStyle||"#ccc"}},n.createElement("a",{className:o["y-progress_text"],style:{width:"".concat(100-this.state.donePercent,"%")}},n.createElement("span",{className:o["y-tooltip"]},this.state.tip[0].text.replace("X",this.props.total<this.props.done?0:this.props.total-this.props.done))),n.createElement("div",{className:o["y-progress_bar"],style:{width:"".concat(this.state.donePercent,"%"),backgroundColor:this.state.tip[1].fillStyle||"#9c3"}},n.createElement("a",{className:o["y-progress_text"],style:{width:"".concat(100-this.state.modifyPercent,"%")}},n.createElement("span",{className:o["y-tooltip"]},this.state.tip[1].text.replace("X",this.props.done>this.props.total?this.props.total:this.props.done))),n.createElement("div",{className:o["y-progress_bar"],style:{width:"".concat(this.state.modifyPercent,"%"),backgroundColor:this.state.tip[2].fillStyle||"#080"}},n.createElement("a",{className:o["y-progress_text"],style:{width:"100%"}},n.createElement("span",{className:o["y-tooltip"]},this.state.tip[2].text.replace("X",this.props.modify>this.props.done?this.props.done:this.props.modify))))))}}]),e}();e.default=d},function(t,e,r){(e=t.exports=r(4)(!1)).push([t.i,'._2aa4880b {\r\n position: relative;\r\n width: 100%;\r\n height: 8px;\r\n background-color: #ccc;\r\n border-radius: 4px;\r\n}\r\n._82773576 {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n bottom: 0;\r\n border-radius: 4px;\r\n transition: all 1.5s ease;\r\n}\r\n.a10e04f8 {\r\n position: absolute;\r\n top: 0;\r\n right: 0;\r\n bottom: 0;\r\n text-align: center;\r\n}\r\n.a10e04f8 ._0ca1c067 {\r\n position: absolute;\r\n top: 15px;\r\n right: 0;\r\n background-color: #333;\r\n color: #f1f1f1;\r\n border-radius: 5px;\r\n padding: 5px 10px;\r\n visibility: hidden;\r\n opacity: 0;\r\n transform: scale(0);\r\n transition: all ease-in 0.2s;\r\n}\r\n.a10e04f8:hover ._0ca1c067 {\r\n visibility: visible;\r\n opacity: 1;\r\n transform: scale(1);\r\n}\r\n._0ca1c067:after {\r\n content: "";\r\n position: absolute;\r\n bottom: 100%;\r\n left: 50%;\r\n transform: translate(-50%, 0);\r\n border: 5px solid;\r\n border-color: transparent transparent #333 transparent;\r\n}\r\n',""]),e.locals={"y-progress":"_2aa4880b","y-progress_bar":"_82773576","y-progress_text":"a10e04f8","y-tooltip":"_0ca1c067"}},function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var r=function(t,e){var r=t[1]||"",n=t[3];if(!n)return r;if(e&&"function"==typeof btoa){var o=function(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}(n),i=n.sources.map(function(t){return"/*# sourceURL="+n.sourceRoot+t+" */"});return[r].concat(i).concat([o]).join("\n")}return[r].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+r+"}":r}).join("")},e.i=function(t,r){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},o=0;o<this.length;o++){var i=this[o][0];"number"==typeof i&&(n[i]=!0)}for(o=0;o<t.length;o++){var s=t[o];"number"==typeof s[0]&&n[s[0]]||(r&&!s[2]?s[2]=r:r&&(s[2]="("+s[2]+") and ("+r+")"),e.push(s))}},e}},function(t,e,r){var n={},o=function(t){var e;return function(){return void 0===e&&(e=t.apply(this,arguments)),e}}(function(){return window&&document&&document.all&&!window.atob}),i=function(t){var e={};return function(t,r){if("function"==typeof t)return t();if(void 0===e[t]){var n=function(t,e){return e?e.querySelector(t):document.querySelector(t)}.call(this,t,r);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}}(),s=null,a=0,c=[],l=r(6);function u(t,e){for(var r=0;r<t.length;r++){var o=t[r],i=n[o.id];if(i){i.refs++;for(var s=0;s<i.parts.length;s++)i.parts[s](o.parts[s]);for(;s<o.parts.length;s++)i.parts.push(b(o.parts[s],e))}else{var a=[];for(s=0;s<o.parts.length;s++)a.push(b(o.parts[s],e));n[o.id]={id:o.id,refs:1,parts:a}}}}function f(t,e){for(var r=[],n={},o=0;o<t.length;o++){var i=t[o],s=e.base?i[0]+e.base:i[0],a={css:i[1],media:i[2],sourceMap:i[3]};n[s]?n[s].parts.push(a):r.push(n[s]={id:s,parts:[a]})}return r}function p(t,e){var r=i(t.insertInto);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var n=c[c.length-1];if("top"===t.insertAt)n?n.nextSibling?r.insertBefore(e,n.nextSibling):r.appendChild(e):r.insertBefore(e,r.firstChild),c.push(e);else if("bottom"===t.insertAt)r.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=i(t.insertAt.before,r);r.insertBefore(e,o)}}function d(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=c.indexOf(t);e>=0&&c.splice(e,1)}function y(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var n=function(){0;return r.nc}();n&&(t.attrs.nonce=n)}return h(e,t.attrs),p(t,e),e}function h(t,e){Object.keys(e).forEach(function(r){t.setAttribute(r,e[r])})}function b(t,e){var r,n,o,i;if(e.transform&&t.css){if(!(i="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=i}if(e.singleton){var c=a++;r=s||(s=y(e)),n=v.bind(null,r,c,!1),o=v.bind(null,r,c,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",h(e,t.attrs),p(t,e),e}(e),n=function(t,e,r){var n=r.css,o=r.sourceMap,i=void 0===e.convertToAbsoluteUrls&&o;(e.convertToAbsoluteUrls||i)&&(n=l(n));o&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var s=new Blob([n],{type:"text/css"}),a=t.href;t.href=URL.createObjectURL(s),a&&URL.revokeObjectURL(a)}.bind(null,r,e),o=function(){d(r),r.href&&URL.revokeObjectURL(r.href)}):(r=y(e),n=function(t,e){var r=e.css,n=e.media;n&&t.setAttribute("media",n);if(t.styleSheet)t.styleSheet.cssText=r;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(r))}}.bind(null,r),o=function(){d(r)});return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else o()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var r=f(t,e);return u(r,e),function(t){for(var o=[],i=0;i<r.length;i++){var s=r[i];(a=n[s.id]).refs--,o.push(a)}t&&u(f(t,e),e);for(i=0;i<o.length;i++){var a;if(0===(a=o[i]).refs){for(var c=0;c<a.parts.length;c++)a.parts[c]();delete n[a.id]}}}};var m=function(){var t=[];return function(e,r){return t[e]=r,t.filter(Boolean).join("\n")}}();function v(t,e,r,n){var o=r?"":n.css;if(t.styleSheet)t.styleSheet.cssText=m(e,o);else{var i=document.createTextNode(o),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var r=e.protocol+"//"+e.host,n=r+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,e){var o,i=e.trim().replace(/^"(.*)"$/,function(t,e){return e}).replace(/^'(.*)'$/,function(t,e){return e});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?t:(o=0===i.indexOf("//")?i:0===i.indexOf("/")?r+i:n+i.replace(/^\.\//,""),"url("+JSON.stringify(o)+")")})}}]);