react-rating
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,3 +0,3 @@ | ||
/*! react-rating - 1.1.0 | (c) 2015, 2018 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(10)},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(s===setTimeout)return setTimeout(e,0);if((s===n||!s)&&setTimeout)return s=setTimeout,setTimeout(e,0);try{return s(e,0)}catch(t){try{return s.call(null,e,0)}catch(t){return s.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?y=d.concat(y):h=-1,y.length&&u())}function u(){if(!v){var e=o(a);v=!0;for(var t=y.length;t;){for(d=y,y=[];++h<t;)d&&d[h].run();h=-1,t=y.length}d=null,v=!1,i(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var s,f,p=e.exports={};!function(){try{s="function"==typeof setTimeout?setTimeout:n}catch(e){s=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,y=[],v=!1,h=-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];y.push(new l(e,t)),1!==y.length||v||o(u)},l.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,l){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 s=[n,o,i,a,u,l],f=0;c=new Error(t.replace(/%s/g,function(){return s[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,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(17)(o,i)}else e.exports=n(16)()}).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(t,n){t.exports=e},function(e,t){"use strict";function n(){}Object.defineProperty(t,"__esModule",{value:!0}),n._name="react_rating_noop",t.default=n,e.exports=t.default},function(e,t,n){(function(t){"use strict";var r=n(2),o=r;if("production"!==t.env.NODE_ENV){var i=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(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];i.apply(void 0,[t].concat(r))}}}e.exports=o}).call(t,n(1))},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=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}}(),u=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 l=u.get;if(void 0===l)return;return l.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(6),c=r(l),s=n(4),f=(r(s),n(7)),p=r(f),d=n(11),y=r(d),v=function(e){function t(e){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),this.state={displayValue:this.props.value,interacting:!1,dirty:!1},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.symbolMouseMove=this.symbolMouseMove.bind(this),this.symbolClick=this.symbolClick.bind(this)}return i(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){var t=this.props.value!==e.value;this.setState(function(n){return{dirty:t||n.dirty,displayValue:t?e.value:n.displayValue}})}},{key:"componentDidUpdate",value:function(e,t){t.displayValue!==this.state.displayValue&&this.state.interacting&&this.props.onHover(this.state.displayValue)}},{key:"symbolClick",value:function(e,t){var n=this.calculateDisplayValue(e,t);this.props.onClick(n,t)}},{key:"symbolMouseMove",value:function(e,t){var n=this.calculateDisplayValue(e,t);n!==this.state.displayValue&&this.setState({displayValue:n})}},{key:"onMouseEnter",value:function(){this.setState({interacting:!this.props.readonly})}},{key:"onMouseLeave",value:function(){this.setState({displayValue:this.props.value,interacting:!1})}},{key:"calculateDisplayValue",value:function(e,t){var n=this.calculateHoverPercentage(t),r=Math.ceil(n%1*this.props.fractions)/this.props.fractions,o=Math.pow(10,3),i=e+(Math.floor(n)+Math.floor(r*o)/o);return i>0?i:1/this.props.fractions}},{key:"calculateHoverPercentage",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=e.target.getBoundingClientRect(),r="rtl"===this.props.direction?n.right-t:t-n.left;return r<0?0:r/n.width}},{key:"render",value:function(){var e=this.props,t=e.readonly,n=e.quiet,r=e.totalSymbols,o=e.value,i=e.placeholderValue,a=e.direction,u=e.emptySymbol,l=e.fullSymbol,s=e.placeholderSymbol,f=this.state,d=f.displayValue,v=f.interacting,h=[],b=[].concat(u),m=[].concat(l),g=[].concat(s),O=0!==i&&0===o&&!v,w=void 0;w=O?i:n?o:d;for(var j=Math.floor(w),T=0;T<r;T++){var k=void 0;k=T-j<0?100:T-j===0?100*(w-T):0,h.push(c.default.createElement(y.default,{key:T,index:T,readonly:t,inactiveIcon:b[T%b.length],activeIcon:O?g[T%m.length]:m[T%m.length],percent:k,onClick:t?p.default:this.symbolClick,onMouseMove:t?p.default:this.symbolMouseMove,onTouchMove:t?p.default:this.symbolMouseMove,onTouchEnd:t?p.default:this.symbolClick,direction:a}))}return c.default.createElement("span",{style:{display:"inline-block",direction:a},onMouseEnter:t?p.default:this.onMouseEnter,onMouseLeave:t?p.default:this.onMouseLeave},h)}}]),t}(c.default.PureComponent);v.propTypes=!1,t.default=v,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=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}}(),u=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 l=u.get;if(void 0===l)return;return l.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(6),c=r(l),s=n(4),f=(r(s),n(13)),p=r(f),d=n(9),y=r(d),v=n(7),h=r(v),b=function(e){function t(e){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),this.state={value:e.initialRating},this.handleClick=this.handleClick.bind(this),this.handleHover=this.handleHover.bind(this)}return i(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){this.setState({value:e.initialRating})}},{key:"componentDidUpdate",value:function(e,t){this.state.value!==t.value&&this.props.onChange(this.state.value)}},{key:"handleClick",value:function(e,t){var n=this.translateDisplayValueToValue(e);this.state.value!==n&&this.setState({value:n})}},{key:"handleHover",value:function(e){var t=void 0===e?e:this.translateDisplayValueToValue(e);this.props.onHover(t)}},{key:"translateDisplayValueToValue",value:function(e){var t=e*this.props.step+this.props.start;return t===this.props.start?t+1/this.props.fractions:t}},{key:"tranlateValueToDisplayValue",value:function(e){return void 0===e?0:(e-this.props.start)/this.props.step}},{key:"render",value:function(){function e(e,t,n){return Math.floor((t-e)/n)}var t=this.props,n=t.step,r=t.emptySymbol,o=t.fullSymbol,i=t.placeholderSymbol,a=t.readonly,u=t.quiet,l=t.fractions,s=t.direction,f=t.start,p=t.stop;return c.default.createElement(y.default,{totalSymbols:e(f,p,n),value:this.tranlateValueToDisplayValue(this.state.value),placeholderValue:this.tranlateValueToDisplayValue(this.props.placeholderRating),readonly:a,quiet:u,fractions:l,direction:s,emptySymbol:r,fullSymbol:o,placeholderSymbol:i,onClick:this.handleClick,onHover:this.handleHover})}}]),t}(c.default.PureComponent);b.defaultProps={start:0,stop:5,step:1,readonly:!1,quiet:!1,fractions:1,direction:"ltr",onChange:h.default,onHover:h.default,emptySymbol:p.default.empty,fullSymbol:p.default.full,placeholderSymbol:p.default.placeholder},b.propTypes=!1,t.default=b,e.exports=t.default},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}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)}Object.defineProperty(t,"__esModule",{value:!0});var u=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}}(),l=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 l=u.get;if(void 0===l)return;return l.call(a)}var c=Object.getPrototypeOf(o);if(null===c)return;e=c,t=i,n=a,r=!0,u=c=void 0}},c=n(6),s=r(c),f=n(4),p=(r(f),function(e){return s.default.isValidElement(e)?e:"object"==typeof e&&null!==e?s.default.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?s.default.createElement("span",{className:e}):void 0}),d=function(e){function t(){i(this,t),l(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return a(t,e),u(t,[{key:"render",value:function(){function e(e){y&&y(i,e)}function t(e){d&&(e.preventDefault(),d(i,e))}var n,r=this.props,i=r.index,a=r.inactiveIcon,u=r.activeIcon,l=r.percent,c=r.direction,f=r.readonly,d=r.onClick,y=r.onMouseMove,v=p(a),h=p(u),b=(n={display:"inline-block",position:"absolute",overflow:"hidden",top:0},o(n,"rtl"===c?"right":"left",0),o(n,"width",l+"%"),n),m={cursor:f?"auto":"pointer",display:"inline-block",position:"relative"};return s.default.createElement("span",{style:m,onClick:t,onMouseMove:e,onTouchMove:e,onTouchEnd:t},v,s.default.createElement("span",{style:b},h))}}]),t}(s.default.PureComponent);d.propTypes=!1,t.default=d,e.exports=t.default},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(12),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){/* | ||
/*! react-rating - 1.1.1 | (c) 2015, 2018 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(10)},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(s===setTimeout)return setTimeout(e,0);if((s===n||!s)&&setTimeout)return s=setTimeout,setTimeout(e,0);try{return s(e,0)}catch(t){try{return s.call(null,e,0)}catch(t){return s.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?y=d.concat(y):h=-1,y.length&&u())}function u(){if(!v){var e=o(a);v=!0;for(var t=y.length;t;){for(d=y,y=[];++h<t;)d&&d[h].run();h=-1,t=y.length}d=null,v=!1,i(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var s,f,p=e.exports={};!function(){try{s="function"==typeof setTimeout?setTimeout:n}catch(e){s=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,y=[],v=!1,h=-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];y.push(new l(e,t)),1!==y.length||v||o(u)},l.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,l){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 s=[n,o,i,a,u,l],f=0;c=new Error(t.replace(/%s/g,function(){return s[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,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(17)(o,i)}else e.exports=n(16)()}).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(t,n){t.exports=e},function(e,t){"use strict";function n(){}Object.defineProperty(t,"__esModule",{value:!0}),n._name="react_rating_noop",t.default=n,e.exports=t.default},function(e,t,n){(function(t){"use strict";var r=n(2),o=r;if("production"!==t.env.NODE_ENV){var i=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(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];i.apply(void 0,[t].concat(r))}}}e.exports=o}).call(t,n(1))},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=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}}(),u=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 l=u.get;if(void 0===l)return;return l.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(6),c=r(l),s=n(4),f=(r(s),n(7)),p=r(f),d=n(11),y=r(d),v=function(e){function t(e){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),this.state={displayValue:this.props.value,interacting:!1,dirty:!1},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.symbolMouseMove=this.symbolMouseMove.bind(this),this.symbolClick=this.symbolClick.bind(this)}return i(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){var t=this.props.value!==e.value;this.setState(function(n){return{dirty:t||n.dirty,displayValue:t?e.value:n.displayValue}})}},{key:"componentDidUpdate",value:function(e,t){t.displayValue!==this.state.displayValue&&this.state.interacting&&this.props.onHover(this.state.displayValue),t.interacting&&!this.state.interacting&&this.props.onHover()}},{key:"symbolClick",value:function(e,t){var n=this.calculateDisplayValue(e,t);this.props.onClick(n,t)}},{key:"symbolMouseMove",value:function(e,t){var n=this.calculateDisplayValue(e,t);n!==this.state.displayValue&&this.setState({displayValue:n})}},{key:"onMouseEnter",value:function(){this.setState({interacting:!this.props.readonly})}},{key:"onMouseLeave",value:function(){this.setState({displayValue:this.props.value,interacting:!1})}},{key:"calculateDisplayValue",value:function(e,t){var n=this.calculateHoverPercentage(t),r=Math.ceil(n%1*this.props.fractions)/this.props.fractions,o=Math.pow(10,3),i=e+(Math.floor(n)+Math.floor(r*o)/o);return i>0?i:1/this.props.fractions}},{key:"calculateHoverPercentage",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=e.target.getBoundingClientRect(),r="rtl"===this.props.direction?n.right-t:t-n.left;return r<0?0:r/n.width}},{key:"render",value:function(){var e=this.props,t=e.readonly,n=e.quiet,r=e.totalSymbols,o=e.value,i=e.placeholderValue,a=e.direction,u=e.emptySymbol,l=e.fullSymbol,s=e.placeholderSymbol,f=this.state,d=f.displayValue,v=f.interacting,h=[],b=[].concat(u),m=[].concat(l),g=[].concat(s),O=0!==i&&0===o&&!v,w=void 0;w=O?i:n?o:d;for(var j=Math.floor(w),T=0;T<r;T++){var k=void 0;k=T-j<0?100:T-j===0?100*(w-T):0,h.push(c.default.createElement(y.default,{key:T,index:T,readonly:t,inactiveIcon:b[T%b.length],activeIcon:O?g[T%m.length]:m[T%m.length],percent:k,onClick:t?p.default:this.symbolClick,onMouseMove:t?p.default:this.symbolMouseMove,onTouchMove:t?p.default:this.symbolMouseMove,onTouchEnd:t?p.default:this.symbolClick,direction:a}))}return c.default.createElement("span",{style:{display:"inline-block",direction:a},onMouseEnter:t?p.default:this.onMouseEnter,onMouseLeave:t?p.default:this.onMouseLeave},h)}}]),t}(c.default.PureComponent);v.propTypes=!1,t.default=v,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=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}}(),u=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 l=u.get;if(void 0===l)return;return l.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(6),c=r(l),s=n(4),f=(r(s),n(13)),p=r(f),d=n(9),y=r(d),v=n(7),h=r(v),b=function(e){function t(e){o(this,t),u(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),this.state={value:e.initialRating},this.handleClick=this.handleClick.bind(this),this.handleHover=this.handleHover.bind(this)}return i(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){this.setState({value:e.initialRating})}},{key:"componentDidUpdate",value:function(e,t){this.state.value!==t.value&&this.props.onChange(this.state.value)}},{key:"handleClick",value:function(e,t){var n=this.translateDisplayValueToValue(e);this.state.value!==n&&this.setState({value:n})}},{key:"handleHover",value:function(e){var t=void 0===e?e:this.translateDisplayValueToValue(e);this.props.onHover(t)}},{key:"translateDisplayValueToValue",value:function(e){var t=e*this.props.step+this.props.start;return t===this.props.start?t+1/this.props.fractions:t}},{key:"tranlateValueToDisplayValue",value:function(e){return void 0===e?0:(e-this.props.start)/this.props.step}},{key:"render",value:function(){function e(e,t,n){return Math.floor((t-e)/n)}var t=this.props,n=t.step,r=t.emptySymbol,o=t.fullSymbol,i=t.placeholderSymbol,a=t.readonly,u=t.quiet,l=t.fractions,s=t.direction,f=t.start,p=t.stop;return c.default.createElement(y.default,{totalSymbols:e(f,p,n),value:this.tranlateValueToDisplayValue(this.state.value),placeholderValue:this.tranlateValueToDisplayValue(this.props.placeholderRating),readonly:a,quiet:u,fractions:l,direction:s,emptySymbol:r,fullSymbol:o,placeholderSymbol:i,onClick:this.handleClick,onHover:this.handleHover})}}]),t}(c.default.PureComponent);b.defaultProps={start:0,stop:5,step:1,readonly:!1,quiet:!1,fractions:1,direction:"ltr",onChange:h.default,onHover:h.default,emptySymbol:p.default.empty,fullSymbol:p.default.full,placeholderSymbol:p.default.placeholder},b.propTypes=!1,t.default=b,e.exports=t.default},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}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)}Object.defineProperty(t,"__esModule",{value:!0});var u=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}}(),l=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 l=u.get;if(void 0===l)return;return l.call(a)}var c=Object.getPrototypeOf(o);if(null===c)return;e=c,t=i,n=a,r=!0,u=c=void 0}},c=n(6),s=r(c),f=n(4),p=(r(f),function(e){return s.default.isValidElement(e)?e:"object"==typeof e&&null!==e?s.default.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?s.default.createElement("span",{className:e}):void 0}),d=function(e){function t(){i(this,t),l(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return a(t,e),u(t,[{key:"render",value:function(){function e(e){y&&y(i,e)}function t(e){d&&(e.preventDefault(),d(i,e))}var n,r=this.props,i=r.index,a=r.inactiveIcon,u=r.activeIcon,l=r.percent,c=r.direction,f=r.readonly,d=r.onClick,y=r.onMouseMove,v=p(a),h=p(u),b=(n={display:"inline-block",position:"absolute",overflow:"hidden",top:0},o(n,"rtl"===c?"right":"left",0),o(n,"width",l+"%"),n),m={cursor:f?"auto":"pointer",display:"inline-block",position:"relative"};return s.default.createElement("span",{style:m,onClick:t,onMouseMove:e,onTouchMove:e,onTouchEnd:t},v,s.default.createElement("span",{style:b},h))}}]),t}(s.default.PureComponent);d.propTypes=!1,t.default=d,e.exports=t.default},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(12),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){/* | ||
object-assign | ||
@@ -4,0 +4,0 @@ (c) Sindre Sorhus |
{ | ||
"name": "react-rating", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A rating react component with custom symbols", | ||
@@ -5,0 +5,0 @@ "main": "lib/react-rating.js", |
@@ -79,3 +79,3 @@ [![npm version](https://badge.fury.io/js/react-rating.svg)](https://badge.fury.io/js/react-rating) | ||
`onChange` | function (value) {} | Gets called with the `value` when you click on a different value than the currently set one. | ||
`onHover` | function (value) {} | Gets called with the `value` when you hover over a symbol. The value is equal to the value that corresponds to that part of the symbol. Gets called in `quiet` mode too. | ||
`onHover` | function (value) {} | Gets called with the `value` when you hover over a symbol. The value is equal to the value that corresponds to that part of the symbol. Gets called in `quiet` mode too. When hover ends, gets called with no `value` (i.e. `undefined` as the value). | ||
@@ -82,0 +82,0 @@ ## Deprecated Properties and Callbacks |
@@ -37,2 +37,6 @@ import React from 'react'; | ||
} | ||
// When hover ends, call this.props.onHover with no value. | ||
if (prevState.interacting && !this.state.interacting) { | ||
this.props.onHover(); | ||
} | ||
} | ||
@@ -39,0 +43,0 @@ |
Sorry, the diff of this file is too big to display
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
372489
17
2260
1