New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-rating

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-rating - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

11

lib/react-rating.js

@@ -1,2 +0,2 @@

/*! react-rating - 0.6.2 | (c) 2015, 2016 dreyescat | MIT | https://github.com/dreyescat/react-rating */
/*! react-rating - 0.6.3 | (c) 2015, 2016 dreyescat | MIT | https://github.com/dreyescat/react-rating */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -107,3 +107,3 @@ if(typeof exports === 'object' && typeof module === 'object')

// Array of class names and/or style objects.
React.PropTypes.arrayOf(React.PropTypes.oneOfType[(React.PropTypes.string, React.PropTypes.object)]),
React.PropTypes.arrayOf(React.PropTypes.oneOfType[(React.PropTypes.string, React.PropTypes.object, React.PropTypes.element)]),
// Class names.

@@ -115,3 +115,3 @@ React.PropTypes.string,

// Array of class names and/or style objects.
React.PropTypes.arrayOf(React.PropTypes.oneOfType[(React.PropTypes.string, React.PropTypes.object)]),
React.PropTypes.arrayOf(React.PropTypes.oneOfType[(React.PropTypes.string, React.PropTypes.object, React.PropTypes.element)]),
// Class names.

@@ -123,3 +123,3 @@ React.PropTypes.string,

// Array of class names and/or style objects.
React.PropTypes.arrayOf(React.PropTypes.oneOfType[(React.PropTypes.string, React.PropTypes.object)]),
React.PropTypes.arrayOf(React.PropTypes.oneOfType[(React.PropTypes.string, React.PropTypes.object, React.PropTypes.element)]),
// Class names.

@@ -161,3 +161,4 @@ React.PropTypes.string,

this.setState({
index: indexOf(nextProps, rate)
index: indexOf(nextProps, rate),
selected: !!nextProps.initialRate
});

@@ -164,0 +165,0 @@ },

@@ -1,2 +0,2 @@

