react-rating
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -1,2 +0,2 @@ | ||
/*! react-rating - 0.8.1 | (c) 2015, 2017 dreyescat | MIT | https://github.com/dreyescat/react-rating */ | ||
/*! react-rating - 0.9.0 | (c) 2015, 2017 dreyescat | MIT | https://github.com/dreyescat/react-rating */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -157,2 +157,5 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
value: function handleClick(i, event) { | ||
if (this.props.readonly) { | ||
return; | ||
} | ||
var index = i + this._fractionalIndex(event); | ||
@@ -172,2 +175,5 @@ this.props.onClick(this._indexToRate(index), event); | ||
value: function handleMouseLeave() { | ||
if (this.props.readonly) { | ||
return; | ||
} | ||
this.props.onRate(); | ||
@@ -181,2 +187,5 @@ this.setState({ | ||
value: function handleMouseMove(i, event) { | ||
if (this.props.readonly) { | ||
return; | ||
} | ||
var index = i + this._fractionalIndex(event); | ||
@@ -271,6 +280,6 @@ if (this.state.indexOver !== index) { | ||
percent: percent, | ||
onClick: !readonly && this.handleClick.bind(this, i), | ||
onMouseMove: !readonly && this.handleMouseMove.bind(this, i), | ||
onTouchMove: !readonly && this.handleMouseMove.bind(this, i), | ||
onTouchEnd: !readonly && this.handleClick.bind(this, i), | ||
onClick: this.handleClick.bind(this, i), | ||
onMouseMove: this.handleMouseMove.bind(this, i), | ||
onTouchMove: this.handleMouseMove.bind(this, i), | ||
onTouchEnd: this.handleClick.bind(this, i), | ||
direction: this.state.direction | ||
@@ -286,3 +295,3 @@ })); | ||
}, | ||
onMouseLeave: !readonly && this.handleMouseLeave | ||
onMouseLeave: this.handleMouseLeave | ||
}, other), | ||
@@ -1532,3 +1541,4 @@ symbolNodes | ||
onTouchMove: props.onMouseMove, | ||
onTouchEnd: props.onClick }, | ||
onTouchEnd: props.onClick | ||
}, | ||
backgroundNode, | ||
@@ -1535,0 +1545,0 @@ _react2['default'].createElement( |
@@ -1,2 +0,2 @@ | ||
/*! react-rating - 0.8.1 | (c) 2015, 2017 dreyescat | MIT | https://github.com/dreyescat/react-rating */ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRating=t(require("react")):e.ReactRating=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="/lib",t(0)}([function(e,t,n){"use strict";e.exports=n(9)},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function a(){v&&d&&(v=!1,d.length?h=d.concat(h):y=-1,h.length&&u())}function u(){if(!v){var e=o(a);v=!0;for(var t=h.length;t;){for(d=h,h=[];++y<t;)d&&d[y].run();y=-1,t=h.length}d=null,v=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function s(){}var l,f,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,h=[],v=!1,y=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new c(e,t)),1!==h.length||v||o(u)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,p.prependListener=s,p.prependOnceListener=s,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){(function(t){"use strict";function n(e,t,n,o,i,a,u,c){if(r(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,o,i,a,u,c],f=0;s=new Error(t.replace(/%s/g,function(){return l[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}var r=function(e){};"production"!==t.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=n}).call(t,n(1))},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){(function(t){"use strict";var r=n(2),o=r;"production"!==t.env.NODE_ENV&&!function(){var e=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}};o=function(t,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!t){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e.apply(void 0,[n].concat(o))}}}(),e.exports=o}).call(t,n(1))},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},i=!0;e.exports=n(14)(o,i)}else e.exports=n(13)()}).call(t,n(1))},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=n(7),a=r(i),u=n(6),c=(r(u),function(e){return a.default.isValidElement(e)?e:"object"==typeof e&&null!==e?a.default.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?a.default.createElement("span",{className:e}):void 0}),s=function(e){var t,n=c(e.background),r=c(e.icon),i=(t={display:"inline-block",position:"absolute",overflow:"hidden",top:0},o(t,"rtl"===e.direction?"right":"left",0),o(t,"width",void 0!==e.percent?e.percent+"%":"auto"),t),u={cursor:e.onClick||e.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return a.default.createElement("span",{style:u,onClick:e.onClick,onMouseMove:e.onMouseMove,onTouchMove:e.onMouseMove,onTouchEnd:e.onClick},n,a.default.createElement("span",{style:i},r))};s.propTypes=!1,e.exports=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(e,t,n){for(var r=!0;r;){var o=e,i=t,a=n;r=!1,null===o&&(o=Function.prototype);var u=Object.getOwnPropertyDescriptor(o,i);if(void 0!==u){if("value"in u)return u.value;var c=u.get;if(void 0===c)return;return c.call(a)}var s=Object.getPrototypeOf(o);if(null===s)return;e=s,t=i,n=a,r=!0,u=s=void 0}},l=n(7),f=r(l),p=n(6),d=(r(p),n(11)),h=r(d),v=n(8),y=r(v),m=function(e,t){var n=e.step,r=n>0?e.start:e.stop,o=n>0?e.stop:e.start;if(n&&r<=t&&t<=o)return(t-e.start)/n},b=function(e){function t(e){i(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e);var n=void 0!==e.initialRate?e.initialRate:e.placeholderRate;this.state={index:m(e,n),indexOver:void 0,direction:"ltr"},this.ratingContainer=null,this.handleClick=this.handleClick.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this)}return a(t,e),c(t,[{key:"componentDidMount",value:function(){this.setState({direction:window.getComputedStyle(this.ratingContainer,null).getPropertyValue("direction")})}},{key:"componentWillReceiveProps",value:function(e){var t=void 0!==e.initialRate?e.initialRate:e.placeholderRate;this.setState({index:m(e,t),selected:void 0!==e.initialRate})}},{key:"handleClick",value:function(e,t){var n=e+this._fractionalIndex(t);this.props.onClick(this._indexToRate(n),t),this.state.index!==n&&(this.props.onChange(this._indexToRate(n)),this.setState({indexOver:void 0,index:n,selected:!0}))}},{key:"handleMouseLeave",value:function(){this.props.onRate(),this.setState({indexOver:void 0})}},{key:"handleMouseMove",value:function(e,t){var n=e+this._fractionalIndex(t);this.state.indexOver!==n&&(this.props.onRate(this._indexToRate(n)),this.setState({indexOver:n}))}},{key:"_indexToRate",value:function(e){return this.props.start+Math.floor(e)*this.props.step+this.props.step*this._roundToFraction(e%1)}},{key:"_rateToIndex",value:function(e){return m(this.props,e)}},{key:"_roundToFraction",value:function(e){var t=Math.ceil(e%1*this.props.fractions)/this.props.fractions,n=Math.pow(10,this.props.scale),r=Math.floor(e)+Math.floor(t*n)/n;return r>this.props.stop?this.props.stop:r}},{key:"_fractionalIndex",value:function(e){var t=e.nativeEvent.type.indexOf("touch")>-1?e.nativeEvent.type.indexOf("touchend")>-1?e.changedTouches[0].clientX:e.touches[0].clientX:e.clientX,n="rtl"===this.state.direction?e.currentTarget.getBoundingClientRect().right-t:t-e.currentTarget.getBoundingClientRect().left;return this._roundToFraction(n/e.currentTarget.offsetWidth)}},{key:"render",value:function(){for(var e=this,t=this.props,n=(t.start,t.stop),r=(t.step,t.initialRate),i=t.placeholderRate,a=(t.empty,t.full,t.placeholder,t.readonly),c=t.quiet,s=(t.fractions,t.scale,t.onChange,t.onClick,t.onRate,o(t,["start","stop","step","initialRate","placeholderRate","empty","full","placeholder","readonly","quiet","fractions","scale","onChange","onClick","onRate"])),l=[],p=[].concat(this.props.empty),d=[].concat(this.props.placeholder),h=[].concat(this.props.full),v=c||void 0===this.state.indexOver?this.state.index:this.state.indexOver,m=Math.floor(v),b=this.state.selected||void 0!==r||void 0===i||!c&&void 0!==this.state.indexOver?h:d,g=0;g<Math.floor(this._rateToIndex(n));g++){var x=g-m===0?v%1*100:g-m<0?100:0;l.push(f.default.createElement(y.default,{key:g,background:p[g%p.length],icon:b[g%b.length],percent:x,onClick:!a&&this.handleClick.bind(this,g),onMouseMove:!a&&this.handleMouseMove.bind(this,g),onTouchMove:!a&&this.handleMouseMove.bind(this,g),onTouchEnd:!a&&this.handleClick.bind(this,g),direction:this.state.direction}))}return f.default.createElement("span",u({ref:function(t){e.ratingContainer=t},onMouseLeave:!a&&this.handleMouseLeave},s),l)}}]),t}(f.default.Component);b.defaultProps={start:0,stop:5,step:1,empty:h.default.empty,placeholder:h.default.placeholder,full:h.default.full,fractions:1,scale:3,onChange:function(e){},onClick:function(e){},onRate:function(e){}},b.propTypes=!1,e.exports=b},function(e,t){"use strict";e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}},function(e,t,n){"use strict";var r=n(10),o={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};e.exports={empty:r(o,{backgroundColor:"#ccc"}),full:r(o,{backgroundColor:"black"}),placeholder:r(o,{backgroundColor:"red"})}},function(e,t,n){(function(t){"use strict";function r(e,n,r,c,s){if("production"!==t.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var f;try{o("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",c||"React class",r,l),f=e[l](n,l,c,r,null,a)}catch(e){f=e}if(i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",r,l,typeof f),f instanceof Error&&!(f.message in u)){u[f.message]=!0;var p=s?s():"";i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(3),i=n(5),a=n(4),u={};e.exports=r}).call(t,n(1))},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(4);e.exports=function(){function e(e,t,n,r,a,u){u!==i&&o(!1,"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")}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};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){(function(t){"use strict";var r=n(2),o=n(3),i=n(5),a=n(4),u=n(12);e.exports=function(e,n){function c(e){var t=e&&(M&&e[M]||e[j]);if("function"==typeof t)return t}function s(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function l(e){this.message=e,this.stack=""}function f(e){function r(r,s,f,p,d,h,v){if(p=p||C,h=h||f,v!==a)if(n)o(!1,"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");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var y=p+":"+f;!u[y]&&c<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",h,p),u[y]=!0,c++)}return null==s[f]?r?new l(null===s[f]?"The "+d+" `"+h+"` is marked as required "+("in `"+p+"`, but its value is `null`."):"The "+d+" `"+h+"` is marked as required in "+("`"+p+"`, but its value is `undefined`.")):null:e(s,f,p,d,h)}if("production"!==t.env.NODE_ENV)var u={},c=0;var s=r.bind(null,!1);return s.isRequired=r.bind(null,!0),s}function p(e){function t(t,n,r,o,i,a){var u=t[n],c=E(u);if(c!==e){var s=R(u);return new l("Invalid "+o+" `"+i+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("`"+e+"`."))}return null}return f(t)}function d(){return f(r.thatReturnsNull)}function h(e){function t(t,n,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u)){var c=E(u);return new l("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an array."))}for(var s=0;s<u.length;s++){var f=e(u,s,r,o,i+"["+s+"]",a);if(f instanceof Error)return f}return null}return f(t)}function v(){function t(t,n,r,o,i){var a=t[n];if(!e(a)){var u=E(a);return new l("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return f(t)}function y(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var a=e.name||C,u=_(t[n]);return new l("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected ")+("instance of `"+a+"`."))}return null}return f(t)}function m(e){function n(t,n,r,o,i){for(var a=t[n],u=0;u<e.length;u++)if(s(a,e[u]))return null;var c=JSON.stringify(e);return new l("Invalid "+o+" `"+i+"` of value `"+a+"` "+("supplied to `"+r+"`, expected one of "+c+"."))}return Array.isArray(e)?f(n):("production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOf, expected an instance of array."):void 0,r.thatReturnsNull)}function b(e){function t(t,n,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var u=t[n],c=E(u);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an object."));for(var s in u)if(u.hasOwnProperty(s)){var f=e(u,s,r,o,i+"."+s,a);if(f instanceof Error)return f}return null}return f(t)}function g(e){function n(t,n,r,o,i){for(var u=0;u<e.length;u++){var c=e[u];if(null==c(t,n,r,o,i,a))return null}return new l("Invalid "+o+" `"+i+"` supplied to "+("`"+r+"`."))}if(!Array.isArray(e))return"production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."):void 0,r.thatReturnsNull;for(var o=0;o<e.length;o++){var u=e[o];if("function"!=typeof u)return i(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",k(u),o),r.thatReturnsNull}return f(n)}function x(){function e(e,t,n,r,o){return T(e[t])?null:new l("Invalid "+r+" `"+o+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return f(e)}function O(e){function t(t,n,r,o,i){var u=t[n],c=E(u);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type `"+c+"` "+("supplied to `"+r+"`, expected `object`."));for(var s in e){var f=e[s];if(f){var p=f(u,s,r,o,i+"."+s,a);if(p)return p}}return null}return f(t)}function T(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(T);if(null===t||e(t))return!0;var n=c(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!T(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!T(i[1]))return!1}return!0;default:return!1}}function w(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function E(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":w(t,e)?"symbol":t}function R(e){if("undefined"==typeof e||null===e)return""+e;var t=E(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function k(e){var t=R(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}function _(e){return e.constructor&&e.constructor.name?e.constructor.name:C}var M="function"==typeof Symbol&&Symbol.iterator,j="@@iterator",C="<<anonymous>>",P={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:d(),arrayOf:h,element:v(),instanceOf:y,node:x(),objectOf:b,oneOf:m,oneOfType:g,shape:O};return l.prototype=Error.prototype,P.checkPropTypes=u,P.PropTypes=P,P}}).call(t,n(1))}])}); | ||
/*! react-rating - 0.9.0 | (c) 2015, 2017 dreyescat | MIT | https://github.com/dreyescat/react-rating */ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRating=t(require("react")):e.ReactRating=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="/lib",t(0)}([function(e,t,n){"use strict";e.exports=n(9)},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function a(){v&&d&&(v=!1,d.length?h=d.concat(h):y=-1,h.length&&u())}function u(){if(!v){var e=o(a);v=!0;for(var t=h.length;t;){for(d=h,h=[];++y<t;)d&&d[y].run();y=-1,t=h.length}d=null,v=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function c(){}var l,f,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,h=[],v=!1,y=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new s(e,t)),1!==h.length||v||o(u)},s.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=c,p.addListener=c,p.once=c,p.off=c,p.removeListener=c,p.removeAllListeners=c,p.emit=c,p.prependListener=c,p.prependOnceListener=c,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){(function(t){"use strict";function n(e,t,n,o,i,a,u,s){if(r(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,o,i,a,u,s],f=0;c=new Error(t.replace(/%s/g,function(){return l[f++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var r=function(e){};"production"!==t.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=n}).call(t,n(1))},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){(function(t){"use strict";var r=n(2),o=r;"production"!==t.env.NODE_ENV&&!function(){var e=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}};o=function(t,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!t){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e.apply(void 0,[n].concat(o))}}}(),e.exports=o}).call(t,n(1))},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},i=!0;e.exports=n(14)(o,i)}else e.exports=n(13)()}).call(t,n(1))},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=n(7),a=r(i),u=n(6),s=(r(u),function(e){return a.default.isValidElement(e)?e:"object"==typeof e&&null!==e?a.default.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?a.default.createElement("span",{className:e}):void 0}),c=function(e){var t,n=s(e.background),r=s(e.icon),i=(t={display:"inline-block",position:"absolute",overflow:"hidden",top:0},o(t,"rtl"===e.direction?"right":"left",0),o(t,"width",void 0!==e.percent?e.percent+"%":"auto"),t),u={cursor:e.onClick||e.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return a.default.createElement("span",{style:u,onClick:e.onClick,onMouseMove:e.onMouseMove,onTouchMove:e.onMouseMove,onTouchEnd:e.onClick},n,a.default.createElement("span",{style:i},r))};c.propTypes=!1,e.exports=c},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function(e,t,n){for(var r=!0;r;){var o=e,i=t,a=n;r=!1,null===o&&(o=Function.prototype);var u=Object.getOwnPropertyDescriptor(o,i);if(void 0!==u){if("value"in u)return u.value;var s=u.get;if(void 0===s)return;return s.call(a)}var c=Object.getPrototypeOf(o);if(null===c)return;e=c,t=i,n=a,r=!0,u=c=void 0}},l=n(7),f=r(l),p=n(6),d=(r(p),n(11)),h=r(d),v=n(8),y=r(v),m=function(e,t){var n=e.step,r=n>0?e.start:e.stop,o=n>0?e.stop:e.start;if(n&&r<=t&&t<=o)return(t-e.start)/n},b=function(e){function t(e){i(this,t),c(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e);var n=void 0!==e.initialRate?e.initialRate:e.placeholderRate;this.state={index:m(e,n),indexOver:void 0,direction:"ltr"},this.ratingContainer=null,this.handleClick=this.handleClick.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this)}return a(t,e),s(t,[{key:"componentDidMount",value:function(){this.setState({direction:window.getComputedStyle(this.ratingContainer,null).getPropertyValue("direction")})}},{key:"componentWillReceiveProps",value:function(e){var t=void 0!==e.initialRate?e.initialRate:e.placeholderRate;this.setState({index:m(e,t),selected:void 0!==e.initialRate})}},{key:"handleClick",value:function(e,t){if(!this.props.readonly){var n=e+this._fractionalIndex(t);this.props.onClick(this._indexToRate(n),t),this.state.index!==n&&(this.props.onChange(this._indexToRate(n)),this.setState({indexOver:void 0,index:n,selected:!0}))}}},{key:"handleMouseLeave",value:function(){this.props.readonly||(this.props.onRate(),this.setState({indexOver:void 0}))}},{key:"handleMouseMove",value:function(e,t){if(!this.props.readonly){var n=e+this._fractionalIndex(t);this.state.indexOver!==n&&(this.props.onRate(this._indexToRate(n)),this.setState({indexOver:n}))}}},{key:"_indexToRate",value:function(e){return this.props.start+Math.floor(e)*this.props.step+this.props.step*this._roundToFraction(e%1)}},{key:"_rateToIndex",value:function(e){return m(this.props,e)}},{key:"_roundToFraction",value:function(e){var t=Math.ceil(e%1*this.props.fractions)/this.props.fractions,n=Math.pow(10,this.props.scale),r=Math.floor(e)+Math.floor(t*n)/n;return r>this.props.stop?this.props.stop:r}},{key:"_fractionalIndex",value:function(e){var t=e.nativeEvent.type.indexOf("touch")>-1?e.nativeEvent.type.indexOf("touchend")>-1?e.changedTouches[0].clientX:e.touches[0].clientX:e.clientX,n="rtl"===this.state.direction?e.currentTarget.getBoundingClientRect().right-t:t-e.currentTarget.getBoundingClientRect().left;return this._roundToFraction(n/e.currentTarget.offsetWidth)}},{key:"render",value:function(){for(var e=this,t=this.props,n=(t.start,t.stop),r=(t.step,t.initialRate),i=t.placeholderRate,a=(t.empty,t.full,t.placeholder,t.readonly,t.quiet),s=(t.fractions,t.scale,t.onChange,t.onClick,t.onRate,o(t,["start","stop","step","initialRate","placeholderRate","empty","full","placeholder","readonly","quiet","fractions","scale","onChange","onClick","onRate"])),c=[],l=[].concat(this.props.empty),p=[].concat(this.props.placeholder),d=[].concat(this.props.full),h=a||void 0===this.state.indexOver?this.state.index:this.state.indexOver,v=Math.floor(h),m=this.state.selected||void 0!==r||void 0===i||!a&&void 0!==this.state.indexOver?d:p,b=0;b<Math.floor(this._rateToIndex(n));b++){var g=b-v===0?h%1*100:b-v<0?100:0;c.push(f.default.createElement(y.default,{key:b,background:l[b%l.length],icon:m[b%m.length],percent:g,onClick:this.handleClick.bind(this,b),onMouseMove:this.handleMouseMove.bind(this,b),onTouchMove:this.handleMouseMove.bind(this,b),onTouchEnd:this.handleClick.bind(this,b),direction:this.state.direction}))}return f.default.createElement("span",u({ref:function(t){e.ratingContainer=t},onMouseLeave:this.handleMouseLeave},s),c)}}]),t}(f.default.Component);b.defaultProps={start:0,stop:5,step:1,empty:h.default.empty,placeholder:h.default.placeholder,full:h.default.full,fractions:1,scale:3,onChange:function(e){},onClick:function(e){},onRate:function(e){}},b.propTypes=!1,e.exports=b},function(e,t){"use strict";e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}},function(e,t,n){"use strict";var r=n(10),o={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};e.exports={empty:r(o,{backgroundColor:"#ccc"}),full:r(o,{backgroundColor:"black"}),placeholder:r(o,{backgroundColor:"red"})}},function(e,t,n){(function(t){"use strict";function r(e,n,r,s,c){if("production"!==t.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var f;try{o("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",s||"React class",r,l),f=e[l](n,l,s,r,null,a)}catch(e){f=e}if(i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,l,typeof f),f instanceof Error&&!(f.message in u)){u[f.message]=!0;var p=c?c():"";i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(3),i=n(5),a=n(4),u={};e.exports=r}).call(t,n(1))},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(4);e.exports=function(){function e(e,t,n,r,a,u){u!==i&&o(!1,"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")}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};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){(function(t){"use strict";var r=n(2),o=n(3),i=n(5),a=n(4),u=n(12);e.exports=function(e,n){function s(e){var t=e&&(M&&e[M]||e[j]);if("function"==typeof t)return t}function c(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function l(e){this.message=e,this.stack=""}function f(e){function r(r,c,f,p,d,h,v){if(p=p||C,h=h||f,v!==a)if(n)o(!1,"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");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var y=p+":"+f;!u[y]&&s<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",h,p),u[y]=!0,s++)}return null==c[f]?r?new l(null===c[f]?"The "+d+" `"+h+"` is marked as required "+("in `"+p+"`, but its value is `null`."):"The "+d+" `"+h+"` is marked as required in "+("`"+p+"`, but its value is `undefined`.")):null:e(c,f,p,d,h)}if("production"!==t.env.NODE_ENV)var u={},s=0;var c=r.bind(null,!1);return c.isRequired=r.bind(null,!0),c}function p(e){function t(t,n,r,o,i,a){var u=t[n],s=E(u);if(s!==e){var c=R(u);return new l("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected ")+("`"+e+"`."))}return null}return f(t)}function d(){return f(r.thatReturnsNull)}function h(e){function t(t,n,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u)){var s=E(u);return new l("Invalid "+o+" `"+i+"` of type "+("`"+s+"` supplied to `"+r+"`, expected an array."))}for(var c=0;c<u.length;c++){var f=e(u,c,r,o,i+"["+c+"]",a);if(f instanceof Error)return f}return null}return f(t)}function v(){function t(t,n,r,o,i){var a=t[n];if(!e(a)){var u=E(a);return new l("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return f(t)}function y(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var a=e.name||C,u=_(t[n]);return new l("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected ")+("instance of `"+a+"`."))}return null}return f(t)}function m(e){function n(t,n,r,o,i){for(var a=t[n],u=0;u<e.length;u++)if(c(a,e[u]))return null;var s=JSON.stringify(e);return new l("Invalid "+o+" `"+i+"` of value `"+a+"` "+("supplied to `"+r+"`, expected one of "+s+"."))}return Array.isArray(e)?f(n):("production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOf, expected an instance of array."):void 0,r.thatReturnsNull)}function b(e){function t(t,n,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var u=t[n],s=E(u);if("object"!==s)return new l("Invalid "+o+" `"+i+"` of type "+("`"+s+"` supplied to `"+r+"`, expected an object."));for(var c in u)if(u.hasOwnProperty(c)){var f=e(u,c,r,o,i+"."+c,a);if(f instanceof Error)return f}return null}return f(t)}function g(e){function n(t,n,r,o,i){for(var u=0;u<e.length;u++){var s=e[u];if(null==s(t,n,r,o,i,a))return null}return new l("Invalid "+o+" `"+i+"` supplied to "+("`"+r+"`."))}if(!Array.isArray(e))return"production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."):void 0,r.thatReturnsNull;for(var o=0;o<e.length;o++){var u=e[o];if("function"!=typeof u)return i(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",k(u),o),r.thatReturnsNull}return f(n)}function x(){function e(e,t,n,r,o){return T(e[t])?null:new l("Invalid "+r+" `"+o+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return f(e)}function O(e){function t(t,n,r,o,i){var u=t[n],s=E(u);if("object"!==s)return new l("Invalid "+o+" `"+i+"` of type `"+s+"` "+("supplied to `"+r+"`, expected `object`."));for(var c in e){var f=e[c];if(f){var p=f(u,c,r,o,i+"."+c,a);if(p)return p}}return null}return f(t)}function T(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(T);if(null===t||e(t))return!0;var n=s(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!T(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!T(i[1]))return!1}return!0;default:return!1}}function w(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function E(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":w(t,e)?"symbol":t}function R(e){if("undefined"==typeof e||null===e)return""+e;var t=E(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function k(e){var t=R(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}function _(e){return e.constructor&&e.constructor.name?e.constructor.name:C}var M="function"==typeof Symbol&&Symbol.iterator,j="@@iterator",C="<<anonymous>>",P={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:d(),arrayOf:h,element:v(),instanceOf:y,node:x(),objectOf:b,oneOf:m,oneOfType:g,shape:O};return l.prototype=Error.prototype,P.checkPropTypes=u,P.PropTypes=P,P}}).call(t,n(1))}])}); |
{ | ||
"name": "react-rating", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "A rating react component with custom symbols", | ||
@@ -17,3 +17,2 @@ "main": "lib/react-rating.js", | ||
"build": "cross-env BUILD_DEV=1 webpack --progress && webpack -p --output-filename react-rating.min.js --progress", | ||
"preversion": "npm test", | ||
"version": "npm run build && git add -A lib", | ||
@@ -53,5 +52,5 @@ "postversion": "git push && git push --tags", | ||
"cross-env": "^3.2.4", | ||
"eslint": "^3.19.0", | ||
"eslint": "^4.7.2", | ||
"eslint-loader": "^1.7.1", | ||
"eslint-plugin-react": "^6.10.3", | ||
"eslint-plugin-react": "^7.4.0", | ||
"font-awesome": "^4.3.0", | ||
@@ -62,4 +61,4 @@ "mocha": "^2.2.5", | ||
"prop-types": "^15.5.8", | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"webpack": "^1.10.1", | ||
@@ -66,0 +65,0 @@ "webpack-dev-server": "^1.10.1" |
@@ -44,6 +44,7 @@ 'use strict'; | ||
<span style={style} | ||
onClick={props.onClick} | ||
onMouseMove={props.onMouseMove} | ||
onTouchMove={props.onMouseMove} | ||
onTouchEnd={props.onClick}> | ||
onClick={props.onClick} | ||
onMouseMove={props.onMouseMove} | ||
onTouchMove={props.onMouseMove} | ||
onTouchEnd={props.onClick} | ||
> | ||
{backgroundNode} | ||
@@ -50,0 +51,0 @@ <span style={iconContainerStyle}> |
@@ -61,2 +61,5 @@ 'use strict'; | ||
handleClick(i, event) { | ||
if (this.props.readonly) { | ||
return | ||
} | ||
const index = i + this._fractionalIndex(event); | ||
@@ -75,2 +78,5 @@ this.props.onClick(this._indexToRate(index), event); | ||
handleMouseLeave() { | ||
if (this.props.readonly) { | ||
return | ||
} | ||
this.props.onRate(); | ||
@@ -83,2 +89,5 @@ this.setState({ | ||
handleMouseMove(i, event) { | ||
if (this.props.readonly) { | ||
return | ||
} | ||
const index = i + this._fractionalIndex(event); | ||
@@ -121,4 +130,4 @@ if (this.state.indexOver !== index) { | ||
const x = this.state.direction === 'rtl' ? | ||
event.currentTarget.getBoundingClientRect().right - clientX : | ||
clientX - event.currentTarget.getBoundingClientRect().left; | ||
event.currentTarget.getBoundingClientRect().right - clientX : | ||
clientX - event.currentTarget.getBoundingClientRect().left; | ||
return this._roundToFraction(x / event.currentTarget.offsetWidth); | ||
@@ -171,3 +180,4 @@ } | ||
symbolNodes.push(<Symbol | ||
symbolNodes.push( | ||
<Symbol | ||
key={i} | ||
@@ -177,8 +187,9 @@ background={emptySymbols[i % emptySymbols.length]} | ||
percent={percent} | ||
onClick={!readonly && this.handleClick.bind(this, i)} | ||
onMouseMove={!readonly && this.handleMouseMove.bind(this, i)} | ||
onTouchMove={!readonly && this.handleMouseMove.bind(this, i)} | ||
onTouchEnd={!readonly && this.handleClick.bind(this, i)} | ||
onClick={this.handleClick.bind(this, i)} | ||
onMouseMove={this.handleMouseMove.bind(this, i)} | ||
onTouchMove={this.handleMouseMove.bind(this, i)} | ||
onTouchEnd={this.handleClick.bind(this, i)} | ||
direction={this.state.direction} | ||
/>); | ||
/> | ||
); | ||
} | ||
@@ -191,3 +202,3 @@ | ||
}} | ||
onMouseLeave={!readonly && this.handleMouseLeave} | ||
onMouseLeave={this.handleMouseLeave} | ||
{...other} | ||
@@ -194,0 +205,0 @@ > |
90466
1712