micro-customer-ui
Advanced tools
Comparing version 1.0.9 to 1.0.10
import '@storybook/addon-actions/register'; | ||
import '@storybook/addon-notes/register'; | ||
import '@storybook/addon-options/register'; |
import { configure, addDecorator } from '@storybook/react'; | ||
import { withNotes } from '@storybook/addon-notes'; | ||
import { withOptions } from '@storybook/addon-options'; | ||
import { themes } from '@storybook/components'; | ||
import { withInfo } from '@storybook/addon-info'; | ||
addDecorator(withNotes); | ||
addDecorator(withInfo({ | ||
source: false | ||
})); | ||
addDecorator( | ||
withOptions({ | ||
name: 'Foo', | ||
theme: themes.highlight, | ||
}) | ||
); | ||
function loadStories() { | ||
@@ -7,0 +18,0 @@ require('../src/stories/index.js'); |
@@ -1,2 +0,2 @@ | ||
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";e.exports=n(1)},function(e,t,n){"use strict"; | ||
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){"use strict";e.exports=n(2)},function(e,t,n){e.exports=n(4)()},function(e,t,n){"use strict"; | ||
/** @license React v16.7.0 | ||
@@ -9,3 +9,3 @@ * react.production.min.js | ||
* LICENSE file in the root directory of this source tree. | ||
*/var r=n(2),o="function"==typeof Symbol&&Symbol.for,i=o?Symbol.for("react.element"):60103,l=o?Symbol.for("react.portal"):60106,u=o?Symbol.for("react.fragment"):60107,a=o?Symbol.for("react.strict_mode"):60108,c=o?Symbol.for("react.profiler"):60114,f=o?Symbol.for("react.provider"):60109,s=o?Symbol.for("react.context"):60110,p=o?Symbol.for("react.concurrent_mode"):60111,y=o?Symbol.for("react.forward_ref"):60112,d=o?Symbol.for("react.suspense"):60113,m=o?Symbol.for("react.memo"):60115,h=o?Symbol.for("react.lazy"):60116,b="function"==typeof Symbol&&Symbol.iterator;function v(e){for(var t=arguments.length-1,n="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=0;r<t;r++)n+="&args[]="+encodeURIComponent(arguments[r+1]);!function(e,t,n,r,o,i,l,u){if(!e){if(e=void 0,void 0===t)e=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var a=[n,r,o,i,l,u],c=0;(e=Error(t.replace(/%s/g,function(){return a[c++]}))).name="Invariant Violation"}throw e.framesToPop=1,e}}(!1,"Minified React error #"+e+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",n)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_={};function O(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||g}function S(){}function j(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||g}O.prototype.isReactComponent={},O.prototype.setState=function(e,t){"object"!=typeof e&&"function"!=typeof e&&null!=e&&v("85"),this.updater.enqueueSetState(this,e,t,"setState")},O.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},S.prototype=O.prototype;var x=j.prototype=new S;x.constructor=j,r(x,O.prototype),x.isPureReactComponent=!0;var w={current:null,currentDispatcher:null},k=Object.prototype.hasOwnProperty,P={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,n){var r=void 0,o={},l=null,u=null;if(null!=t)for(r in void 0!==t.ref&&(u=t.ref),void 0!==t.key&&(l=""+t.key),t)k.call(t,r)&&!P.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(1===a)o.children=n;else if(1<a){for(var c=Array(a),f=0;f<a;f++)c[f]=arguments[f+2];o.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps)void 0===o[r]&&(o[r]=a[r]);return{$$typeof:i,type:e,key:l,ref:u,props:o,_owner:w.current}}function I(e){return"object"==typeof e&&null!==e&&e.$$typeof===i}var C=/\/+/g,$=[];function T(e,t,n,r){if($.length){var o=$.pop();return o.result=e,o.keyPrefix=t,o.func=n,o.context=r,o.count=0,o}return{result:e,keyPrefix:t,func:n,context:r,count:0}}function N(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>$.length&&$.push(e)}function R(e,t,n){return null==e?0:function e(t,n,r,o){var u=typeof t;"undefined"!==u&&"boolean"!==u||(t=null);var a=!1;if(null===t)a=!0;else switch(u){case"string":case"number":a=!0;break;case"object":switch(t.$$typeof){case i:case l:a=!0}}if(a)return r(o,t,""===n?"."+M(t,0):n),1;if(a=0,n=""===n?".":n+":",Array.isArray(t))for(var c=0;c<t.length;c++){var f=n+M(u=t[c],c);a+=e(u,f,r,o)}else if(f=null===t||"object"!=typeof t?null:"function"==typeof(f=b&&t[b]||t["@@iterator"])?f:null,"function"==typeof f)for(t=f.call(t),c=0;!(u=t.next()).done;)a+=e(u=u.value,f=n+M(u,c++),r,o);else"object"===u&&v("31","[object Object]"==(r=""+t)?"object with keys {"+Object.keys(t).join(", ")+"}":r,"");return a}(e,"",t,n)}function M(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}(e.key):t.toString(36)}function A(e,t){e.func.call(e.context,t,e.count++)}function q(e,t,n){var r=e.result,o=e.keyPrefix;e=e.func.call(e.context,t,e.count++),Array.isArray(e)?U(e,r,n,function(e){return e}):null!=e&&(I(e)&&(e=function(e,t){return{$$typeof:i,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(e,o+(!e.key||t&&t.key===e.key?"":(""+e.key).replace(C,"$&/")+"/")+n)),r.push(e))}function U(e,t,n,r,o){var i="";null!=n&&(i=(""+n).replace(C,"$&/")+"/"),R(e,q,t=T(t,i,r,o)),N(t)}var V={Children:{map:function(e,t,n){if(null==e)return e;var r=[];return U(e,r,null,t,n),r},forEach:function(e,t,n){if(null==e)return e;R(e,A,t=T(null,null,t,n)),N(t)},count:function(e){return R(e,function(){return null},null)},toArray:function(e){var t=[];return U(e,t,null,function(e){return e}),t},only:function(e){return I(e)||v("143"),e}},createRef:function(){return{current:null}},Component:O,PureComponent:j,createContext:function(e,t){return void 0===t&&(t=null),(e={$$typeof:s,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:f,_context:e},e.Consumer=e},forwardRef:function(e){return{$$typeof:y,render:e}},lazy:function(e){return{$$typeof:h,_ctor:e,_status:-1,_result:null}},memo:function(e,t){return{$$typeof:m,type:e,compare:void 0===t?null:t}},Fragment:u,StrictMode:a,Suspense:d,createElement:E,cloneElement:function(e,t,n){null==e&&v("267",e);var o=void 0,l=r({},e.props),u=e.key,a=e.ref,c=e._owner;if(null!=t){void 0!==t.ref&&(a=t.ref,c=w.current),void 0!==t.key&&(u=""+t.key);var f=void 0;for(o in e.type&&e.type.defaultProps&&(f=e.type.defaultProps),t)k.call(t,o)&&!P.hasOwnProperty(o)&&(l[o]=void 0===t[o]&&void 0!==f?f[o]:t[o])}if(1===(o=arguments.length-2))l.children=n;else if(1<o){f=Array(o);for(var s=0;s<o;s++)f[s]=arguments[s+2];l.children=f}return{$$typeof:i,type:e.type,key:u,ref:a,props:l,_owner:c}},createFactory:function(e){var t=E.bind(null,e);return t.type=e,t},isValidElement:I,version:"16.7.0",unstable_ConcurrentMode:p,unstable_Profiler:c,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:w,assign:r}},F={default:V},B=F&&V||F;e.exports=B.default||B},function(e,t,n){"use strict"; | ||
*/var r=n(3),o="function"==typeof Symbol&&Symbol.for,i=o?Symbol.for("react.element"):60103,l=o?Symbol.for("react.portal"):60106,a=o?Symbol.for("react.fragment"):60107,u=o?Symbol.for("react.strict_mode"):60108,c=o?Symbol.for("react.profiler"):60114,f=o?Symbol.for("react.provider"):60109,s=o?Symbol.for("react.context"):60110,p=o?Symbol.for("react.concurrent_mode"):60111,y=o?Symbol.for("react.forward_ref"):60112,d=o?Symbol.for("react.suspense"):60113,m=o?Symbol.for("react.memo"):60115,b=o?Symbol.for("react.lazy"):60116,h="function"==typeof Symbol&&Symbol.iterator;function v(e){for(var t=arguments.length-1,n="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=0;r<t;r++)n+="&args[]="+encodeURIComponent(arguments[r+1]);!function(e,t,n,r,o,i,l,a){if(!e){if(e=void 0,void 0===t)e=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,o,i,l,a],c=0;(e=Error(t.replace(/%s/g,function(){return u[c++]}))).name="Invariant Violation"}throw e.framesToPop=1,e}}(!1,"Minified React error #"+e+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",n)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_={};function O(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||g}function S(){}function j(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||g}O.prototype.isReactComponent={},O.prototype.setState=function(e,t){"object"!=typeof e&&"function"!=typeof e&&null!=e&&v("85"),this.updater.enqueueSetState(this,e,t,"setState")},O.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},S.prototype=O.prototype;var x=j.prototype=new S;x.constructor=j,r(x,O.prototype),x.isPureReactComponent=!0;var w={current:null,currentDispatcher:null},P=Object.prototype.hasOwnProperty,E={key:!0,ref:!0,__self:!0,__source:!0};function T(e,t,n){var r=void 0,o={},l=null,a=null;if(null!=t)for(r in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(l=""+t.key),t)P.call(t,r)&&!E.hasOwnProperty(r)&&(o[r]=t[r]);var u=arguments.length-2;if(1===u)o.children=n;else if(1<u){for(var c=Array(u),f=0;f<u;f++)c[f]=arguments[f+2];o.children=c}if(e&&e.defaultProps)for(r in u=e.defaultProps)void 0===o[r]&&(o[r]=u[r]);return{$$typeof:i,type:e,key:l,ref:a,props:o,_owner:w.current}}function k(e){return"object"==typeof e&&null!==e&&e.$$typeof===i}var I=/\/+/g,C=[];function $(e,t,n,r){if(C.length){var o=C.pop();return o.result=e,o.keyPrefix=t,o.func=n,o.context=r,o.count=0,o}return{result:e,keyPrefix:t,func:n,context:r,count:0}}function R(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>C.length&&C.push(e)}function N(e,t,n){return null==e?0:function e(t,n,r,o){var a=typeof t;"undefined"!==a&&"boolean"!==a||(t=null);var u=!1;if(null===t)u=!0;else switch(a){case"string":case"number":u=!0;break;case"object":switch(t.$$typeof){case i:case l:u=!0}}if(u)return r(o,t,""===n?"."+q(t,0):n),1;if(u=0,n=""===n?".":n+":",Array.isArray(t))for(var c=0;c<t.length;c++){var f=n+q(a=t[c],c);u+=e(a,f,r,o)}else if(f=null===t||"object"!=typeof t?null:"function"==typeof(f=h&&t[h]||t["@@iterator"])?f:null,"function"==typeof f)for(t=f.call(t),c=0;!(a=t.next()).done;)u+=e(a=a.value,f=n+q(a,c++),r,o);else"object"===a&&v("31","[object Object]"==(r=""+t)?"object with keys {"+Object.keys(t).join(", ")+"}":r,"");return u}(e,"",t,n)}function q(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}(e.key):t.toString(36)}function A(e,t){e.func.call(e.context,t,e.count++)}function M(e,t,n){var r=e.result,o=e.keyPrefix;e=e.func.call(e.context,t,e.count++),Array.isArray(e)?U(e,r,n,function(e){return e}):null!=e&&(k(e)&&(e=function(e,t){return{$$typeof:i,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(e,o+(!e.key||t&&t.key===e.key?"":(""+e.key).replace(I,"$&/")+"/")+n)),r.push(e))}function U(e,t,n,r,o){var i="";null!=n&&(i=(""+n).replace(I,"$&/")+"/"),N(e,M,t=$(t,i,r,o)),R(t)}var V={Children:{map:function(e,t,n){if(null==e)return e;var r=[];return U(e,r,null,t,n),r},forEach:function(e,t,n){if(null==e)return e;N(e,A,t=$(null,null,t,n)),R(t)},count:function(e){return N(e,function(){return null},null)},toArray:function(e){var t=[];return U(e,t,null,function(e){return e}),t},only:function(e){return k(e)||v("143"),e}},createRef:function(){return{current:null}},Component:O,PureComponent:j,createContext:function(e,t){return void 0===t&&(t=null),(e={$$typeof:s,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:f,_context:e},e.Consumer=e},forwardRef:function(e){return{$$typeof:y,render:e}},lazy:function(e){return{$$typeof:b,_ctor:e,_status:-1,_result:null}},memo:function(e,t){return{$$typeof:m,type:e,compare:void 0===t?null:t}},Fragment:a,StrictMode:u,Suspense:d,createElement:T,cloneElement:function(e,t,n){null==e&&v("267",e);var o=void 0,l=r({},e.props),a=e.key,u=e.ref,c=e._owner;if(null!=t){void 0!==t.ref&&(u=t.ref,c=w.current),void 0!==t.key&&(a=""+t.key);var f=void 0;for(o in e.type&&e.type.defaultProps&&(f=e.type.defaultProps),t)P.call(t,o)&&!E.hasOwnProperty(o)&&(l[o]=void 0===t[o]&&void 0!==f?f[o]:t[o])}if(1===(o=arguments.length-2))l.children=n;else if(1<o){f=Array(o);for(var s=0;s<o;s++)f[s]=arguments[s+2];l.children=f}return{$$typeof:i,type:e.type,key:a,ref:u,props:l,_owner:c}},createFactory:function(e){var t=T.bind(null,e);return t.type=e,t},isValidElement:k,version:"16.7.0",unstable_ConcurrentMode:p,unstable_Profiler:c,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:w,assign:r}},H={default:V},F=H&&V||H;e.exports=F.default||F},function(e,t,n){"use strict"; | ||
/* | ||
@@ -15,2 +15,2 @@ object-assign | ||
@license MIT | ||
*/var r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,l,u=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),a=1;a<arguments.length;a++){for(var c in n=Object(arguments[a]))o.call(n,c)&&(u[c]=n[c]);if(r){l=r(n);for(var f=0;f<l.length;f++)i.call(n,l[f])&&(u[l[f]]=n[l[f]])}}return u}},function(e,t,n){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),i=function(e,t){return function(e,t){var n=(e-1)/2,r=function(e,t){for(var n=[],r=t.month,o=t.year,i=0;i<e;i++)0==--r&&(r=12,o--),n.push({year:o,month:r});return n}(n,t),o=function(e,t){for(var n=[],r=t.month,o=t.year,i=0;i<e;i++)13==++r&&(r=1,o++),n.push({year:o,month:r});return n}(n,t);return r.reverse().concat(t,o)}(21,e).map(function(e){for(var n=!1,r=0;r<t.length;r++)if(e.year===t[r].year&&e.month===t[r].month){n=!0;break}return{leftInfo:e.year+"年",leftShow:1===e.month,centerInfo:e.month+"月",enabled:n}})},l=function(e){for(var t=e.begin,n=e.end,r=parseInt(t.substring(0,4)),o=parseInt(t.substring(4,6)),i=parseInt(n.substring(0,4)),l=parseInt(n.substring(4,6)),u=[],a=r,c=o,f=parseInt(a+""+(c>9?c:"0"+c)),s=parseInt(i+""+(l>9?l:"0"+l));f<=s;)u.push({year:a,month:c}),12===c&&a<i?(c=1,a++):c++,f=parseInt(a+""+(c>9?c:"0"+c));return u};n(3);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"default",function(){return y});var y=function(e){function t(e){var n,r,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r=this,o=c(t).call(this,e),n=!o||"object"!==u(o)&&"function"!=typeof o?s(r):o,p(s(s(n)),"calcVal",function(e){var t=n.props.config,r=i(e,l(t.enabledTime)),o=t.eleHeight,u=t.visibleNum*o,a=1,c=1,f="",s="";return r.forEach(function(e,t){t===(r.length-1)/2&&(f=e.centerInfo,s=e.leftInfo),1===a&&e.enabled?a=-t*o:1===a||1!==c||e.enabled||(c=-t*o)}),{scrollClass:"",list:r,scrollTop:-(r.length*o-u)/2,middleText:f,middleYear:s,topBoundary:a,bottomBoundary:c}}),p(s(s(n)),"handleClick",function(e){var t=n.props.config,r=e-((n.state.list.length-1)/2+1);if(0!==r){if(!n.state.list[e-1].enabled)return;var o=-r*t.eleHeight;n.setState({scrollClass:"time-line-scroll-trans",scrollTop:n.state.scrollTop+o},function(){setTimeout(function(){var t=n.state.list[e-1],r={year:parseInt(t.leftInfo.slice(0,-1)),month:parseInt(t.centerInfo.slice(0,-1))};n.setState(Object.assign({},n.calcVal(r))),n.props.onChange&&n.props.onChange(r)},501)})}}),n.state=Object.assign({},n.calcVal(e.config.curTime)),n}var n,r,y;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}(t,o.a.Component),n=t,(r=[{key:"render",value:function(){var e=this,t=this.props.config,n=t.eleHeight,r=t.visibleNum*n;return o.a.createElement("div",{className:"time-line-wrapper",style:{height:r+"px"}},o.a.createElement("div",{className:this.state.scrollClass+" time-line-scroll",style:{top:this.state.scrollTop+"px"}},o.a.createElement("ul",null,this.state.list.map(function(t,r){return o.a.createElement("li",{onClick:e.handleClick.bind(e,r+1),key:t.leftInfo+t.centerInfo,className:t.enabled?"":"time-line-disabled","data-cur-val":t.leftInfo+"-"+t.centerInfo},o.a.createElement("div",{style:{height:n+"px"},className:"time-line-center"},t.leftShow?t.leftInfo:"",t.centerInfo),t.enabled&&o.a.createElement("i",null))}))),o.a.createElement("div",{className:"time-line-middle",style:{height:n+"px",top:(r-n)/2+"px"}}),o.a.createElement("div",{"data-cur-val":this.state.middleYear+"-"+this.state.middleText,className:"1月"===this.state.middleText?"time-line-focus-flag-big":"time-line-focus-flag",style:{lineHeight:n-8+"px",height:n+"px",top:(r-n)/2+5+"px"}},"1月"===this.state.middleText?this.state.middleYear+this.state.middleText:this.state.middleText))}}])&&a(n.prototype,r),y&&a(n,y),t}()}]); | ||
*/var r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,l,a=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u<arguments.length;u++){for(var c in n=Object(arguments[u]))o.call(n,c)&&(a[c]=n[c]);if(r){l=r(n);for(var f=0;f<l.length;f++)i.call(n,l[f])&&(a[l[f]]=n[l[f]])}}return a}},function(e,t,n){"use strict";var r=n(5);function o(){}e.exports=function(){function e(e,t,n,o,i,l){if(l!==r){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),i=n(1),l=n.n(i),a=function(e,t){var n=e.split("-");return function(e,t){var n=(e-1)/2,r=function(e,t){for(var n=[],r=t.month,o=t.year,i=0;i<e;i++)0==--r&&(r=12,o--),n.push({year:o,month:r});return n}(n,t),o=function(e,t){for(var n=[],r=t.month,o=t.year,i=0;i<e;i++)13==++r&&(r=1,o++),n.push({year:o,month:r});return n}(n,t);return r.reverse().concat(t,o)}(21,{year:parseInt(n[0]),month:parseInt(n[1])}).map(function(e){for(var n=!1,r=0;r<t.length;r++)if(e.year===t[r].year&&e.month===t[r].month){n=!0;break}return{leftInfo:e.year+"年",leftShow:1===e.month,centerInfo:e.month+"月",enabled:n}})},u=function(e,t){for(var n=parseInt(e.substring(0,4)),r=parseInt(e.substring(5)),o=parseInt(t.substring(0,4)),i=parseInt(t.substring(5)),l=[],a=n,u=r,c=parseInt(a+""+(u>9?u:"0"+u)),f=parseInt(o+""+(i>9?i:"0"+i));c<=f;)l.push({year:a,month:u}),12===u&&a<o?(u=1,a++):u++,c=parseInt(a+""+(u>9?u:"0"+u));return l};n(6);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"default",function(){return m});var m=function(e){function t(e){var n,r,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r=this,o=s(t).call(this,e),n=!o||"object"!==c(o)&&"function"!=typeof o?y(r):o,d(y(y(n)),"calcVal",function(e){var t=a(e,u(n.props.beginEnabledTime,n.props.endEnabledTime)),r=n.props.eleHeight||1,o=n.props.visibleNum*r,i=1,l=1,c="",f="";return t.forEach(function(e,n){n===(t.length-1)/2&&(c=e.centerInfo,f=e.leftInfo),1===i&&e.enabled?i=-n*r:1===i||1!==l||e.enabled||(l=-n*r)}),{scrollClass:"",list:t,scrollTop:-(t.length*r-o)/2,middleText:c,middleYear:f,topBoundary:i,bottomBoundary:l}}),d(y(y(n)),"handleClick",function(e){var t=e-((n.state.list.length-1)/2+1);if(0!==t){if(!n.state.list[e-1].enabled)return;var r=-t*n.props.eleHeight;n.setState({scrollClass:"time-line-scroll-trans",scrollTop:n.state.scrollTop+r},function(){setTimeout(function(){var t=n.state.list[e-1],r=t.centerInfo.slice(0,-1),o=parseInt(t.leftInfo.slice(0,-1))+"-"+(1===r.length?"0"+r:r);console.log(o),n.setState(Object.assign({},n.calcVal(o))),n.props.onChange&&n.props.onChange(o)},501)})}}),n.state=Object.assign({},n.calcVal(e.selectedTime)),n}var n,r,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(t,o.a.Component),n=t,(r=[{key:"render",value:function(){var e=this,t=this.props.eleHeight,n=this.props.visibleNum*t;return o.a.createElement("div",{className:"time-line-wrapper",style:{height:n+"px"}},o.a.createElement("div",{className:this.state.scrollClass+" time-line-scroll",style:{top:this.state.scrollTop+"px"}},o.a.createElement("ul",null,this.state.list.map(function(n,r){return o.a.createElement("li",{onClick:e.handleClick.bind(e,r+1),key:n.leftInfo+n.centerInfo,className:n.enabled?"":"time-line-disabled","data-cur-val":n.leftInfo+"-"+n.centerInfo},o.a.createElement("div",{style:{height:t+"px"},className:"time-line-center"},n.leftShow?n.leftInfo:"",n.centerInfo),n.enabled&&o.a.createElement("i",null))}))),o.a.createElement("div",{className:"time-line-middle",style:{height:t+"px",top:(n-t)/2+"px"}}),o.a.createElement("div",{"data-cur-val":this.state.middleYear+"-"+this.state.middleText,className:"1月"===this.state.middleText?"time-line-focus-flag-big":"time-line-focus-flag",style:{lineHeight:t-8+"px",height:t+"px",top:(n-t)/2+5+"px"}},"1月"===this.state.middleText?this.state.middleYear+this.state.middleText:this.state.middleText))}}])&&f(n.prototype,r),i&&f(n,i),t}();m.defaultProps={beginEnabledTime:"1949-10",endEnabledTime:"6949-10",visibleNum:9,eleHeight:50},m.propTypes={selectedTime:l.a.string.isRequired,beginEnabledTime:l.a.string,endEnabledTime:l.a.string,visibleNum:l.a.number,eleHeight:l.a.number,onChange:l.a.func}}]); |
{ | ||
"name": "micro-customer-ui", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "", | ||
@@ -22,3 +22,5 @@ "browser": { | ||
"@storybook/addon-actions": "^4.1.4", | ||
"@storybook/addon-notes": "^4.1.4", | ||
"@storybook/addon-info": "^4.1.4", | ||
"@storybook/addon-options": "^4.1.4", | ||
"@storybook/components": "^4.1.4", | ||
"@storybook/react": "^4.1.4", | ||
@@ -34,2 +36,3 @@ "babel-loader": "^8.0.5", | ||
"dependencies": { | ||
"prop-types": "^15.6.2", | ||
"react": "^16.7.0", | ||
@@ -36,0 +39,0 @@ "react-dom": "^16.7.0" |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {getEnableTimes, switchNavData} from './timeUtils'; | ||
@@ -8,10 +9,9 @@ import '../css/timeLine.css'; | ||
super(props); | ||
this.state = Object.assign({}, this.calcVal(props.config.curTime)); | ||
this.state = Object.assign({}, this.calcVal(props.selectedTime)); | ||
} | ||
calcVal = (curTime) => { | ||
let config = this.props.config; | ||
let list = switchNavData(curTime, getEnableTimes(config.enabledTime)); | ||
let eleHeight = config.eleHeight; | ||
let visibleHeight = config.visibleNum * eleHeight; | ||
calcVal = (selectedTime) => { | ||
let list = switchNavData(selectedTime, getEnableTimes(this.props.beginEnabledTime, this.props.endEnabledTime)); | ||
let eleHeight = this.props.eleHeight || 1; | ||
let visibleHeight = this.props.visibleNum * eleHeight; | ||
@@ -53,3 +53,2 @@ // 计算出滚动边界 | ||
handleClick = (idx) => { | ||
let config = this.props.config; | ||
let idxSpan = idx - ((this.state.list.length - 1) / 2 + 1); | ||
@@ -64,3 +63,3 @@ if (idxSpan !== 0) { | ||
// 计算滚动间距 | ||
let scrollSpan = -idxSpan * config.eleHeight; | ||
let scrollSpan = -idxSpan * this.props.eleHeight; | ||
@@ -74,9 +73,8 @@ // 滚动动画 | ||
let stopTime = this.state.list[idx - 1]; | ||
let curTime = { | ||
year: parseInt(stopTime.leftInfo.slice(0, -1)), | ||
month: parseInt(stopTime.centerInfo.slice(0, -1)) | ||
}; | ||
this.setState(Object.assign({}, this.calcVal(curTime))); | ||
let monthStr = stopTime.centerInfo.slice(0, -1); | ||
let selectedTime = parseInt(stopTime.leftInfo.slice(0, -1)) + '-' + (monthStr.length === 1 ? '0' + monthStr : monthStr); | ||
console.log(selectedTime) | ||
this.setState(Object.assign({}, this.calcVal(selectedTime))); | ||
if (this.props.onChange) { | ||
this.props.onChange(curTime); | ||
this.props.onChange(selectedTime); | ||
} | ||
@@ -89,5 +87,4 @@ }, 501) | ||
render() { | ||
let config = this.props.config; | ||
let eleHeight = config.eleHeight; | ||
let visibleHeight = config.visibleNum * eleHeight; | ||
let eleHeight = this.props.eleHeight; | ||
let visibleHeight = this.props.visibleNum * eleHeight; | ||
@@ -121,1 +118,24 @@ return ( | ||
} | ||
// react的props默认值 | ||
TimeLine.defaultProps = { | ||
beginEnabledTime: '1949-10', | ||
endEnabledTime: '6949-10', | ||
visibleNum: 9, | ||
eleHeight: 50 | ||
}; | ||
TimeLine.propTypes = { | ||
/** 当前选中的节点,格式为:YYYY-MM */ | ||
selectedTime: PropTypes.string.isRequired, | ||
/** 可点击的开始时间节点,格式为:YYYY-MM */ | ||
beginEnabledTime: PropTypes.string, | ||
/** 可点击的结束时间节点,格式为:YYYY-MM */ | ||
endEnabledTime: PropTypes.string, | ||
/** 可视区域中的元素数量,请务必为奇数,最大为21 */ | ||
visibleNum: PropTypes.number, | ||
/** 每个元素的高度,单位px */ | ||
eleHeight: PropTypes.number, | ||
/** 时间节点变化时,调用此函数,回调参数参考ACTION LOGGER面板 */ | ||
onChange: PropTypes.func | ||
}; |
@@ -48,3 +48,8 @@ // 倒序获取年月集合 | ||
// 转为导航所需的数据结构 | ||
export const switchNavData = (curTime, enabledTimes) => { | ||
export const switchNavData = (selectedTime, enabledTimes) => { | ||
let timeArray = selectedTime.split('-'); | ||
let curTime = { | ||
year: parseInt(timeArray[0]), | ||
month: parseInt(timeArray[1]) | ||
}; | ||
let times = calcTimes(21, curTime); | ||
@@ -70,7 +75,7 @@ return times.map(time => { | ||
// 根据始末会计期计算出可访问的会计期列表 | ||
export const getEnableTimes = ({begin, end}) => { | ||
export const getEnableTimes = (begin, end) => { | ||
let beginYear = parseInt(begin.substring(0, 4)); | ||
let beginMonth = parseInt(begin.substring(4, 6)); | ||
let beginMonth = parseInt(begin.substring(5)); | ||
let endYear = parseInt(end.substring(0, 4)); | ||
let endMonth = parseInt(end.substring(4, 6)); | ||
let endMonth = parseInt(end.substring(5)); | ||
@@ -77,0 +82,0 @@ let times = []; |
@@ -1,1 +0,13 @@ | ||
### 时间导航 | ||
#### code | ||
~~~javascript | ||
import 'micro-customer-ui/dist/time-line-react/dist.css'; | ||
import TimeLine from 'micro-customer-ui/TimeLine'; | ||
<TimeLine | ||
selectedTime='2018-05' | ||
beginEnabledTime='2018-01' | ||
endEnabledTime='2018-06' | ||
onChange={this.handleChange} | ||
/> | ||
~~~ |
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import TimeLine from '../../dist/time-line-react/dist'; | ||
import TimeLine from '../components/time-line-react/js/TimeLine'; | ||
import markdown from '../components/time-line-react/readme.md'; | ||
import Loading from '../components/mior-react-loading/js/Loading'; | ||
// 配置信息 | ||
let config = { | ||
// 当前时间 | ||
curTime: { | ||
year: 2018, | ||
month: 5 | ||
storiesOf('导航', module).add('时间导航', () => | ||
<TimeLine | ||
selectedTime='2018-05' | ||
beginEnabledTime='2018-01' | ||
endEnabledTime='2018-06' | ||
onChange={action('onChange')} | ||
/>, { | ||
info: { | ||
text: markdown, | ||
inline: true | ||
}, | ||
}); | ||
// 可点击时间节点数组,格式要求:'YYYYMM' | ||
enabledTime: { | ||
begin: '201801', | ||
end: '201807' | ||
}, | ||
// 可视区域中的元素数量,请务必为奇数,最大为21 | ||
visibleNum: 9, | ||
// 每个元素的高度,单位px | ||
eleHeight: 50 | ||
}; | ||
storiesOf('导航', module).add('时间导航', () => | ||
<TimeLine config={config} onChange={action('onChange')}/>, { | ||
notes: { | ||
markdown: markdown | ||
} | ||
storiesOf('loading', module).add('大', () => | ||
<div> | ||
<Loading loading={true} size="large"/> | ||
</div>, { | ||
}).add('中', () => | ||
<div> | ||
<Loading loading={true} size="default"/> | ||
</div>, { | ||
}).add('小', () => | ||
<div> | ||
<Loading loading={true} size="small"/> | ||
</div>, { | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
326121
27
813
3
16
+ Addedprop-types@^15.6.2