/*! react-rating - 0.6.2 | (c) 2015, 2016 dreyescat | MIT | https://github.com/dreyescat/react-rating */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactRating=e(require("react")):t.ReactRating=e(t.React)}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var o={};return e.m=t,e.c=o,e.p="/lib",e(0)}([function(t,e,o){"use strict";t.exports=o(3)},function(e,o){e.exports=t},function(t,e,o){"use strict";function n(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}var i=o(1),r=i.createClass({displayName:"PercentageSymbol",propTypes:!1,_iconNode:function(t){return i.isValidElement(t)?t:"object"==typeof t&&null!==t?i.createElement("span",{style:t}):"[object String]"===Object.prototype.toString.call(t)?i.createElement("span",{className:t}):void 0},render:function(){var t,e=this._iconNode(this.props.background),o=this._iconNode(this.props.icon),r=(t={display:"inline-block",position:"absolute",overflow:"hidden",top:0},n(t,"rtl"===this.props.direction?"right":"left",0),n(t,"width",void 0!==this.props.percent?this.props.percent+"%":"auto"),t),s={cursor:this.props.onClick||this.props.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return i.createElement("span",{style:s,onClick:this.props.onClick,onMouseMove:this.props.onMouseMove},e,i.createElement("span",{style:r},o))}});t.exports=r},function(t,e,o){"use strict";function n(t,e){var o={};for(var n in t)e.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},r=o(1),s=o(5),a=o(2),p=function(t,e){var o=t.step,n=o>0?t.start:t.stop,i=o>0?t.stop:t.start;if(o&&n<=e&&e<=i)return(e-t.start)/o},c=r.createClass({displayName:"Rating",propTypes:!1,getDefaultProps:function(){return{start:0,stop:5,step:1,empty:s.empty,placeholder:s.placeholder,full:s.full,fractions:1,scale:3,onChange:function(t){},onClick:function(t){},onRate:function(t){}}},componentDidMount:function(){this.setState({direction:window.getComputedStyle(this.refs.container,null).getPropertyValue("direction")})},componentWillReceiveProps:function(t){var e=t.initialRate>0?t.initialRate:t.placeholderRate;this.setState({index:p(t,e)})},getInitialState:function(){var t=this.props.initialRate>0?this.props.initialRate:this.props.placeholderRate;return{index:this._rateToIndex(t),indexOver:void 0,direction:"ltr"}},handleClick:function(t,e){var o=t+this._fractionalIndex(e);this.props.onClick(this._indexToRate(o),e),this.state.index!==o&&(this.props.onChange(this._indexToRate(o)),this.setState({indexOver:void 0,index:o,selected:!0}))},handleMouseLeave:function(){this.props.onRate(),this.setState({indexOver:void 0})},handleMouseMove:function(t,e){var o=t+this._fractionalIndex(e);this.state.indexOver!==o&&(this.props.onRate(this._indexToRate(o)),this.setState({indexOver:o}))},_indexToRate:function(t){return this.props.start+Math.floor(t)*this.props.step+this.props.step*this._roundToFraction(t%1)},_rateToIndex:function(t){return p(this.props,t)},_roundToFraction:function(t){var e=Math.ceil(t%1*this.props.fractions)/this.props.fractions,o=Math.pow(10,this.props.scale);return Math.floor(t)+Math.floor(e*o)/o},_fractionalIndex:function(t){var e="rtl"===this.state.direction?t.currentTarget.getBoundingClientRect().right-t.clientX:t.clientX-t.currentTarget.getBoundingClientRect().left;return this._roundToFraction(e/t.currentTarget.offsetWidth)},render:function(){for(var t=[],e=[].concat(this.props.empty),o=[].concat(this.props.placeholder),s=[].concat(this.props.full),p=this.props.quiet||void 0===this.state.indexOver?this.state.index:this.state.indexOver,c=Math.floor(p),l=!this.state.selected&&!this.props.initialRate&&this.props.placeholderRate>0&&void 0==this.state.indexOver?o:s,d=0;d<Math.floor(this._rateToIndex(this.props.stop));d++){var h=d-c===0?p%1*100:d-c<0?100:0;t.push(r.createElement(a,{key:d,background:e[d%e.length],icon:l[d%l.length],percent:h,onClick:!this.props.readonly&&this.handleClick.bind(this,d),onMouseMove:!this.props.readonly&&this.handleMouseMove.bind(this,d),direction:this.state.direction}))}var u=this.props,e=(u.start,u.stop,u.step,u.empty),o=(u.initialRate,u.placeholderRate,u.placeholder),s=u.full,f=u.readonly,v=(u.quiet,u.fractions,u.scale,u.onChange,u.onClick,u.onRate,n(u,["start","stop","step","empty","initialRate","placeholderRate","placeholder","full","readonly","quiet","fractions","scale","onChange","onClick","onRate"]));return r.createElement("span",i({ref:"container",onMouseLeave:!f&&this.handleMouseLeave},v),t)}});t.exports=c},function(t,e){"use strict";t.exports=function(){for(var t={},e=0;e<arguments.length;e++){var o=arguments[e];for(var n in o)t[n]=o[n]}return t}},function(t,e,o){"use strict";var n=o(4),i={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};t.exports={empty:n(i,{backgroundColor:"#ccc"}),full:n(i,{backgroundColor:"black"}),placeholder:n(i,{backgroundColor:"red"})}}])});
/*! react-rating - 0.6.3 | (c) 2015, 2016 dreyescat | MIT | https://github.com/dreyescat/react-rating */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactRating=e(require("react")):t.ReactRating=e(t.React)}(this,function(t){return function(t){function e(i){if(o[i])return o[i].exports;var n=o[i]={exports:{},id:i,loaded:!1};return t[i].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var o={};return e.m=t,e.c=o,e.p="/lib",e(0)}([function(t,e,o){"use strict";t.exports=o(3)},function(e,o){e.exports=t},function(t,e,o){"use strict";function i(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}var n=o(1),r=n.createClass({displayName:"PercentageSymbol",propTypes:!1,_iconNode:function(t){return n.isValidElement(t)?t:"object"==typeof t&&null!==t?n.createElement("span",{style:t}):"[object String]"===Object.prototype.toString.call(t)?n.createElement("span",{className:t}):void 0},render:function(){var t,e=this._iconNode(this.props.background),o=this._iconNode(this.props.icon),r=(t={display:"inline-block",position:"absolute",overflow:"hidden",top:0},i(t,"rtl"===this.props.direction?"right":"left",0),i(t,"width",void 0!==this.props.percent?this.props.percent+"%":"auto"),t),s={cursor:this.props.onClick||this.props.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return n.createElement("span",{style:s,onClick:this.props.onClick,onMouseMove:this.props.onMouseMove},e,n.createElement("span",{style:r},o))}});t.exports=r},function(t,e,o){"use strict";function i(t,e){var o={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(o[i]=t[i]);return o}var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i])}return t},r=o(1),s=o(5),a=o(2),p=function(t,e){var o=t.step,i=o>0?t.start:t.stop,n=o>0?t.stop:t.start;if(o&&i<=e&&e<=n)return(e-t.start)/o},c=r.createClass({displayName:"Rating",propTypes:!1,getDefaultProps:function(){return{start:0,stop:5,step:1,empty:s.empty,placeholder:s.placeholder,full:s.full,fractions:1,scale:3,onChange:function(t){},onClick:function(t){},onRate:function(t){}}},componentDidMount:function(){this.setState({direction:window.getComputedStyle(this.refs.container,null).getPropertyValue("direction")})},componentWillReceiveProps:function(t){var e=t.initialRate>0?t.initialRate:t.placeholderRate;this.setState({index:p(t,e),selected:!!t.initialRate})},getInitialState:function(){var t=this.props.initialRate>0?this.props.initialRate:this.props.placeholderRate;return{index:this._rateToIndex(t),indexOver:void 0,direction:"ltr"}},handleClick:function(t,e){var o=t+this._fractionalIndex(e);this.props.onClick(this._indexToRate(o),e),this.state.index!==o&&(this.props.onChange(this._indexToRate(o)),this.setState({indexOver:void 0,index:o,selected:!0}))},handleMouseLeave:function(){this.props.onRate(),this.setState({indexOver:void 0})},handleMouseMove:function(t,e){var o=t+this._fractionalIndex(e);this.state.indexOver!==o&&(this.props.onRate(this._indexToRate(o)),this.setState({indexOver:o}))},_indexToRate:function(t){return this.props.start+Math.floor(t)*this.props.step+this.props.step*this._roundToFraction(t%1)},_rateToIndex:function(t){return p(this.props,t)},_roundToFraction:function(t){var e=Math.ceil(t%1*this.props.fractions)/this.props.fractions,o=Math.pow(10,this.props.scale);return Math.floor(t)+Math.floor(e*o)/o},_fractionalIndex:function(t){var e="rtl"===this.state.direction?t.currentTarget.getBoundingClientRect().right-t.clientX:t.clientX-t.currentTarget.getBoundingClientRect().left;return this._roundToFraction(e/t.currentTarget.offsetWidth)},render:function(){for(var t=[],e=[].concat(this.props.empty),o=[].concat(this.props.placeholder),s=[].concat(this.props.full),p=this.props.quiet||void 0===this.state.indexOver?this.state.index:this.state.indexOver,c=Math.floor(p),l=!this.state.selected&&!this.props.initialRate&&this.props.placeholderRate>0&&void 0==this.state.indexOver?o:s,d=0;d<Math.floor(this._rateToIndex(this.props.stop));d++){var h=d-c===0?p%1*100:d-c<0?100:0;t.push(r.createElement(a,{key:d,background:e[d%e.length],icon:l[d%l.length],percent:h,onClick:!this.props.readonly&&this.handleClick.bind(this,d),onMouseMove:!this.props.readonly&&this.handleMouseMove.bind(this,d),direction:this.state.direction}))}var u=this.props,e=(u.start,u.stop,u.step,u.empty),o=(u.initialRate,u.placeholderRate,u.placeholder),s=u.full,f=u.readonly,v=(u.quiet,u.fractions,u.scale,u.onChange,u.onClick,u.onRate,i(u,["start","stop","step","empty","initialRate","placeholderRate","placeholder","full","readonly","quiet","fractions","scale","onChange","onClick","onRate"]));return r.createElement("span",n({ref:"container",onMouseLeave:!f&&this.handleMouseLeave},v),t)}});t.exports=c},function(t,e){"use strict";t.exports=function(){for(var t={},e=0;e<arguments.length;e++){var o=arguments[e];for(var i in o)t[i]=o[i]}return t}},function(t,e,o){"use strict";var i=o(4),n={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};t.exports={empty:i(n,{backgroundColor:"#ccc"}),full:i(n,{backgroundColor:"black"}),placeholder:i(n,{backgroundColor:"red"})}}])});
{
"name": "react-rating",
"version": "0.6.2",
"version": "0.6.3",
"description": "A rating react component with custom symbols",

@@ -5,0 +5,0 @@ "main": "lib/react-rating.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc