[
  {
    "path": ".eslintrc",
    "content": "{\n  \"parser\": \"babel-eslint\",\n  \"ecmaFeatures\": {\n    \"arrowFunctions\": true,\n    \"templateStrings\": true,\n    \"classes\": true,\n    \"modules\": true,\n    \"restParams\": true,\n    \"jsx\": true\n  },\n\n  \"env\": {\n    \"browser\": true,\n    \"node\": true,\n    \"es6\": true\n  },\n\n  \"globals\": {\n    \"BROWSER\": true\n  },\n\n  \"rules\": {\n    \"quotes\": 0,\n    \"no-trailing-spaces\": 0,\n    \"no-unused-vars\": 0,\n    \"no-alert\": 0,\n    \"strict\": 0\n  }\n}"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nbootstrap-star-rating\n./src/components/Review.jsx\nother\n.travis.yml\ncoverage\ndist\ntest\nkarma.conf.js\nwebpack.config.js"
  },
  {
    "path": ".jshintrc",
    "content": "{\n  \"curly\": true,\n  \"eqeqeq\": true,\n  \"immed\": true,\n  \"latedef\": true,\n  \"newcap\": false,\n  \"noarg\": true,\n  \"sub\": true,\n  \"undef\": true,\n  \"unused\": true,\n  \"boss\": true,\n  \"eqnull\": true,\n  \"expr\": true,\n  \"node\": true,\n  \"browser\": true,\n  \"devel\": true,\n  \"esnext\": true\n}"
  },
  {
    "path": ".npmignore",
    "content": "node_modules\nbootstrap-star-rating\nother\ntest\nkarma.conf.js\nwebpack.config.js"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Cameron J Roe\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# react-star-rating ![](https://david-dm.org/cameronjroe/react-star-rating.svg)\n\n[![NPM](https://nodei.co/npm/react-star-rating.png?compact=true)](https://nodei.co/npm/react-star-rating/)\n\n<!-- [![Build Status](https://travis-ci.org/)](https://travis-ci.org/) -->\n![](src/assets/star-rating.png)\n\n> A simple star rating component built with React.\n\n## Install\n\n```sh\n$ npm install react-star-rating --save\n```\n\nInclude the css:\n\n```html\n<link rel=\"stylesheet\" href=\"node_modules/react-star-rating/dist/css/react-star-rating.min.css\">\n```\n\n## Usage\n\n### ES6\n```js\nimport React from 'react';\nimport StarRating from 'react-star-rating';\n\nclass FormComponent extends React.Component {\n  render() {\n    return (\n      <form action=\"/api\" method=\"POST\">\n        <StarRating name=\"airbnb-rating\" caption=\"Rate your stay!\" totalStars={5} />\n        <button type=\"submit\" className=\"btn btn-submit\">Submit Rating</button>\n      </form>\n    );\n  }\n}\n\nReact.render(<FormComponent />, document.getElementById('star-rating'));\n```\n\n### ES5\n```js\nvar React = require('react');\nvar StarRating = require('react-star-rating');\n\nvar FormComponent = React.createClass({\n    render: function () {\n      return (\n        <form action=\"/api\" method=\"POST\">\n          <StarRating name=\"airbnb-rating\" caption=\"Rate your stay!\" totalStars={5} />\n          <button type=\"submit\" className=\"btn btn-submit\">Submit Rating</button>\n        </form>\n      );\n    }\n});\n\nReact.render(<FormComponent />, document.getElementById('star-rating'));\n```\n\n## Options\n  - **name**={string} - name for form input (required)\n  - **caption**={string} - caption for rating (optional)\n  - **totalStars**={number} - rating amount (required, default: 5)\n  - **rating**={number} - a set rating between the rating amount (optional)\n  - **disabled**={boolean} - whether to disable the rating from being selected (optional)\n  - **editing**={boolean} - whether the rating is explicitly in editing mode (optional)\n  - **size**={number} - size of stars (optional)\n  - **onRatingClick**={function} - a handler function that gets called onClick of the rating (optional) - gets passed (event, {position, rating, caption, name})\n\n## Todo\n\n- [x] Fix ES6 bug with bundling\n- [x] Add svg stars\n- [x] Double-check touch support works\n- [ ] Re-implement star hovering (kinda janky right now)\n\n\n## License\n\n[MIT](https://github.com/cameronjroe/react-star-rating/blob/master/LICENSE)\n"
  },
  {
    "path": "changelog.md",
    "content": "\n## v1.4.0 - 10.10.15\n  - Changed ratingAmount to totalStars\n  - Added SVG stars\n  - Updated to React 0.14.x\n  - Temporarily removed step support while react updates mask attribute"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=viewport content=\"width=device-width, initial-scale=1\">\n  <title>React Star Rating</title>\n  <link href=\"http://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css\" rel=\"stylesheet\">\n  <link rel=\"stylesheet\" href=\"http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css\">\n  <link href='http://fonts.googleapis.com/css?family=Philosopher:400,700,400italic,700italic' rel='stylesheet' type='text/css'>\n  <link rel=\"stylesheet\" href=\"./dist/css/demo.css\">\n  <link rel=\"stylesheet\" href=\"./dist/css/react-star-rating.css\">\n</head>\n<body>\n  <a href=\"https://github.com/cameronjroe/react-star-rating\"><img style=\"position: absolute; top: 0; right: 0; border: 0;\" src=\"https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67\" alt=\"Fork me on GitHub\" data-canonical-src=\"https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png\"></a>\n  \n  <div class=\"inject\"></div>\n  \n  <script src=\"./dist/docs.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"react-star-rating\",\n  \"version\": \"1.4.2\",\n  \"description\": \"A simple star rating component built with React.\",\n  \"main\": \"./dist/react-star-rating.min.js\",\n  \"scripts\": {\n    \"start\": \"npm run dev\",\n    \"dev\": \"webpack serve\",\n    \"build\": \"webpack\",\n    \"test\": \"karma start ./test/karma.conf.js\",\n    \"prepublish\": \"\"\n  },\n  \"repository\": \"cameronroe/react-star-rating\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"classnames\": \"^2.3.2\",\n    \"react\": \"^18.2.0\",\n    \"react-dom\": \"^18.2.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.19.6\",\n    \"@babel/preset-env\": \"^7.19.4\",\n    \"@babel/preset-react\": \"^7.18.6\",\n    \"autoprefixer\": \"^10.4.13\",\n    \"babel-eslint\": \"^10.1.0\",\n    \"babel-loader\": \"^9.0.0\",\n    \"chai\": \"^4.3.6\",\n    \"cross-env\": \"^7.0.3\",\n    \"css-loader\": \"^6.7.1\",\n    \"eslint\": \"^8.26.0\",\n    \"eslint-webpack-plugin\": \"^3.2.0\",\n    \"html-webpack-plugin\": \"^5.5.0\",\n    \"isparta\": \"^3.0.4\",\n    \"istanbul-instrumenter-loader\": \"^2.0.0\",\n    \"jshint-stylish\": \"^2.2.1\",\n    \"karma\": \"^6.4.1\",\n    \"karma-chai\": \"^0.1.0\",\n    \"karma-chrome-launcher\": \"^3.1.1\",\n    \"karma-coverage\": \"^2.2.0\",\n    \"karma-mocha\": \"^2.0.1\",\n    \"karma-phantomjs-launcher\": \"^1.0.4\",\n    \"karma-sinon\": \"^1.0.5\",\n    \"karma-sourcemap-loader\": \"^0.3.8\",\n    \"karma-webpack\": \"^5.0.0\",\n    \"mocha\": \"^10.1.0\",\n    \"node-bourbon\": \"^4.2.8\",\n    \"node-sass\": \"^7.0.3\",\n    \"postcss\": \"^8.4.18\",\n    \"postcss-loader\": \"^7.0.1\",\n    \"react-addons-test-utils\": \"^15.6.2\",\n    \"sass\": \"^1.55.0\",\n    \"sass-loader\": \"^13.1.0\",\n    \"sinon\": \"^14.0.1\",\n    \"style-loader\": \"^3.3.1\",\n    \"through2\": \"^4.0.2\",\n    \"vinyl-source-stream\": \"^2.0.0\",\n    \"webpack\": \"^5.74.0\",\n    \"webpack-cli\": \"^4.10.0\",\n    \"webpack-dev-server\": \"^4.11.1\",\n    \"webpack-shell-plugin-next\": \"^2.2.2\"\n  }\n}\n"
  },
  {
    "path": "postcss.config.js",
    "content": "module.exports = {\n  plugins: [\n    require('autoprefixer')\n  ]\n}\n"
  },
  {
    "path": "src/StarRating.js",
    "content": "import React, { Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport cx from 'classnames';\nimport { utils } from './utils';\nimport './sass/react-star-rating.scss';\n\nfunction isFloat(n) {\n  return n === Number(n) && n % 1 !== 0;\n}\n\n// TODO\n// - Add support for svg symbol\n// - Add svg masking when react supports it\n// - Update onClick to onSelect which supports mobile, desktop\n// - Add onChange to trigger function when rating changes\n\n/**\n * @fileoverview react-star-rating\n * <StarRating\n *   name={string} - name for form input (required)\n *   caption={string} - caption for rating (optional)\n *   totalStars={number} - the total amount of stars (required, default: 5)\n *   rating={number} - a set rating between the rating amount (optional)\n *   disabled={boolean} - whether to disable the rating from being selected (optional)\n *   editing={boolean} - whether the rating is explicitly in editing mode (optional)\n *   size={number} - size of stars (optional)\n *   onRatingClick={function} - a handler function that gets called onClick of the rating (optional)\n *   />\n */\nclass StarRating extends Component {\n\n  // static propTypes = {\n  //   name: React.PropTypes.string.isRequired,\n  //   caption: React.PropTypes.string,\n  //   totalStars: React.PropTypes.number.isRequired,\n  //   rating: React.PropTypes.number,\n  //   onRatingClick: React.PropTypes.func,\n  //   disabled: React.PropTypes.bool,\n  //   editing: React.PropTypes.bool,\n  //   size: React.PropTypes.number\n  // }\n\n  static defaultProps = {\n    step: 1,\n    totalStars: 5,\n    onRatingClick() {},\n    disabled: false,\n    size: 50,\n    rating: 0\n  }\n\n  constructor(props) {\n    super(props);\n\n    this.state = {\n      currentRatingVal: props.rating,\n      currentRatingPos: this.getStarRatingPosition(props.rating),\n      editing: props.editing || true,\n      rating: props.rating,\n      pos: this.getStarRatingPosition(props.rating),\n      glyph: this.getStars(),\n      size: props.size\n    };\n  }\n\n  componentWillMount() {\n    this.min = 0;\n    this.max = this.props.totalStars || 5;\n\n    if (this.props.rating) {\n      this.state.editing = this.props.editing || false;\n    }\n  }\n\n  componentDidMount() {\n    this.root = ReactDOM.findDOMNode(this.refs.root);\n    this.ratingContainer = ReactDOM.findDOMNode(this.refs.ratingContainer);\n  }\n\n  componentWillUnmount() {\n    delete this.root;\n    delete this.ratingContainer;\n  }\n\n  /**\n   * Gets the stars based on totalStars\n   * @return {string} stars\n   */\n  getStars() {\n    var stars = '';\n    var numRating = this.props.totalStars;\n    for(var i = 0; i < numRating; i++) {\n      stars += '\\u2605';\n    }\n    return stars;\n  }\n\n  getWidthFromValue(val) {\n    var min = this.min,\n        max = this.max;\n    if (val <= min || min === max) {\n      return 0;\n    }\n    if (val >= max) {\n      return 100;\n    }\n    return (val - min) * 100 / (max - min);\n  }\n\n  calculate(pos) {\n    var val = utils.getValueFromPosition(pos, this.props.step, this.ratingContainer, this.min, this.max),\n        width = this.getWidthFromValue(val);\n\n    width += '%';\n    return {width, val};\n  }\n\n  getStarRatingPosition(val) {\n    return this.getWidthFromValue(val) + '%';\n  }\n\n  getRatingEvent(e) {\n    let root = this.root;\n    let pos = utils.getPosition(e, root);\n    return this.calculate(pos);\n  }\n\n  /**\n   * Get Star SVG\n   */\n  getSvg(rating) {\n    let stars = [];\n    for (let i = 0; i < this.props.totalStars; i++) {\n      let attrs = {};\n      attrs['transform'] = `translate(${i*50}, 0)`;\n      attrs['fill'] = (i+this.props.step <= rating) ? '#FFA91B' : '#C6C6C6';\n      stars.push(\n        <path {...attrs}\n          key={`star-${i}`}\n          mask=\"url(#half-star-mask)\"\n          d=\"m0,18.1l19.1,0l5.9,-18.1l5.9,18.1l19.1,0l-15.4,11.2l5.9,18.1l-15.4,-11.2l-15.4,11.2l5.9,-18.1l-15.4,-11.2l0,0z\" />\n      );\n    }\n\n    let styles = {\n      width: `${stars.length * this.props.size}px`,\n      height: `${this.props.size}px`\n    };\n\n    return (\n      <svg className=\"rsr__star\"\n        style={styles}\n        viewBox={`0 0 ${stars.length} 50`}\n        preserveAspectRatio=\"xMinYMin meet\"\n        version=\"1.1\"\n        xmlns=\"http://www.w3.org/2000/svg\">\n        {/*\n          React Doesn't support `mask` attributes yet\n        <defs>\n          <mask id=\"half-star-mask\">\n            <rect x=\"0\" y=\"0\" width=\"26\" height=\"50\" fill=\"blue\"></rect>\n          </mask>\n        </defs>*/}\n        <g>\n          {stars.map((item) => {\n            return item;\n          })}\n        </g>\n      </svg>\n    );\n  }\n\n  /**\n   * Update the active rating selection\n   * @param  {number} width width based on mouse position\n   * @param  {number} val   current rating amount\n   */\n  updateRating(width, val) {\n    this.setState({\n      pos: width,\n      rating: val\n    });\n  }\n\n  /**\n   * Update rating state if props have changed\n   */\n  shouldComponentUpdate(nextProps, nextState) {\n    if (nextProps !== this.props) {\n      this.updateRating(\n        this.getStarRatingPosition(nextProps.rating),\n        nextProps.rating\n      );\n      return true;\n    } else {\n      return nextState.currentRatingVal !== this.state.currentRatingVal || nextState.rating !== this.state.rating;\n    }\n  }\n\n  /**\n   * Set position to original state\n   */\n  handleMouseLeave() {\n    this.setState({\n      pos: this.state.currentRatingPos,\n      rating: this.state.currentRatingVal\n    });\n  }\n\n  /**\n   * Update position to current event state\n   * @param  {object} event\n   */\n  handleMouseMove(e) {\n    // get hover position\n    let ratingEvent = this.getRatingEvent(e);\n    this.updateRating(\n      ratingEvent.width,\n      ratingEvent.val\n    );\n  }\n\n  /**\n   * Update rating state, Trigger function handler\n   * @param  {object} event\n   */\n  handleClick(e) {\n    if (this.props.disabled) {\n      e.stopPropagation();\n      e.preventDefault();\n      return false;\n    }\n\n    var payload = {\n      currentRatingPos: this.state.pos,\n      currentRatingVal: this.state.rating,\n      caption: this.props.caption,\n      name: this.props.name\n    };\n\n    this.setState(payload);\n\n    this.props.onRatingClick(e, {\n      rating: this.state.rating,\n      position: this.state.pos,\n      caption: this.props.caption,\n      name: this.props.name\n    });\n  }\n\n  getClasses() {\n    return cx({\n      'rsr-root': true,\n      'rsr--disabled': this.props.disabled,\n      'rsr--editing': this.state.editing\n    });\n  }\n\n  getCaption() {\n    if (this.props.caption) {\n      return (<span className=\"rsr__caption\">{this.props.caption}</span>);\n    } else {\n      return null;\n    }\n  }\n\n  setAttrs(isState) {\n    let attrs = {};\n    if (isState) {\n      attrs['onMouseMove'] = this.handleMouseMove.bind(this);\n      attrs['onMouseLeave'] = this.handleMouseLeave.bind(this);\n      attrs['onClick'] = this.handleClick.bind(this);\n    }\n    return attrs;\n  }\n\n  render() {\n\n    let classes = this.getClasses();\n    let caption = this.getCaption();\n    let attrs = this.setAttrs(this.state.editing);\n\n    return (\n      <span className=\"rsr-container\">\n        {caption}\n        <div ref=\"root\" className={classes}>\n          <div ref=\"ratingContainer\"\n            className=\"rsr rating-gly-star\"\n            data-content={this.state.glyph} {...attrs}>\n            {this.getSvg(this.state.rating)}\n            <input type=\"hidden\"\n              name={this.props.name}\n              value={this.state.currentRatingVal}\n              style={{display: 'none !important'}}\n              min={this.min}\n              max={this.max}\n              readOnly />\n          </div>\n        </div>\n      </span>\n    );\n  }\n}\n\nexport default StarRating;\n"
  },
  {
    "path": "src/docs.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=viewport content=\"width=device-width, initial-scale=1\">\n  <title><%= htmlWebpackPlugin.options.title %></title>\n  <link href=\"http://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css\" rel=\"stylesheet\">\n  <link rel=\"stylesheet\" href=\"http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css\">\n  <link href='http://fonts.googleapis.com/css?family=Philosopher:400,700,400italic,700italic' rel='stylesheet' type='text/css'>\n</head>\n<body>\n  <a href=\"https://github.com/cameronjroe/react-star-rating\"><img style=\"position: absolute; top: 0; right: 0; border: 0;\" src=\"https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67\" alt=\"Fork me on GitHub\" data-canonical-src=\"https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png\"></a>\n\n  <div class=\"inject\"></div>\n\n</body>\n</html>\n"
  },
  {
    "path": "src/docs.js",
    "content": "import React, { Component } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport StarRating from './StarRating';\nimport pkg from '../package';\nimport './sass/demo.scss';\n\nconst inject = document.querySelector('.inject');\nconst root = createRoot(inject);\n\nclass Docs extends Component {\n\n  handleRatingClick(e, data) {\n    console.log(data);\n    alert('You left a ' + data.rating + ' star rating for ' + data.name);\n  }\n\n  render() {\n    var currentVersion = pkg.version;\n\n    return (\n      <section>\n        <div className=\"intro\">\n          <h1 className=\"main-title\">\n            {'react-star-rating'}\n            <small> easy star ratings with Test</small>\n          </h1>\n          <StarRating name=\"hotels\" size={50} rating={5} editing={false} totalStars={5} step={1} />\n          <p style={{marginBottom: '10px'}}>v{currentVersion}</p>\n          <a href=\"https://github.com/cameronjroe/react-star-rating\" className=\"btn btn-primary\">View on Github</a>\n        </div>\n        <div className=\"ratings-wrap\">\n          <h2>Installation</h2>\n          <hr/>\n          <code>\n            {'$ npm install react-star-rating --save'}\n          </code>\n          <p>Include the css:</p>\n          <code>\n            {'<link rel=\"stylesheet\" href=\"node_modules/react-star-rating/dist/css/react-star-rating.min.css\">'}\n          </code>\n          <h2>Usage</h2>\n          <hr/>\n          <form target=\"_self\" method=\"GET\" className=\"demo-form\">\n            <StarRating name=\"react-star-rating\" caption=\"Rate this component!\" totalStars={5} />\n            <button type=\"submit\" className=\"btn btn-primary\">Submit Rating</button>\n          </form>\n          <h3>ES6</h3>\n          <code>\n            <p>{'import React from \\'react\\''}</p>\n            <p>{'import StarRating from \\'react-star-rating\\''}</p>\n            <p>{' '}</p>\n            <p>{'class FormComponent extends React.Component {'}</p>\n            <p>{'  render() { '}</p>\n            <p>{'    return ('}</p>\n            <p>{'      <form target=\"_self\" method=\"GET\">'}</p>\n            <p>{'        <StarRating name=\"react-star-rating\" caption=\"Rate this component!\" totalStars={5} />'}</p>\n            <p>{'        <button type=\"submit\" className=\"btn btn-primary\">Submit Rating</button>'}</p>\n            <p>{'      </form>'}</p>\n            <p>{'    );'}</p>\n            <p>{'  }'}</p>\n            <p>{'}'}</p>\n            <p>{' '}</p>\n            <p>{'React.render(<FormComponent />, document.getElementById(\\'star-rating\\'));'}</p>\n          </code>\n          <h3>ES5</h3>\n          <code>\n            <p>{'var React = require(\\'react\\');'}</p>\n            <p>{'var StarRating = require(\\'react-star-rating\\');'}</p>\n            <p>{' '}</p>\n            <p>{'var FormComponent = React.createClass({'}</p>\n            <p>{'  render: function () { '}</p>\n            <p>{'    return ('}</p>\n            <p>{'      <form target=\"_self\" method=\"GET\">'}</p>\n            <p>{'        <StarRating name=\"react-star-rating\" caption=\"Rate this component!\" totalStars={5} />'}</p>\n            <p>{'        <button type=\"submit\" className=\"btn btn-primary\">Submit Rating</button>'}</p>\n            <p>{'      </form>'}</p>\n            <p>{'    );'}</p>\n            <p>{'  }'}</p>\n            <p>{'});'}</p>\n            <p>{' '}</p>\n            <p>{'React.render(<FormComponent />, document.getElementById(\\'star-rating\\'));'}</p>\n          </code>\n          <h2>Options</h2>\n          <hr/>\n          <ul>\n            <li><strong>name</strong>{'={string} - name for form input (required)'}</li>\n            <li><strong>caption</strong>{'={string} - caption for rating (optional)'}</li>\n            <li><strong>totalStars</strong>{'={number} - rating amount (required, default: 5)'}</li>\n            <li><strong>rating</strong>{'={number} - a set rating between the rating amount (optional)'}</li>\n            <li><strong>disabled</strong>{'={boolean} - whether to disable the rating from being selected (optional)'}</li>\n            <li><strong>editing</strong>{'={boolean} - whether the rating is explicitly in editing mode (optional)'}</li>\n            <li><strong>size</strong>{'={number} - size of stars (optional)'}</li>\n            <li><strong>onRatingClick</strong>{'={function} - a handler function that gets called onClick of the rating (optional) - gets passed (event, {position, rating, caption, name})'}</li>\n          </ul>\n          <h2>Examples</h2>\n          <hr/>\n          <StarRating name=\"handler\" caption=\"Use onClick Handlers!\" totalStars={5} onRatingClick={this.handleRatingClick.bind(this)} />\n          <p></p>\n          <code>\n            <p>{'// handler in react class'}</p>\n            <p>{'handleRatingClick: function (e, data) {'}</p>\n            <p>{'    alert(\\'You left a \\' + data.rating + \\' star rating for \\' + data.caption);'}</p>\n            <p>{'}'}</p>\n            <p>{' '}</p>\n            <p>{'<StarRating name=\"handler\" caption=\"Use onClick Handlers!\" totalStars={5} onRatingClick={handleRatingClick} />'}</p>\n          </code>\n          <p></p>\n          <blockquote><strong>{'If you\\'re using ES6, make sure to bind the handler: '}</strong><code>{'this.handleRatingClick.bind(this, pass, args, here)'}</code></blockquote>\n          <StarRating name=\"ten-stars\" caption=\"Configure number of stars!\" totalStars={10} step={1} onRatingClick={this.handleRatingClick.bind(this)} />\n          <code>\n            {'<StarRating name=\"ten-stars\" caption=\"Configure number of stars!\" totalStars={10} step={1} onRatingClick={this.handleRatingClick} />'}\n          </code>\n          {/*<StarRating name=\"half-stars\" caption=\"Use half-star steps!\" totalStars={5} />\n          <code>\n            {'<StarRating name=\"half-stars\" caption=\"Use half-star steps!\" totalStars={5} />'}\n          </code>*/}\n          <StarRating name=\"small-rating\" caption=\"Small!\" size={30} totalStars={5} rating={3} />\n          <code>\n            {'<StarRating name=\"small-rating\" caption=\"Small!\" size={30} totalStars={5} rating={3} />'}\n          </code>\n          <StarRating name=\"medium-rating\" caption=\"Medium!\" size={50} totalStars={5} rating={4} />\n          <code>\n            {'<StarRating name=\"medium-rating\" caption=\"Medium!\" size={50} totalStars={5} rating={4} />'}\n          </code>\n          <StarRating name=\"large-rating\" caption=\"Large!\" size={70} totalStars={5} rating={5} />\n          <code>\n            {'<StarRating name=\"large-rating\" caption=\"Large!\" size={70} totalStars={5} rating={5} />'}\n          </code>\n          <StarRating name=\"jumbo-rating\" caption=\"Jumbo!\" size={100} totalStars={5} rating={5} />\n          <code>\n            {'<StarRating name=\"jumbo-rating\" caption=\"Jumbo!\" size={100} totalStars={5} rating={5} />'}\n          </code>\n          <StarRating name=\"disabled\" caption=\"Disabled.\" totalStars={5} rating={3} disabled={true} />\n          <code>\n            {'<StarRating name=\"disabled\" caption=\"Disabled.\" totalStars={5} rating={3} disabled={true} />'}\n          </code>\n        </div>\n        <footer>\n          <div className=\"footer-creds\">\n            <p>Code licensed under <a href=\"https://github.com/cameronjroe/react-star-rating/blob/master/LICENSE\">MIT</a> - Currently v{currentVersion} - <a href=\"https://github.com/cameronjroe/react-star-rating\">Github Repo</a></p>\n            <p>Created by <a href=\"http://twitter.com/cameronjroe\">@cameronjroe</a> - <iframe src=\"https://ghbtns.com/github-btn.html?user=cameronjroe&type=follow&count=true\" frameBorder=\"0\" scrolling=\"0\" width=\"170px\" height=\"20px\"></iframe></p>\n          </div>\n        </footer>\n      </section>\n    );\n  }\n\n}\n\nroot.render(<Docs />);\n"
  },
  {
    "path": "src/sass/demo.scss",
    "content": "@import \"bourbon\";\n\nhtml, body {\n  font-size: 16px;\n  margin: 0;\n  padding-bottom: 2em;\n  font-family: 'Times';\n}\n\nh1, h2, h3, h4, h5, h6 {\n  font-family: 'Philosopher', sans-serif;\n}\n\ncode {\n  color: #444;\n  padding: 2em;\n  line-height: 1.5;\n  margin-top: 2em;\n  margin-bottom: 2.5em;\n  min-width: 100%;\n  display: inline-block;\n  box-shadow: inset 0px 0px 7px rgba(210, 210, 210, 0.54);\n  background-color: rgba(210, 210, 210, 0.24);\n  white-space: pre-wrap;\n}\n\niframe {\n  border: 0;\n  display: inline-block;\n  vertical-align: middle;\n}\n\nul li {\n  margin: 0.5em 0;\n  font-size: 1.2em;\n}\n\nfooter {\n  text-align: center;\n}\n\n.btn {\n  border-radius: 2px;\n}\n\n.btn-primary {\n  background-color: #F5A71B;\n  color: #fff;\n  border: 0;\n  text-transform: uppercase;\n  font-size: 12px;\n  font-weight: bold;\n  margin: 0 1.5em;\n  letter-spacing: 1px;\n  &:active, &:hover, &:focus {\n    outline: 0;\n    color: #fff;\n    background-color: darken(#F5A71B, 10%);\n  }\n}\n\n.demo-form {\n  fieldset {\n    display: inline-block;\n  }\n}\n\n.footer-creds {\n  display: inline-block;\n  letter-spacing: 1px;\n  opacity: 0.8;\n}\n\n.intro {\n  color: #fff;\n  background: linear-gradient(#444, #333) left repeat;\n  padding: 8em 0;\n  box-shadow: inset 0px 0px 7px #000;\n  text-align: center;\n  .react-star-rating {\n    text-align: center;\n  }\n}\n\n.main-title {\n  font-size: 4em;\n  letter-spacing: 1px;\n  text-align: center;\n  > small {\n    display: block;\n    font-size: 0.5em;\n  }\n}\n\n.ratings-wrap {\n  max-width: 980px;\n  margin: 0 auto;\n  padding: 4em;\n  border-radius: 5px;\n}\n"
  },
  {
    "path": "src/sass/react-star-rating.scss",
    "content": "@import \"bourbon\";\n\n.rsr-root {\n  vertical-align: middle;\n  display: inline-block;\n}\n\n.rsr--editing {\n  &:hover {\n    cursor: pointer;\n  }\n}\n\n.rsr {\n  position: relative;\n  vertical-align: middle;\n  display: inline-block;\n  color: #e3e3e3;\n  overflow: hidden;\n}\n\n.rsr__stars {\n  position: absolute;\n  left: 0;\n  top: 0;\n  white-space: nowrap;\n  overflow: hidden;\n  color: #F5A71B;\n  transition: all 0.01s;\n}\n\n.rsr__caption {\n  font-size: 1.25em;\n  vertical-align: middle;\n  margin-right: 0.5em;\n}\n\n.rsr--disabled {\n  .rsr-container:hover {\n    cursor: not-allowed;\n  }\n}\n"
  },
  {
    "path": "src/utils.js",
    "content": "\nfunction getDecimalPlaces(num) {\n  var match = ('' + num).match(/(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/);\n  return !match ? 0 : Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));\n}\n\nfunction applyPrecision(val, precision) {\n  return parseFloat(val.toFixed(precision));\n}\n\nexport const utils = {\n  /**\n   * Gets the mouse position\n   * @param  {event} e\n   * @return {number} delta\n   */\n  getPosition(e, root) {\n    return e.clientX - root.getBoundingClientRect().left;\n  },\n\n  treatName(title) {\n    if (typeof title === 'string') {\n      return title.toLowerCase().split(' ').join('_');\n    }\n  },\n\n  getValueFromPosition(pos, step, container, min, max) {\n    var precision = getDecimalPlaces(step);\n    var maxWidth = container.offsetWidth;\n    var diff = max - min;\n    var factor = (diff * pos) / (maxWidth * step);\n    factor = Math.ceil(factor);\n    var val = applyPrecision(parseFloat(min + factor * step), precision);\n    val = Math.max(Math.min(val, max), min);\n    return val;\n  }\n\n}\n"
  }
]