react-rating
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -1,3 +0,3 @@ | ||
/*! react-rating - 1.3.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)}(window,function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},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="/lib",n(n.s=3)}([function(e,t,n){e.exports=n(4)()},function(t,n){t.exports=e},function(e,t,n){"use strict";var o=n(8),r={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};e.exports={empty:o(r,{backgroundColor:"#ccc"}),full:o(r,{backgroundColor:"black"}),placeholder:o(r,{backgroundColor:"red"})}},function(e,t,n){e.exports=n(9)},function(e,t,n){"use strict";var o=n(5),r=n(6),i=n(7);e.exports=function(){function e(e,t,n,o,a,l){l!==i&&r(!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,exact:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t,n){"use strict";function o(e){return function(){return e}}var r=function(){};r.thatReturns=o,r.thatReturnsFalse=o(!1),r.thatReturnsTrue=o(!0),r.thatReturnsNull=o(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var o=function(e){};e.exports=function(e,t,n,r,i,a,l,u){if(o(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,r,i,a,l,u],p=0;(c=new Error(t.replace(/%s/g,function(){return s[p++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}},function(e,t,n){"use strict";n.r(t);var o=n(1),r=n.n(o),i=(n(0),n(2)),a=n.n(i);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function c(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}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 f(e){return(f="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)}var y=function(e){return r.a.isValidElement(e)?e:"object"===f(e)&&null!==e?r.a.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?r.a.createElement("span",{className:e}):void 0},b=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,s(t).apply(this,arguments))}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,r.a.PureComponent),function(e,t,n){t&&u(e.prototype,t),n&&u(e,n)}(t,[{key:"render",value:function(){var e,t=this.props,n=t.index,o=t.inactiveIcon,i=t.activeIcon,a=t.percent,u=t.direction,c=t.readonly,s=t.onClick,p=t.onMouseMove,f=y(o),b=y(i),h=(l(e={display:"inline-block",position:"absolute",overflow:"hidden",top:0},"rtl"===u?"right":"left",0),l(e,"width","".concat(a,"%")),e),d={cursor:c?"inherit":"pointer",display:"inline-block",position:"relative"};function v(e){p&&p(n,e)}function m(e){s&&(e.preventDefault(),s(n,e))}return r.a.createElement("span",{style:d,onClick:m,onMouseMove:v,onTouchMove:v,onTouchEnd:m},f,r.a.createElement("span",{style:h},b))}}]),t}();b.propTypes=!1;var h=b;function d(e){return(d="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 v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(){return(m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function g(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var j=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?k(e):t}(this,O(t).call(this,e))).state={displayValue:n.props.value,interacting:!1,dirty:!1},n.onMouseEnter=n.onMouseEnter.bind(k(k(n))),n.onMouseLeave=n.onMouseLeave.bind(k(k(n))),n.symbolMouseMove=n.symbolMouseMove.bind(k(k(n))),n.symbolClick=n.symbolClick.bind(k(k(n))),n}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&&S(e,t)}(t,r.a.PureComponent),function(e,t,n){t&&g(e.prototype,t),n&&g(e,n)}(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),o=Math.ceil(n%1*this.props.fractions)/this.props.fractions,r=Math.pow(10,3),i=e+(Math.floor(n)+Math.floor(o*r)/r);return i>0?i>this.props.totalSymbols?this.props.totalSymbols: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(),o="rtl"===this.props.direction?n.right-t:t-n.left;return o<0?0:o/n.width}},{key:"render",value:function(){var e,t=this.props,n=t.readonly,o=t.quiet,i=t.totalSymbols,a=t.value,l=t.placeholderValue,u=t.direction,c=t.emptySymbol,s=t.fullSymbol,p=t.placeholderSymbol,f=t.className,y=t.id,b=t.style,d=t.tabIndex,g=this.state,O=g.displayValue,S=g.interacting,k=[],j=[].concat(c),w=[].concat(s),_=[].concat(p),P=0!==l&&0===a&&!S;e=P?l:o?a:O;for(var M=Math.floor(e),T=0;T<i;T++){var E=void 0;E=T-M<0?100:T-M==0?100*(e-T):0,k.push(r.a.createElement(h,m({key:T,index:T,readonly:n,inactiveIcon:j[T%j.length],activeIcon:P?_[T%w.length]:w[T%w.length],percent:E,direction:u},!n&&{onClick:this.symbolClick,onMouseMove:this.symbolMouseMove,onTouchMove:this.symbolMouseMove,onTouchEnd:this.symbolClick})))}return r.a.createElement("span",m({id:y,style:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){v(e,t,n[t])})}return e}({},b,{display:"inline-block",direction:u}),className:f,tabIndex:d,"aria-label":this.props["aria-label"]},!n&&{onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave}),k)}}]),t}();j.propTypes=!1;var w=j;function _(){}_._name="react_rating_noop";var P=_;function M(e){return(M="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 T(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function V(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var C=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t){return!t||"object"!==M(t)&&"function"!=typeof t?V(e):t}(this,E(t).call(this,e))).state={value:e.initialRating},n.handleClick=n.handleClick.bind(V(V(n))),n.handleHover=n.handleHover.bind(V(V(n))),n}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&&x(e,t)}(t,r.a.PureComponent),function(e,t,n){t&&T(e.prototype,t),n&&T(e,n)}(t,[{key:"componentWillReceiveProps",value:function(e){this.setState({value:e.initialRating})}},{key:"handleClick",value:function(e,t){var n=this,o=this.translateDisplayValueToValue(e);this.state.value!==o&&this.setState({value:o},function(){return n.props.onChange(n.state.value)})}},{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(){var e=this.props,t=e.step,n=e.emptySymbol,o=e.fullSymbol,i=e.placeholderSymbol,a=e.readonly,l=e.quiet,u=e.fractions,c=e.direction,s=e.start,p=e.stop,f=e.id,y=e.className,b=e.style,h=e.tabIndex;return r.a.createElement(w,{id:f,style:b,className:y,tabIndex:h,"aria-label":this.props["aria-label"],totalSymbols:function(e,t,n){return Math.floor((t-e)/n)}(s,p,t),value:this.tranlateValueToDisplayValue(this.state.value),placeholderValue:this.tranlateValueToDisplayValue(this.props.placeholderRating),readonly:a,quiet:l,fractions:u,direction:c,emptySymbol:n,fullSymbol:o,placeholderSymbol:i,onClick:this.handleClick,onHover:this.handleHover})}}]),t}();C.defaultProps={start:0,stop:5,step:1,readonly:!1,quiet:!1,fractions:1,direction:"ltr",onChange:P,onHover:P,emptySymbol:a.a.empty,fullSymbol:a.a.full,placeholderSymbol:a.a.placeholder},C.propTypes=!1;t.default=C}])}); | ||
/*! react-rating - 1.3.2 | (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)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},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="/lib",n(n.s=3)}([function(e,t,n){e.exports=n(4)()},function(t,n){t.exports=e},function(e,t,n){"use strict";var o=n(8),r={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};e.exports={empty:o(r,{backgroundColor:"#ccc"}),full:o(r,{backgroundColor:"black"}),placeholder:o(r,{backgroundColor:"red"})}},function(e,t,n){e.exports=n(9)},function(e,t,n){"use strict";var o=n(5),r=n(6),i=n(7);e.exports=function(){function e(e,t,n,o,a,l){l!==i&&r(!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,exact:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t,n){"use strict";function o(e){return function(){return e}}var r=function(){};r.thatReturns=o,r.thatReturnsFalse=o(!1),r.thatReturnsTrue=o(!0),r.thatReturnsNull=o(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var o=function(e){};e.exports=function(e,t,n,r,i,a,l,u){if(o(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,r,i,a,l,u],p=0;(c=new Error(t.replace(/%s/g,function(){return s[p++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}},function(e,t,n){"use strict";n.r(t);var o=n(1),r=n.n(o),i=(n(0),n(2)),a=n.n(i);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function c(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}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 f(e){return(f="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)}var y=function(e){return r.a.isValidElement(e)?e:"object"===f(e)&&null!==e?r.a.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?r.a.createElement("span",{className:e}):void 0},b=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,s(t).apply(this,arguments))}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,r.a.PureComponent),function(e,t,n){t&&u(e.prototype,t),n&&u(e,n)}(t,[{key:"render",value:function(){var e,t=this.props,n=t.index,o=t.inactiveIcon,i=t.activeIcon,a=t.percent,u=t.direction,c=t.readonly,s=t.onClick,p=t.onMouseMove,f=y(o),b=y(i),h=(l(e={display:"inline-block",position:"absolute",overflow:"hidden",top:0},"rtl"===u?"right":"left",0),l(e,"width","".concat(a,"%")),e),d={cursor:c?"inherit":"pointer",display:"inline-block",position:"relative"};function v(e){p&&p(n,e)}function m(e){s&&(e.preventDefault(),s(n,e))}return r.a.createElement("span",{style:d,onClick:m,onMouseMove:v,onTouchMove:v,onTouchEnd:m},f,r.a.createElement("span",{style:h},b))}}]),t}();b.propTypes=!1;var h=b;function d(e){return(d="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 v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(){return(m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function g(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var j=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?k(e):t}(this,O(t).call(this,e))).state={displayValue:n.props.value,interacting:!1,dirty:!1},n.onMouseEnter=n.onMouseEnter.bind(k(k(n))),n.onMouseLeave=n.onMouseLeave.bind(k(k(n))),n.symbolMouseMove=n.symbolMouseMove.bind(k(k(n))),n.symbolClick=n.symbolClick.bind(k(k(n))),n}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&&S(e,t)}(t,r.a.PureComponent),function(e,t,n){t&&g(e.prototype,t),n&&g(e,n)}(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),o=Math.ceil(n%1*this.props.fractions)/this.props.fractions,r=Math.pow(10,3),i=e+(Math.floor(n)+Math.floor(o*r)/r);return i>0?i>this.props.totalSymbols?this.props.totalSymbols: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(),o="rtl"===this.props.direction?n.right-t:t-n.left;return o<0?0:o/n.width}},{key:"render",value:function(){var e,t=this.props,n=t.readonly,o=t.quiet,i=t.totalSymbols,a=t.value,l=t.placeholderValue,u=t.direction,c=t.emptySymbol,s=t.fullSymbol,p=t.placeholderSymbol,f=t.className,y=t.id,b=t.style,d=t.tabIndex,g=this.state,O=g.displayValue,S=g.interacting,k=[],j=[].concat(c),_=[].concat(s),w=[].concat(p),P=0!==l&&0===a&&!S;e=P?l:o?a:O;for(var M=Math.floor(e),T=0;T<i;T++){var E=void 0;E=T-M<0?100:T-M==0?100*(e-T):0,k.push(r.a.createElement(h,m({key:T,index:T,readonly:n,inactiveIcon:j[T%j.length],activeIcon:P?w[T%_.length]:_[T%_.length],percent:E,direction:u},!n&&{onClick:this.symbolClick,onMouseMove:this.symbolMouseMove,onTouchMove:this.symbolMouseMove,onTouchEnd:this.symbolClick})))}return r.a.createElement("span",m({id:y,style:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){v(e,t,n[t])})}return e}({},b,{display:"inline-block",direction:u}),className:f,tabIndex:d,"aria-label":this.props["aria-label"]},!n&&{onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave}),k)}}]),t}();j.propTypes=!1;var _=j;function w(){}w._name="react_rating_noop";var P=w;function M(e){return(M="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 T(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function V(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var C=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=function(e,t){return!t||"object"!==M(t)&&"function"!=typeof t?V(e):t}(this,E(t).call(this,e))).state={value:e.initialRating},n.handleClick=n.handleClick.bind(V(V(n))),n.handleHover=n.handleHover.bind(V(V(n))),n}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&&x(e,t)}(t,r.a.PureComponent),function(e,t,n){t&&T(e.prototype,t),n&&T(e,n)}(t,[{key:"componentWillReceiveProps",value:function(e){this.setState({value:e.initialRating})}},{key:"handleClick",value:function(e,t){var n=this,o=this.translateDisplayValueToValue(e);this.state.value!==o&&this.setState({value:o},function(){return n.props.onChange(n.state.value)})}},{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(){var e=this.props,t=e.step,n=e.emptySymbol,o=e.fullSymbol,i=e.placeholderSymbol,a=e.readonly,l=e.quiet,u=e.fractions,c=e.direction,s=e.start,p=e.stop,f=e.id,y=e.className,b=e.style,h=e.tabIndex;return r.a.createElement(_,{id:f,style:b,className:y,tabIndex:h,"aria-label":this.props["aria-label"],totalSymbols:function(e,t,n){return Math.floor((t-e)/n)}(s,p,t),value:this.tranlateValueToDisplayValue(this.state.value),placeholderValue:this.tranlateValueToDisplayValue(this.props.placeholderRating),readonly:a,quiet:l,fractions:u,direction:c,emptySymbol:n,fullSymbol:o,placeholderSymbol:i,onClick:this.handleClick,onHover:this.handleHover})}}]),t}();C.defaultProps={start:0,stop:5,step:1,readonly:!1,quiet:!1,fractions:1,direction:"ltr",onChange:P,onHover:P,emptySymbol:a.a.empty,fullSymbol:a.a.full,placeholderSymbol:a.a.placeholder},C.propTypes=!1;t.default=C}])}); | ||
//# sourceMappingURL=react-rating.min.js.map |
{ | ||
"name": "react-rating", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "A rating react component with custom symbols", | ||
@@ -5,0 +5,0 @@ "main": "lib/react-rating.js", |
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
219524