Huge News!Announcing our $40M Series B led by Abstract Ventures.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.5.0 to 0.6.0

3

lib/react-rating.js

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

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

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

this.setState({
indexOver: undefined,
index: index,

@@ -178,0 +179,0 @@ selected: true

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

/*! react-rating - 0.5.0 | (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 r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.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 r=o(1),i=r.createClass({displayName:"PercentageSymbol",propTypes:!1,_iconNode:function(t){return r.isValidElement(t)?t:"object"==typeof t&&null!==t?r.createElement("span",{style:t}):"[object String]"===Object.prototype.toString.call(t)?r.createElement("span",{className:t}):void 0},render:function(){var t,e=this._iconNode(this.props.background),o=this._iconNode(this.props.icon),i=(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.onMouseDown||this.props.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return r.createElement("span",{style:s,onMouseDown:this.props.onMouseDown,onMouseMove:this.props.onMouseMove},e,r.createElement("span",{style:i},o))}});t.exports=i},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 r=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},i=o(1),s=o(5),a=o(2),p=function(t,e){var o=t.step,n=o>0?t.start:t.stop,r=o>0?t.stop:t.start;if(o&&n<=e&&e<=r)return(e-t.start)/o},c=i.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"}},handleMouseDown:function(t,e){var o=t+this._fractionalIndex(e);this.props.onClick(this._indexToRate(o)),this.state.index!==o&&(this.props.onChange(this._indexToRate(o)),this.setState({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,u=0;u<Math.floor(this._rateToIndex(this.props.stop));u++){var h=u-c===0?p%1*100:u-c<0?100:0;t.push(i.createElement(a,{key:u,background:e[u%e.length],icon:l[u%l.length],percent:h,onMouseDown:!this.props.readonly&&this.handleMouseDown.bind(this,u),onMouseMove:!this.props.readonly&&this.handleMouseMove.bind(this,u),direction:this.state.direction}))}var d=this.props,e=(d.start,d.stop,d.step,d.empty),o=(d.initialRate,d.placeholderRate,d.placeholder),s=d.full,f=d.readonly,v=(d.quiet,d.fractions,d.scale,d.onChange,d.onClick,d.onRate,n(d,["start","stop","step","empty","initialRate","placeholderRate","placeholder","full","readonly","quiet","fractions","scale","onChange","onClick","onRate"]));return i.createElement("span",r({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),r={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};t.exports={empty:n(r,{backgroundColor:"#ccc"}),full:n(r,{backgroundColor:"black"}),placeholder:n(r,{backgroundColor:"red"})}}])});
/*! react-rating - 0.6.0 | (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 r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.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 r=o(1),i=r.createClass({displayName:"PercentageSymbol",propTypes:!1,_iconNode:function(t){return r.isValidElement(t)?t:"object"==typeof t&&null!==t?r.createElement("span",{style:t}):"[object String]"===Object.prototype.toString.call(t)?r.createElement("span",{className:t}):void 0},render:function(){var t,e=this._iconNode(this.props.background),o=this._iconNode(this.props.icon),i=(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.onMouseDown||this.props.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return r.createElement("span",{style:s,onMouseDown:this.props.onMouseDown,onMouseMove:this.props.onMouseMove},e,r.createElement("span",{style:i},o))}});t.exports=i},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 r=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},i=o(1),s=o(5),a=o(2),p=function(t,e){var o=t.step,n=o>0?t.start:t.stop,r=o>0?t.stop:t.start;if(o&&n<=e&&e<=r)return(e-t.start)/o},c=i.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"}},handleMouseDown:function(t,e){var o=t+this._fractionalIndex(e);this.props.onClick(this._indexToRate(o)),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,u=0;u<Math.floor(this._rateToIndex(this.props.stop));u++){var d=u-c===0?p%1*100:u-c<0?100:0;t.push(i.createElement(a,{key:u,background:e[u%e.length],icon:l[u%l.length],percent:d,onMouseDown:!this.props.readonly&&this.handleMouseDown.bind(this,u),onMouseMove:!this.props.readonly&&this.handleMouseMove.bind(this,u),direction:this.state.direction}))}var h=this.props,e=(h.start,h.stop,h.step,h.empty),o=(h.initialRate,h.placeholderRate,h.placeholder),s=h.full,f=h.readonly,v=(h.quiet,h.fractions,h.scale,h.onChange,h.onClick,h.onRate,n(h,["start","stop","step","empty","initialRate","placeholderRate","placeholder","full","readonly","quiet","fractions","scale","onChange","onClick","onRate"]));return i.createElement("span",r({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),r={display:"inline-block",borderRadius:"50%",border:"5px double white",width:30,height:30};t.exports={empty:n(r,{backgroundColor:"#ccc"}),full:n(r,{backgroundColor:"black"}),placeholder:n(r,{backgroundColor:"red"})}}])});
{
"name": "react-rating",
"version": "0.5.0",
"version": "0.6.0",
"description": "A rating react component with custom symbols",

@@ -50,2 +50,3 @@ "main": "lib/react-rating.js",

"node-libs-browser": "^0.5.2",
"react": "^0.14.8",
"webpack": "^1.10.1",

@@ -52,0 +53,0 @@ "webpack-dev-server": "^1.10.1"

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