react-rating
Advanced tools
Comparing version 0.9.1 to 1.0.0
@@ -1,2 +0,2 @@ | ||
/*! react-rating - 0.9.1 | (c) 2015, 2017 dreyescat | MIT | https://github.com/dreyescat/react-rating */ | ||
/*! react-rating - 1.0.0 | (c) 2015, 2018 dreyescat | MIT | https://github.com/dreyescat/react-rating */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -68,3 +68,5 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
@@ -77,4 +79,2 @@ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
@@ -88,84 +88,51 @@ | ||
var _propTypes = __webpack_require__(3); | ||
var _utilsStyle = __webpack_require__(3); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _utilsStyle2 = _interopRequireDefault(_utilsStyle); | ||
var _style = __webpack_require__(13); | ||
var _Rating = __webpack_require__(5); | ||
var _style2 = _interopRequireDefault(_style); | ||
var _Rating2 = _interopRequireDefault(_Rating); | ||
var _PercentageSymbol = __webpack_require__(15); | ||
var _utilsNoop = __webpack_require__(16); | ||
var _PercentageSymbol2 = _interopRequireDefault(_PercentageSymbol); | ||
var _utilsNoop2 = _interopRequireDefault(_utilsNoop); | ||
// Returns the index of the rate in the range (start, stop, step). | ||
// Returns undefined index if the rate is outside the range. | ||
// NOTE: A range.step of 0 produces an empty range and consequently returns an | ||
// undefined index. | ||
var indexOf = function indexOf(range, rate) { | ||
// Check the rate is in the proper range [start..stop] according to | ||
// the start, stop and step properties in props. | ||
var step = range.step; | ||
var start = step > 0 ? range.start : range.stop; | ||
var stop = step > 0 ? range.stop : range.start; | ||
if (step && start <= rate && rate <= stop) { | ||
// The index corresponds to the number of steps of size props.step | ||
// that fits between rate and start. | ||
// This index does not need to be a whole number because we can have | ||
// fractional symbols, and consequently fractional/float indexes. | ||
return (rate - range.start) / step; | ||
} | ||
}; | ||
var RatingAPILayer = (function (_React$PureComponent) { | ||
_inherits(RatingAPILayer, _React$PureComponent); | ||
var Rating = (function (_React$Component) { | ||
_inherits(Rating, _React$Component); | ||
function RatingAPILayer(props) { | ||
_classCallCheck(this, RatingAPILayer); | ||
function Rating(props) { | ||
_classCallCheck(this, Rating); | ||
_get(Object.getPrototypeOf(Rating.prototype), 'constructor', this).call(this, props); | ||
var index = props.initialRate !== undefined ? props.initialRate : props.placeholderRate; | ||
_get(Object.getPrototypeOf(RatingAPILayer.prototype), 'constructor', this).call(this, props); | ||
this.state = { | ||
index: indexOf(props, index), | ||
indexOver: undefined, | ||
// Default direction is left to right | ||
direction: 'ltr' | ||
value: props.initialRating | ||
}; | ||
this.ratingContainer = null; | ||
this.handleClick = this.handleClick.bind(this); | ||
this.handleMouseLeave = this.handleMouseLeave.bind(this); | ||
this.handleMouseMove = this.handleMouseMove.bind(this); | ||
this.handleHover = this.handleHover.bind(this); | ||
} | ||
_createClass(Rating, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ | ||
// detect the computed direction style for the mounted component | ||
direction: window.getComputedStyle(this.ratingContainer, null).getPropertyValue("direction") | ||
}); | ||
} | ||
}, { | ||
_createClass(RatingAPILayer, [{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
var rate = nextProps.initialRate !== undefined ? nextProps.initialRate : nextProps.placeholderRate; | ||
this.setState({ | ||
index: indexOf(nextProps, rate), | ||
selected: nextProps.initialRate !== undefined | ||
value: nextProps.initialRating | ||
}); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps, prevState) { | ||
// If we have a new value trigger onChange callback | ||
if (this.state.value !== prevState.value) { | ||
this.props.onChange(this.state.value); | ||
} | ||
} | ||
}, { | ||
key: 'handleClick', | ||
value: function handleClick(i, event) { | ||
if (this.props.readonly) { | ||
return; | ||
} | ||
var index = i + this._fractionalIndex(event); | ||
this.props.onClick(this._indexToRate(index), event); | ||
if (this.state.index !== index) { | ||
this.props.onChange(this._indexToRate(index)); | ||
value: function handleClick(value, e) { | ||
var newValue = this.translateDisplayValueToValue(value); | ||
// Avoid calling setState if not necessary. Micro optimisation. | ||
if (this.state.value !== newValue) { | ||
this.setState({ | ||
indexOver: undefined, | ||
index: index, | ||
selected: true | ||
value: newValue | ||
}); | ||
@@ -175,58 +142,289 @@ } | ||
}, { | ||
key: 'handleMouseLeave', | ||
value: function handleMouseLeave() { | ||
if (this.props.readonly) { | ||
return; | ||
key: 'handleHover', | ||
value: function handleHover(displayValue) { | ||
var value = displayValue === undefined ? displayValue : this.translateDisplayValueToValue(displayValue); | ||
this.props.onHover(value); | ||
} | ||
}, { | ||
key: 'translateDisplayValueToValue', | ||
value: function translateDisplayValueToValue(displayValue) { | ||
var translatedValue = displayValue * this.props.step + this.props.start; | ||
// minimum value cannot be equal to start, since it's exclusive | ||
return translatedValue === this.props.start ? translatedValue + 1 / this.props.fractions : translatedValue; | ||
} | ||
}, { | ||
key: 'tranlateValueToDisplayValue', | ||
value: function tranlateValueToDisplayValue(value) { | ||
if (value === undefined) { | ||
return 0; | ||
} | ||
this.props.onRate(); | ||
return (value - this.props.start) / this.props.step; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _props = this.props; | ||
var step = _props.step; | ||
var emptySymbol = _props.emptySymbol; | ||
var fullSymbol = _props.fullSymbol; | ||
var placeholderSymbol = _props.placeholderSymbol; | ||
var readonly = _props.readonly; | ||
var quiet = _props.quiet; | ||
var fractions = _props.fractions; | ||
var direction = _props.direction; | ||
var start = _props.start; | ||
var stop = _props.stop; | ||
function calculateTotalSymbols(start, stop, step) { | ||
return Math.floor((stop - start) / step); | ||
} | ||
return _react2['default'].createElement(_Rating2['default'], { | ||
totalSymbols: calculateTotalSymbols(start, stop, step), | ||
value: this.tranlateValueToDisplayValue(this.state.value), | ||
placeholderValue: this.tranlateValueToDisplayValue(this.props.placeholderRating), | ||
readonly: readonly, | ||
quiet: quiet, | ||
fractions: fractions, | ||
direction: direction, | ||
emptySymbol: emptySymbol, | ||
fullSymbol: fullSymbol, | ||
placeholderSymbol: placeholderSymbol, | ||
onClick: this.handleClick, | ||
onHover: this.handleHover | ||
}); | ||
} | ||
}]); | ||
return RatingAPILayer; | ||
})(_react2['default'].PureComponent); | ||
RatingAPILayer.defaultProps = { | ||
start: 0, | ||
stop: 5, | ||
step: 1, | ||
readonly: false, | ||
quiet: false, | ||
fractions: 1, | ||
direction: 'ltr', | ||
onChange: _utilsNoop2['default'], | ||
onHover: _utilsNoop2['default'], | ||
emptySymbol: _utilsStyle2['default'].empty, | ||
fullSymbol: _utilsStyle2['default'].full, | ||
placeholderSymbol: _utilsStyle2['default'].placeholder | ||
}; | ||
// Define propTypes only in development. | ||
RatingAPILayer.propTypes = "boolean" !== 'undefined' && (true) && { | ||
start: _react.PropTypes.number, | ||
stop: _react.PropTypes.number, | ||
step: _react.PropTypes.number, | ||
initialRating: _react.PropTypes.number, | ||
placeholderRating: _react.PropTypes.number, | ||
readonly: _react.PropTypes.bool, | ||
quiet: _react.PropTypes.bool, | ||
fractions: _react.PropTypes.number, | ||
direction: _react.PropTypes.string, | ||
emptySymbol: _react.PropTypes.oneOfType([ | ||
// Array of class names and/or style objects. | ||
_react.PropTypes.arrayOf(_react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object, _react.PropTypes.element])), | ||
// Class names. | ||
_react.PropTypes.string, | ||
// Style objects. | ||
_react.PropTypes.object]), | ||
fullSymbol: _react.PropTypes.oneOfType([ | ||
// Array of class names and/or style objects. | ||
_react.PropTypes.arrayOf(_react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object, _react.PropTypes.element])), | ||
// Class names. | ||
_react.PropTypes.string, | ||
// Style objects. | ||
_react.PropTypes.object]), | ||
placeholderSymbol: _react.PropTypes.oneOfType([ | ||
// Array of class names and/or style objects. | ||
_react.PropTypes.arrayOf(_react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object, _react.PropTypes.element])), | ||
// Class names. | ||
_react.PropTypes.string, | ||
// Style objects. | ||
_react.PropTypes.object]), | ||
onHover: _react.PropTypes.func, | ||
onChange: _react.PropTypes.func | ||
}; | ||
exports['default'] = RatingAPILayer; | ||
module.exports = exports['default']; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var merge = __webpack_require__(4); | ||
var style = { | ||
display: 'inline-block', | ||
borderRadius: '50%', | ||
border: '5px double white', | ||
width: 30, | ||
height: 30 | ||
}; | ||
module.exports = { | ||
empty: merge(style, { | ||
backgroundColor: '#ccc' | ||
}), | ||
full: merge(style, { | ||
backgroundColor: 'black' | ||
}), | ||
placeholder: merge(style, { | ||
backgroundColor: 'red' | ||
}) | ||
}; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
'use strict'; | ||
module.exports = function () { | ||
var res = {}; | ||
for (var i = 0; i < arguments.length; i++) { | ||
var obj = arguments[i]; | ||
for (var k in obj) { | ||
res[k] = obj[k]; | ||
} | ||
} | ||
return res; | ||
}; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _react = __webpack_require__(2); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = __webpack_require__(6); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _RatingSymbol = __webpack_require__(15); | ||
var _RatingSymbol2 = _interopRequireDefault(_RatingSymbol); | ||
var Rating = (function (_React$PureComponent) { | ||
_inherits(Rating, _React$PureComponent); | ||
function Rating(props) { | ||
_classCallCheck(this, Rating); | ||
_get(Object.getPrototypeOf(Rating.prototype), 'constructor', this).call(this, props); | ||
this.state = { | ||
// Indicates the value that is displayed to the user in the form of symbols. | ||
// It can be either 0 (for no displayed symbols) or (0, end] | ||
displayValue: this.props.value, | ||
// Indicates if the user is currently hovering over the rating element | ||
interacting: false, | ||
// Indicates if the rating element has been clicked even once | ||
dirty: false | ||
}; | ||
this.onMouseEnter = this.onMouseEnter.bind(this); | ||
this.onMouseLeave = this.onMouseLeave.bind(this); | ||
this.symbolMouseMove = this.symbolMouseMove.bind(this); | ||
this.symbolClick = this.symbolClick.bind(this); | ||
} | ||
// Define propTypes only in development. | ||
_createClass(Rating, [{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
this.setState({ | ||
indexOver: undefined | ||
dirty: this.props.value !== nextProps.value && !this.state.dirty ? true : this.state.dirty, | ||
displayValue: nextProps.value | ||
}); | ||
} | ||
}, { | ||
key: 'handleMouseMove', | ||
value: function handleMouseMove(i, event) { | ||
if (this.props.readonly) { | ||
return; | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps, prevState) { | ||
// Ensure we do not call this.props.onHover on clicks or on mouseLeave | ||
if (prevState.displayValue !== this.state.displayValue && this.state.interacting) { | ||
this.props.onHover(this.state.displayValue); | ||
} | ||
var index = i + this._fractionalIndex(event); | ||
if (this.state.indexOver !== index) { | ||
this.props.onRate(this._indexToRate(index)); | ||
} | ||
}, { | ||
key: 'symbolClick', | ||
value: function symbolClick(symbolIndex, event) { | ||
this.props.onClick(this.state.displayValue, event); | ||
} | ||
}, { | ||
key: 'symbolMouseMove', | ||
value: function symbolMouseMove(symbolIndex, event) { | ||
var value = this.calculateDisplayValue(symbolIndex, event); | ||
if (value !== this.state.displayValue) { | ||
this.setState({ | ||
indexOver: index | ||
displayValue: value | ||
}); | ||
} | ||
} | ||
// Calculate the rate of an index according the the start and step. | ||
}, { | ||
key: '_indexToRate', | ||
value: function _indexToRate(index) { | ||
return this.props.start + Math.floor(index) * this.props.step + this.props.step * this._roundToFraction(index % 1); | ||
key: 'onMouseEnter', | ||
value: function onMouseEnter() { | ||
this.setState({ | ||
interacting: !this.props.readonly | ||
}); | ||
} | ||
// Calculate the corresponding index for a rate according to the provided | ||
// props or this.props. | ||
}, { | ||
key: '_rateToIndex', | ||
value: function _rateToIndex(rate) { | ||
return indexOf(this.props, rate); | ||
key: 'onMouseLeave', | ||
value: function onMouseLeave() { | ||
this.setState({ | ||
displayValue: this.props.value, | ||
interacting: false | ||
}); | ||
} | ||
}, { | ||
key: '_roundToFraction', | ||
value: function _roundToFraction(index) { | ||
key: 'calculateDisplayValue', | ||
value: function calculateDisplayValue(symbolIndex, event) { | ||
var percentage = this.calculateHoverPercentage(event); | ||
// Get the closest top fraction. | ||
var fraction = Math.ceil(index % 1 * this.props.fractions) / this.props.fractions; | ||
var fraction = Math.ceil(percentage % 1 * this.props.fractions) / this.props.fractions; | ||
// Truncate decimal trying to avoid float precission issues. | ||
var precision = Math.pow(10, this.props.scale); | ||
var roundedValue = Math.floor(index) + Math.floor(fraction * precision) / precision; | ||
// Handles bugs when the touchend is past the star stop | ||
return roundedValue > this.props.stop ? this.props.stop : roundedValue; | ||
var precision = Math.pow(10, 3); | ||
var displayValue = symbolIndex + (Math.floor(percentage) + Math.floor(fraction * precision) / precision); | ||
// ensure the returned value is greater than 0 | ||
return displayValue > 0 ? displayValue : 1 / this.props.fractions; | ||
} | ||
}, { | ||
key: '_fractionalIndex', | ||
value: function _fractionalIndex(event) { | ||
key: 'calculateHoverPercentage', | ||
value: function calculateHoverPercentage(event) { | ||
var clientX = event.nativeEvent.type.indexOf("touch") > -1 ? event.nativeEvent.type.indexOf("touchend") > -1 ? event.changedTouches[0].clientX : event.touches[0].clientX : event.clientX; | ||
var x = this.state.direction === 'rtl' ? event.currentTarget.getBoundingClientRect().right - clientX : clientX - event.currentTarget.getBoundingClientRect().left; | ||
return this._roundToFraction(x / event.currentTarget.offsetWidth); | ||
var delta = this.props.direction === 'rtl' ? event.target.getBoundingClientRect().right - clientX : clientX - event.target.getBoundingClientRect().left; | ||
// Returning 0 if the delta is negative solves the flickering issue | ||
return delta < 0 ? 0 : delta / event.target.offsetWidth; | ||
} | ||
@@ -236,56 +434,57 @@ }, { | ||
value: function render() { | ||
var _this = this; | ||
var _props = this.props; | ||
var start = _props.start; | ||
var stop = _props.stop; | ||
var step = _props.step; | ||
var initialRate = _props.initialRate; | ||
var placeholderRate = _props.placeholderRate; | ||
var empty = _props.empty; | ||
var full = _props.full; | ||
var placeholder = _props.placeholder; | ||
var readonly = _props.readonly; | ||
var quiet = _props.quiet; | ||
var fractions = _props.fractions; | ||
var scale = _props.scale; | ||
var onChange = _props.onChange; | ||
var onClick = _props.onClick; | ||
var onRate = _props.onRate; | ||
var totalSymbols = _props.totalSymbols; | ||
var value = _props.value; | ||
var placeholderValue = _props.placeholderValue; | ||
var direction = _props.direction; | ||
var emptySymbol = _props.emptySymbol; | ||
var fullSymbol = _props.fullSymbol; | ||
var placeholderSymbol = _props.placeholderSymbol; | ||
var _state = this.state; | ||
var displayValue = _state.displayValue; | ||
var interacting = _state.interacting; | ||
var other = _objectWithoutProperties(_props, ['start', 'stop', 'step', 'initialRate', 'placeholderRate', 'empty', 'full', 'placeholder', 'readonly', 'quiet', 'fractions', 'scale', 'onChange', 'onClick', 'onRate']); | ||
var symbolNodes = []; | ||
var emptySymbols = [].concat(this.props.empty); | ||
var placeholderSymbols = [].concat(this.props.placeholder); | ||
var fullSymbols = [].concat(this.props.full); | ||
// The symbol with the mouse over prevails over the selected one, | ||
// provided that we are not in quiet mode. | ||
var index = !quiet && this.state.indexOver !== undefined ? this.state.indexOver : this.state.index; | ||
// The index of the last full symbol or NaN if index is undefined. | ||
var lastFullIndex = Math.floor(index); | ||
// Render the number of whole symbols. | ||
var empty = [].concat(emptySymbol); | ||
var full = [].concat(fullSymbol); | ||
var placeholder = [].concat(placeholderSymbol); | ||
var shouldDisplayPlaceholder = placeholderValue !== undefined && value === 0 && !interacting; | ||
var icon = !this.state.selected && initialRate === undefined && placeholderRate !== undefined && (quiet || this.state.indexOver === undefined) ? placeholderSymbols : fullSymbols; | ||
// The value that will be used as base for calculating how to render the symbols | ||
var renderedValue = undefined; | ||
if (shouldDisplayPlaceholder) { | ||
renderedValue = placeholderValue; | ||
} else { | ||
renderedValue = quiet ? value : displayValue; | ||
} | ||
for (var i = 0; i < Math.floor(this._rateToIndex(stop)); i++) { | ||
// Return the percentage of the decimal part of the last full index, | ||
// 100 percent for those below the last full index or 0 percent for those | ||
// indexes NaN or above the last full index. | ||
var percent = i - lastFullIndex === 0 ? index % 1 * 100 : i - lastFullIndex < 0 ? 100 : 0; | ||
// The amount of full symbols | ||
var fullSymbols = Math.floor(renderedValue); | ||
var listeners = !readonly && { | ||
onClick: this.handleClick.bind(this, i), | ||
onMouseMove: this.handleMouseMove.bind(this, i), | ||
onTouchMove: this.handleMouseMove.bind(this, i), | ||
onTouchEnd: this.handleClick.bind(this, i) | ||
}; | ||
symbolNodes.push(_react2['default'].createElement(_PercentageSymbol2['default'], _extends({ | ||
for (var i = 0; i < totalSymbols; i++) { | ||
var percent = undefined; | ||
// Calculate each symbol's fullness percentage | ||
if (i - fullSymbols < 0) { | ||
percent = 100; | ||
} else if (i - fullSymbols === 0) { | ||
percent = (renderedValue - i) * 100; | ||
} else { | ||
percent = 0; | ||
} | ||
symbolNodes.push(_react2['default'].createElement(_RatingSymbol2['default'], { | ||
key: i, | ||
background: emptySymbols[i % emptySymbols.length], | ||
icon: icon[i % icon.length], | ||
percent: percent | ||
}, listeners, { | ||
direction: this.state.direction | ||
}))); | ||
index: i, | ||
readonly: readonly, | ||
inactiveIcon: empty[i % empty.length], | ||
activeIcon: shouldDisplayPlaceholder ? placeholder[i % full.length] : full[i % full.length], | ||
percent: percent, | ||
onClick: !readonly && this.symbolClick, | ||
onMouseMove: !readonly && this.symbolMouseMove, | ||
onTouchMove: !readonly && this.symbolMouseMove, | ||
onTouchEnd: !readonly && this.symbolClick, | ||
direction: direction | ||
})); | ||
} | ||
@@ -295,8 +494,7 @@ | ||
'span', | ||
_extends({ | ||
ref: function (container) { | ||
_this.ratingContainer = container; | ||
}, | ||
onMouseLeave: !readonly ? this.handleMouseLeave : undefined | ||
}, other), | ||
{ | ||
style: { display: 'inline-block', direction: direction }, | ||
onMouseEnter: !readonly ? this.onMouseEnter : undefined, | ||
onMouseLeave: !readonly ? this.onMouseLeave : undefined | ||
}, | ||
symbolNodes | ||
@@ -308,26 +506,13 @@ ); | ||
return Rating; | ||
})(_react2['default'].Component); | ||
})(_react2['default'].PureComponent); | ||
Rating.defaultProps = { | ||
start: 0, | ||
stop: 5, | ||
step: 1, | ||
empty: _style2['default'].empty, | ||
placeholder: _style2['default'].placeholder, | ||
full: _style2['default'].full, | ||
fractions: 1, | ||
scale: 3, | ||
onChange: function onChange(rate) {}, | ||
onClick: function onClick(rate) {}, | ||
onRate: function onRate(rate) {} | ||
}; | ||
// Define propTypes only in development. | ||
Rating.propTypes = "boolean" !== 'undefined' && (true) && { | ||
start: _propTypes2['default'].number, | ||
stop: _propTypes2['default'].number, | ||
step: _propTypes2['default'].number, | ||
initialRate: _propTypes2['default'].number, | ||
placeholderRate: _propTypes2['default'].number, | ||
empty: _propTypes2['default'].oneOfType([ | ||
totalSymbols: _propTypes2['default'].number.isRequired, | ||
value: _propTypes2['default'].number.isRequired, // Always >= 0 | ||
placeholderValue: _propTypes2['default'].number.isRequired, | ||
readonly: _propTypes2['default'].bool.isRequired, | ||
quiet: _propTypes2['default'].bool.isRequired, | ||
fractions: _propTypes2['default'].number.isRequired, | ||
direction: _propTypes2['default'].string.isRequired, | ||
emptySymbol: _propTypes2['default'].oneOfType([ | ||
// Array of class names and/or style objects. | ||
@@ -338,4 +523,4 @@ _propTypes2['default'].arrayOf(_propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element])), | ||
// Style objects. | ||
_propTypes2['default'].object]), | ||
placeholder: _propTypes2['default'].oneOfType([ | ||
_propTypes2['default'].object]).isRequired, | ||
fullSymbol: _propTypes2['default'].oneOfType([ | ||
// Array of class names and/or style objects. | ||
@@ -346,4 +531,4 @@ _propTypes2['default'].arrayOf(_propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element])), | ||
// Style objects. | ||
_propTypes2['default'].object]), | ||
full: _propTypes2['default'].oneOfType([ | ||
_propTypes2['default'].object]).isRequired, | ||
placeholderSymbol: _propTypes2['default'].oneOfType([ | ||
// Array of class names and/or style objects. | ||
@@ -355,28 +540,20 @@ _propTypes2['default'].arrayOf(_propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element])), | ||
_propTypes2['default'].object]), | ||
readonly: _propTypes2['default'].bool, | ||
quiet: _propTypes2['default'].bool, | ||
fractions: _propTypes2['default'].number, | ||
scale: _propTypes2['default'].number, | ||
onChange: _propTypes2['default'].func, | ||
onClick: _propTypes2['default'].func, | ||
onRate: _propTypes2['default'].func | ||
onClick: _propTypes2['default'].func.isRequired, | ||
onHover: _propTypes2['default'].func.isRequired | ||
}; | ||
module.exports = Rating; | ||
exports['default'] = Rating; | ||
module.exports = exports['default']; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; | ||
/***/ }), | ||
/* 3 */ | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(process) {/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
@@ -399,13 +576,13 @@ | ||
var throwOnDirectAccess = true; | ||
module.exports = __webpack_require__(5)(isValidElement, throwOnDirectAccess); | ||
module.exports = __webpack_require__(8)(isValidElement, throwOnDirectAccess); | ||
} else { | ||
// By explicitly using `prop-types` you are opting into new production behavior. | ||
// http://fb.me/prop-types-in-prod | ||
module.exports = __webpack_require__(12)(); | ||
module.exports = __webpack_require__(14)(); | ||
} | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) | ||
/***/ }), | ||
/* 4 */ | ||
/* 7 */ | ||
/***/ (function(module, exports) { | ||
@@ -583,7 +760,3 @@ | ||
process.emit = noop; | ||
process.prependListener = noop; | ||
process.prependOnceListener = noop; | ||
process.listeners = function (name) { return [] } | ||
process.binding = function (name) { | ||
@@ -601,10 +774,12 @@ throw new Error('process.binding is not supported'); | ||
/***/ }), | ||
/* 5 */ | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(process) {/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
@@ -614,9 +789,8 @@ | ||
var emptyFunction = __webpack_require__(6); | ||
var invariant = __webpack_require__(7); | ||
var warning = __webpack_require__(8); | ||
var assign = __webpack_require__(9); | ||
var emptyFunction = __webpack_require__(9); | ||
var invariant = __webpack_require__(10); | ||
var warning = __webpack_require__(11); | ||
var ReactPropTypesSecret = __webpack_require__(10); | ||
var checkPropTypes = __webpack_require__(11); | ||
var ReactPropTypesSecret = __webpack_require__(12); | ||
var checkPropTypes = __webpack_require__(13); | ||
@@ -717,4 +891,3 @@ module.exports = function(isValidElement, throwOnDirectAccess) { | ||
oneOfType: createUnionTypeChecker, | ||
shape: createShapeTypeChecker, | ||
exact: createStrictShapeTypeChecker, | ||
shape: createShapeTypeChecker | ||
}; | ||
@@ -929,16 +1102,2 @@ | ||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
var checker = arrayOfTypeCheckers[i]; | ||
if (typeof checker !== 'function') { | ||
warning( | ||
false, | ||
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + | ||
'received %s at index %s.', | ||
getPostfixForTypeWarning(checker), | ||
i | ||
); | ||
return emptyFunction.thatReturnsNull; | ||
} | ||
} | ||
function validate(props, propName, componentName, location, propFullName) { | ||
@@ -989,32 +1148,2 @@ for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
function createStrictShapeTypeChecker(shapeTypes) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | ||
} | ||
// We need to check all keys in case some are required but missing from | ||
// props. | ||
var allKeys = assign({}, props[propName], shapeTypes); | ||
for (var key in allKeys) { | ||
var checker = shapeTypes[key]; | ||
if (!checker) { | ||
return new PropTypeError( | ||
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + | ||
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') + | ||
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') | ||
); | ||
} | ||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); | ||
if (error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
function isNode(propValue) { | ||
@@ -1107,5 +1236,2 @@ switch (typeof propValue) { | ||
function getPreciseType(propValue) { | ||
if (typeof propValue === 'undefined' || propValue === null) { | ||
return '' + propValue; | ||
} | ||
var propType = getPropType(propValue); | ||
@@ -1122,19 +1248,2 @@ if (propType === 'object') { | ||
// Returns a string that is postfixed to a warning about an invalid type. | ||
// For example, "undefined" or "of type array" | ||
function getPostfixForTypeWarning(value) { | ||
var type = getPreciseType(value); | ||
switch (type) { | ||
case 'array': | ||
case 'object': | ||
return 'an ' + type; | ||
case 'boolean': | ||
case 'date': | ||
case 'regexp': | ||
return 'a ' + type; | ||
default: | ||
return type; | ||
} | ||
} | ||
// Returns class name of the object, if any. | ||
@@ -1154,6 +1263,6 @@ function getClassName(propValue) { | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) | ||
/***/ }), | ||
/* 6 */ | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
@@ -1165,5 +1274,7 @@ | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
@@ -1200,3 +1311,3 @@ * | ||
/***/ }), | ||
/* 7 */ | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1206,5 +1317,7 @@ | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
@@ -1258,13 +1371,15 @@ */ | ||
module.exports = invariant; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) | ||
/***/ }), | ||
/* 8 */ | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(process) {/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* Copyright 2014-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
@@ -1275,3 +1390,3 @@ */ | ||
var emptyFunction = __webpack_require__(6); | ||
var emptyFunction = __webpack_require__(9); | ||
@@ -1288,149 +1403,57 @@ /** | ||
if (process.env.NODE_ENV !== 'production') { | ||
var printWarning = function printWarning(format) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
(function () { | ||
var printWarning = function printWarning(format) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(message); | ||
} | ||
try { | ||
// --- Welcome to debugging React --- | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); | ||
} catch (x) {} | ||
}; | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(message); | ||
} | ||
try { | ||
// --- Welcome to debugging React --- | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); | ||
} catch (x) {} | ||
}; | ||
warning = function warning(condition, format) { | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
warning = function warning(condition, format) { | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
if (format.indexOf('Failed Composite propType: ') === 0) { | ||
return; // Ignore CompositeComponent proptype check. | ||
} | ||
if (format.indexOf('Failed Composite propType: ') === 0) { | ||
return; // Ignore CompositeComponent proptype check. | ||
} | ||
if (!condition) { | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
if (!condition) { | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
} | ||
printWarning.apply(undefined, [format].concat(args)); | ||
} | ||
printWarning.apply(undefined, [format].concat(args)); | ||
} | ||
}; | ||
}; | ||
})(); | ||
} | ||
module.exports = warning; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) | ||
/***/ }), | ||
/* 9 */ | ||
/* 12 */ | ||
/***/ (function(module, exports) { | ||
/* | ||
object-assign | ||
(c) Sindre Sorhus | ||
@license MIT | ||
*/ | ||
'use strict'; | ||
/* eslint-disable no-unused-vars */ | ||
var getOwnPropertySymbols = Object.getOwnPropertySymbols; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var propIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
function toObject(val) { | ||
if (val === null || val === undefined) { | ||
throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
} | ||
return Object(val); | ||
} | ||
function shouldUseNative() { | ||
try { | ||
if (!Object.assign) { | ||
return false; | ||
} | ||
// Detect buggy property enumeration order in older V8 versions. | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=4118 | ||
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers | ||
test1[5] = 'de'; | ||
if (Object.getOwnPropertyNames(test1)[0] === '5') { | ||
return false; | ||
} | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | ||
var test2 = {}; | ||
for (var i = 0; i < 10; i++) { | ||
test2['_' + String.fromCharCode(i)] = i; | ||
} | ||
var order2 = Object.getOwnPropertyNames(test2).map(function (n) { | ||
return test2[n]; | ||
}); | ||
if (order2.join('') !== '0123456789') { | ||
return false; | ||
} | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | ||
var test3 = {}; | ||
'abcdefghijklmnopqrst'.split('').forEach(function (letter) { | ||
test3[letter] = letter; | ||
}); | ||
if (Object.keys(Object.assign({}, test3)).join('') !== | ||
'abcdefghijklmnopqrst') { | ||
return false; | ||
} | ||
return true; | ||
} catch (err) { | ||
// We don't expect any of the above to throw, but better to be safe. | ||
return false; | ||
} | ||
} | ||
module.exports = shouldUseNative() ? Object.assign : function (target, source) { | ||
var from; | ||
var to = toObject(target); | ||
var symbols; | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = Object(arguments[s]); | ||
for (var key in from) { | ||
if (hasOwnProperty.call(from, key)) { | ||
to[key] = from[key]; | ||
} | ||
} | ||
if (getOwnPropertySymbols) { | ||
symbols = getOwnPropertySymbols(from); | ||
for (var i = 0; i < symbols.length; i++) { | ||
if (propIsEnumerable.call(from, symbols[i])) { | ||
to[symbols[i]] = from[symbols[i]]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}; | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports) { | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
@@ -1446,10 +1469,12 @@ | ||
/***/ }), | ||
/* 11 */ | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(process) {/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
@@ -1460,5 +1485,5 @@ | ||
if (process.env.NODE_ENV !== 'production') { | ||
var invariant = __webpack_require__(7); | ||
var warning = __webpack_require__(8); | ||
var ReactPropTypesSecret = __webpack_require__(10); | ||
var invariant = __webpack_require__(10); | ||
var warning = __webpack_require__(11); | ||
var ReactPropTypesSecret = __webpack_require__(12); | ||
var loggedTypeFailures = {}; | ||
@@ -1489,3 +1514,3 @@ } | ||
// behavior as without this statement except with a better message. | ||
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]); | ||
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName); | ||
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); | ||
@@ -1512,13 +1537,15 @@ } catch (ex) { | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) | ||
/***/ }), | ||
/* 12 */ | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
@@ -1528,12 +1555,9 @@ | ||
var emptyFunction = __webpack_require__(6); | ||
var invariant = __webpack_require__(7); | ||
var ReactPropTypesSecret = __webpack_require__(10); | ||
var emptyFunction = __webpack_require__(9); | ||
var invariant = __webpack_require__(10); | ||
module.exports = function() { | ||
function shim(props, propName, componentName, location, propFullName, secret) { | ||
if (secret === ReactPropTypesSecret) { | ||
// It is still safe when called from React. | ||
return; | ||
} | ||
// Important! | ||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. | ||
function shim() { | ||
invariant( | ||
@@ -1550,4 +1574,2 @@ false, | ||
}; | ||
// Important! | ||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. | ||
var ReactPropTypes = { | ||
@@ -1570,4 +1592,3 @@ array: shim, | ||
oneOfType: getShim, | ||
shape: getShim, | ||
exact: getShim | ||
shape: getShim | ||
}; | ||
@@ -1583,3 +1604,3 @@ | ||
/***/ }), | ||
/* 13 */ | ||
/* 15 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1589,51 +1610,18 @@ | ||
var merge = __webpack_require__(14); | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var style = { | ||
display: 'inline-block', | ||
borderRadius: '50%', | ||
border: '5px double white', | ||
width: 30, | ||
height: 30 | ||
}; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
module.exports = { | ||
empty: merge(style, { | ||
backgroundColor: '#ccc' | ||
}), | ||
full: merge(style, { | ||
backgroundColor: 'black' | ||
}), | ||
placeholder: merge(style, { | ||
backgroundColor: 'red' | ||
}) | ||
}; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
/***/ }), | ||
/* 14 */ | ||
/***/ (function(module, exports) { | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
module.exports = function () { | ||
var res = {}; | ||
for (var i = 0; i < arguments.length; i++) { | ||
var obj = arguments[i]; | ||
for (var k in obj) { | ||
res[k] = obj[k]; | ||
} | ||
} | ||
return res; | ||
}; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
/***/ }), | ||
/* 15 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _react = __webpack_require__(2); | ||
@@ -1643,3 +1631,3 @@ | ||
var _propTypes = __webpack_require__(3); | ||
var _propTypes = __webpack_require__(6); | ||
@@ -1664,44 +1652,105 @@ var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var PercentageSymbol = function PercentageSymbol(props) { | ||
var _iconContainerStyle; | ||
var RatingSymbol = (function (_React$PureComponent) { | ||
_inherits(RatingSymbol, _React$PureComponent); | ||
var backgroundNode = _iconNode(props.background); | ||
var iconNode = _iconNode(props.icon); | ||
var iconContainerStyle = (_iconContainerStyle = { | ||
display: 'inline-block', | ||
position: 'absolute', | ||
overflow: 'hidden', | ||
top: 0 | ||
}, _defineProperty(_iconContainerStyle, props.direction === 'rtl' ? 'right' : 'left', 0), _defineProperty(_iconContainerStyle, 'width', props.percent !== undefined ? props.percent + '%' : 'auto'), _iconContainerStyle); | ||
var style = { | ||
cursor: props.onClick || props.onMouseOver ? 'pointer' : 'auto', | ||
display: 'inline-block', | ||
position: 'relative' | ||
}; | ||
return _react2['default'].createElement( | ||
'span', | ||
{ style: style, | ||
onClick: props.onClick, | ||
onMouseMove: props.onMouseMove, | ||
onTouchMove: props.onMouseMove, | ||
onTouchEnd: props.onClick | ||
}, | ||
backgroundNode, | ||
_react2['default'].createElement( | ||
'span', | ||
{ style: iconContainerStyle }, | ||
iconNode | ||
) | ||
); | ||
}; | ||
function RatingSymbol() { | ||
_classCallCheck(this, RatingSymbol); | ||
// Define propTypes only in development. They will be void in production. | ||
PercentageSymbol.propTypes = "boolean" !== 'undefined' && (true) && { | ||
icon: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element]), | ||
background: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element]), | ||
percent: _propTypes2['default'].number | ||
_get(Object.getPrototypeOf(RatingSymbol.prototype), 'constructor', this).apply(this, arguments); | ||
} | ||
// Define propTypes only in development. They will be void in production. | ||
_createClass(RatingSymbol, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _iconContainerStyle; | ||
var _props = this.props; | ||
var index = _props.index; | ||
var inactiveIcon = _props.inactiveIcon; | ||
var activeIcon = _props.activeIcon; | ||
var percent = _props.percent; | ||
var direction = _props.direction; | ||
var readonly = _props.readonly; | ||
var onClick = _props.onClick; | ||
var onMouseMove = _props.onMouseMove; | ||
var backgroundNode = _iconNode(inactiveIcon); | ||
var iconNode = _iconNode(activeIcon); | ||
var iconContainerStyle = (_iconContainerStyle = { | ||
display: 'inline-block', | ||
position: 'absolute', | ||
overflow: 'hidden', | ||
top: 0 | ||
}, _defineProperty(_iconContainerStyle, direction === 'rtl' ? 'right' : 'left', 0), _defineProperty(_iconContainerStyle, 'width', percent + '%'), _iconContainerStyle); | ||
var style = { | ||
cursor: !readonly ? 'pointer' : 'auto', | ||
display: 'inline-block', | ||
position: 'relative' | ||
}; | ||
function handleMouseMove(e) { | ||
if (onMouseMove) { | ||
onMouseMove(index, e); | ||
} | ||
} | ||
function handleMouseClick(e) { | ||
if (onClick) { | ||
onClick(index, e); | ||
} | ||
} | ||
return _react2['default'].createElement( | ||
'span', | ||
{ | ||
style: style, | ||
onClick: handleMouseClick, | ||
onMouseMove: handleMouseMove, | ||
onTouchMove: handleMouseMove, | ||
onTouchEnd: handleMouseClick | ||
}, | ||
backgroundNode, | ||
_react2['default'].createElement( | ||
'span', | ||
{ style: iconContainerStyle }, | ||
iconNode | ||
) | ||
); | ||
} | ||
}]); | ||
return RatingSymbol; | ||
})(_react2['default'].PureComponent); | ||
RatingSymbol.propTypes = "boolean" !== 'undefined' && (true) && { | ||
index: _propTypes2['default'].number.isRequired, | ||
readonly: _propTypes2['default'].bool.isRequired, | ||
inactiveIcon: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element]).isRequired, | ||
activeIcon: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object, _propTypes2['default'].element]).isRequired, | ||
percent: _propTypes2['default'].number.isRequired, | ||
direction: _propTypes2['default'].string.isRequired, | ||
onClick: _propTypes2['default'].func, | ||
onMouseMove: _propTypes2['default'].func | ||
}; | ||
module.exports = PercentageSymbol; | ||
exports['default'] = RatingSymbol; | ||
module.exports = exports['default']; | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
function noop(value) {} | ||
noop._name = 'react_rating_noop'; | ||
exports['default'] = noop; | ||
module.exports = exports['default']; | ||
/***/ }) | ||
@@ -1708,0 +1757,0 @@ /******/ ]) |
@@ -1,7 +0,2 @@ | ||
/*! react-rating - 0.9.1 | (c) 2015, 2017 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(9)},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(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.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?h=d.concat(h):y=-1,h.length&&u())}function u(){if(!v){var e=o(a);v=!0;for(var t=h.length;t;){for(d=h,h=[];++y<t;)d&&d[y].run();y=-1,t=h.length}d=null,v=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function s(){}var l,f,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,h=[],v=!1,y=-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];h.push(new c(e,t)),1!==h.length||v||o(u)},c.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=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,p.prependListener=s,p.prependOnceListener=s,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,c){if(r(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,o,i,a,u,c],f=0;s=new Error(t.replace(/%s/g,function(){return l[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}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){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},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){(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(15)(o,i)}else e.exports=n(14)()}).call(t,n(1))},function(t,n){t.exports=e},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}var i=n(7),a=r(i),u=n(6),c=(r(u),function(e){return a.default.isValidElement(e)?e:"object"==typeof e&&null!==e?a.default.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?a.default.createElement("span",{className:e}):void 0}),s=function(e){var t,n=c(e.background),r=c(e.icon),i=(t={display:"inline-block",position:"absolute",overflow:"hidden",top:0},o(t,"rtl"===e.direction?"right":"left",0),o(t,"width",void 0!==e.percent?e.percent+"%":"auto"),t),u={cursor:e.onClick||e.onMouseOver?"pointer":"auto",display:"inline-block",position:"relative"};return a.default.createElement("span",{style:u,onClick:e.onClick,onMouseMove:e.onMouseMove,onTouchMove:e.onMouseMove,onTouchEnd:e.onClick},n,a.default.createElement("span",{style:i},r))};s.propTypes=!1,e.exports=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}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)}var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=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}}(),s=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 c=u.get;if(void 0===c)return;return c.call(a)}var s=Object.getPrototypeOf(o);if(null===s)return;e=s,t=i,n=a,r=!0,u=s=void 0}},l=n(7),f=r(l),p=n(6),d=(r(p),n(11)),h=r(d),v=n(8),y=r(v),b=function(e,t){var n=e.step,r=n>0?e.start:e.stop,o=n>0?e.stop:e.start;if(n&&r<=t&&t<=o)return(t-e.start)/n},g=function(e){function t(e){i(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e);var n=void 0!==e.initialRate?e.initialRate:e.placeholderRate;this.state={index:b(e,n),indexOver:void 0,direction:"ltr"},this.ratingContainer=null,this.handleClick=this.handleClick.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this)}return a(t,e),c(t,[{key:"componentDidMount",value:function(){this.setState({direction:window.getComputedStyle(this.ratingContainer,null).getPropertyValue("direction")})}},{key:"componentWillReceiveProps",value:function(e){var t=void 0!==e.initialRate?e.initialRate:e.placeholderRate;this.setState({index:b(e,t),selected:void 0!==e.initialRate})}},{key:"handleClick",value:function(e,t){if(!this.props.readonly){var n=e+this._fractionalIndex(t);this.props.onClick(this._indexToRate(n),t),this.state.index!==n&&(this.props.onChange(this._indexToRate(n)),this.setState({indexOver:void 0,index:n,selected:!0}))}}},{key:"handleMouseLeave",value:function(){this.props.readonly||(this.props.onRate(),this.setState({indexOver:void 0}))}},{key:"handleMouseMove",value:function(e,t){if(!this.props.readonly){var n=e+this._fractionalIndex(t);this.state.indexOver!==n&&(this.props.onRate(this._indexToRate(n)),this.setState({indexOver:n}))}}},{key:"_indexToRate",value:function(e){return this.props.start+Math.floor(e)*this.props.step+this.props.step*this._roundToFraction(e%1)}},{key:"_rateToIndex",value:function(e){return b(this.props,e)}},{key:"_roundToFraction",value:function(e){var t=Math.ceil(e%1*this.props.fractions)/this.props.fractions,n=Math.pow(10,this.props.scale),r=Math.floor(e)+Math.floor(t*n)/n;return r>this.props.stop?this.props.stop:r}},{key:"_fractionalIndex",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="rtl"===this.state.direction?e.currentTarget.getBoundingClientRect().right-t:t-e.currentTarget.getBoundingClientRect().left;return this._roundToFraction(n/e.currentTarget.offsetWidth)}},{key:"render",value:function(){for(var e=this,t=this.props,n=(t.start,t.stop),r=(t.step,t.initialRate),i=t.placeholderRate,a=(t.empty,t.full,t.placeholder,t.readonly),c=t.quiet,s=(t.fractions,t.scale,t.onChange,t.onClick,t.onRate,o(t,["start","stop","step","initialRate","placeholderRate","empty","full","placeholder","readonly","quiet","fractions","scale","onChange","onClick","onRate"])),l=[],p=[].concat(this.props.empty),d=[].concat(this.props.placeholder),h=[].concat(this.props.full),v=c||void 0===this.state.indexOver?this.state.index:this.state.indexOver,b=Math.floor(v),g=this.state.selected||void 0!==r||void 0===i||!c&&void 0!==this.state.indexOver?h:d,m=0;m<Math.floor(this._rateToIndex(n));m++){var O=m-b===0?v%1*100:m-b<0?100:0,x=!a&&{onClick:this.handleClick.bind(this,m),onMouseMove:this.handleMouseMove.bind(this,m),onTouchMove:this.handleMouseMove.bind(this,m),onTouchEnd:this.handleClick.bind(this,m)};l.push(f.default.createElement(y.default,u({key:m,background:p[m%p.length],icon:g[m%g.length],percent:O},x,{direction:this.state.direction})))}return f.default.createElement("span",u({ref:function(t){e.ratingContainer=t},onMouseLeave:a?void 0:this.handleMouseLeave},s),l)}}]),t}(f.default.Component);g.defaultProps={start:0,stop:5,step:1,empty:h.default.empty,placeholder:h.default.placeholder,full:h.default.full,fractions:1,scale:3,onChange:function(e){},onClick:function(e){},onRate:function(e){}},g.propTypes=!1,e.exports=g},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(10),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 | ||
(c) Sindre Sorhus | ||
@license MIT | ||
*/ | ||
"use strict";function n(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}var o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=r()?Object.assign:function(e,t){for(var r,u,c=n(e),s=1;s<arguments.length;s++){r=Object(arguments[s]);for(var l in r)i.call(r,l)&&(c[l]=r[l]);if(o){u=o(r);for(var f=0;f<u.length;f++)a.call(r,u[f])&&(c[u[f]]=r[u[f]])}}return c}},function(e,t,n){(function(t){"use strict";function r(e,n,r,c,s){if("production"!==t.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var f;try{o("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.",c||"React class",r,l,typeof e[l]),f=e[l](n,l,c,r,null,a)}catch(e){f=e}if(i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",r,l,typeof f),f instanceof Error&&!(f.message in u)){u[f.message]=!0;var p=s?s():"";i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(3),i=n(5),a=n(4),u={};e.exports=r}).call(t,n(1))},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(4);e.exports=function(){function e(e,t,n,r,a,u){u!==i&&o(!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=r,n.PropTypes=n,n}},function(e,t,n){(function(t){"use strict";var r=n(2),o=n(3),i=n(5),a=n(12),u=n(4),c=n(13);e.exports=function(e,n){function s(e){var t=e&&(P&&e[P]||e[C]);if("function"==typeof t)return t}function l(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function f(e){this.message=e,this.stack=""}function p(e){function r(r,s,l,p,d,h,v){if(p=p||N,h=h||l,v!==u)if(n)o(!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");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var y=p+":"+l;!a[y]&&c<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",h,p),a[y]=!0,c++)}return null==s[l]?r?new f(null===s[l]?"The "+d+" `"+h+"` is marked as required "+("in `"+p+"`, but its value is `null`."):"The "+d+" `"+h+"` is marked as required in "+("`"+p+"`, but its value is `undefined`.")):null:e(s,l,p,d,h)}if("production"!==t.env.NODE_ENV)var a={},c=0;var s=r.bind(null,!1);return s.isRequired=r.bind(null,!0),s}function d(e){function t(t,n,r,o,i,a){var u=t[n],c=j(u);if(c!==e){var s=R(u);return new f("Invalid "+o+" `"+i+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("`"+e+"`."))}return null}return p(t)}function h(){return p(r.thatReturnsNull)}function v(e){function t(t,n,r,o,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){var c=j(a);return new f("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an array."))}for(var s=0;s<a.length;s++){var l=e(a,s,r,o,i+"["+s+"]",u);if(l instanceof Error)return l}return null}return p(t)}function y(){function t(t,n,r,o,i){var a=t[n];if(!e(a)){var u=j(a);return new f("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return p(t)}function b(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var a=e.name||N,u=M(t[n]);return new f("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected ")+("instance of `"+a+"`."))}return null}return p(t)}function g(e){function n(t,n,r,o,i){for(var a=t[n],u=0;u<e.length;u++)if(l(a,e[u]))return null;var c=JSON.stringify(e);return new f("Invalid "+o+" `"+i+"` of value `"+a+"` "+("supplied to `"+r+"`, expected one of "+c+"."))}return Array.isArray(e)?p(n):("production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOf, expected an instance of array."):void 0,r.thatReturnsNull)}function m(e){function t(t,n,r,o,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=t[n],c=j(a);if("object"!==c)return new f("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an object."));for(var s in a)if(a.hasOwnProperty(s)){var l=e(a,s,r,o,i+"."+s,u);if(l instanceof Error)return l}return null}return p(t)}function O(e){function n(t,n,r,o,i){for(var a=0;a<e.length;a++){var c=e[a];if(null==c(t,n,r,o,i,u))return null}return new f("Invalid "+o+" `"+i+"` supplied to "+("`"+r+"`."))}if(!Array.isArray(e))return"production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."):void 0,r.thatReturnsNull;for(var o=0;o<e.length;o++){var a=e[o];if("function"!=typeof a)return i(!1,"Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",_(a),o),r.thatReturnsNull}return p(n)}function x(){function e(e,t,n,r,o){return k(e[t])?null:new f("Invalid "+r+" `"+o+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return p(e)}function w(e){function t(t,n,r,o,i){var a=t[n],c=j(a);if("object"!==c)return new f("Invalid "+o+" `"+i+"` of type `"+c+"` "+("supplied to `"+r+"`, expected `object`."));for(var s in e){var l=e[s];if(l){var p=l(a,s,r,o,i+"."+s,u);if(p)return p}}return null}return p(t)}function T(e){function t(t,n,r,o,i){var c=t[n],s=j(c);if("object"!==s)return new f("Invalid "+o+" `"+i+"` of type `"+s+"` "+("supplied to `"+r+"`, expected `object`."));var l=a({},t[n],e);for(var p in l){var d=e[p];if(!d)return new f("Invalid "+o+" `"+i+"` key `"+p+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var h=d(c,p,r,o,i+"."+p,u);if(h)return h}return null}return p(t)}function k(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(k);if(null===t||e(t))return!0;var n=s(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!k(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!k(i[1]))return!1}return!0;default:return!1}}function E(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function j(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":E(t,e)?"symbol":t}function R(e){if("undefined"==typeof e||null===e)return""+e;var t=j(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function _(e){var t=R(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}function M(e){return e.constructor&&e.constructor.name?e.constructor.name:N}var P="function"==typeof Symbol&&Symbol.iterator,C="@@iterator",N="<<anonymous>>",S={array:d("array"),bool:d("boolean"),func:d("function"),number:d("number"),object:d("object"),string:d("string"),symbol:d("symbol"),any:h(),arrayOf:v,element:y(),instanceOf:b,node:x(),objectOf:m,oneOf:g,oneOfType:O,shape:w,exact:T};return f.prototype=Error.prototype,S.checkPropTypes=c,S.PropTypes=S,S}}).call(t,n(1))}])}); | ||
/*! react-rating - 1.0.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(9)},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(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.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 s(){}var c,f,p=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=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=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,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 s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,i,a,u,l],f=0;s=new Error(t.replace(/%s/g,function(){return c[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}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(t,n){t.exports=e},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(16)(o,i)}else e.exports=n(15)()}).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(e,t,n){(function(t){"use strict";var r=n(2),o=r;"production"!==t.env.NODE_ENV&&!function(){var e=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(t,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!t){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e.apply(void 0,[n].concat(o))}}}(),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 s=Object.getPrototypeOf(o);if(null===s)return;e=s,t=i,n=a,r=!0,u=s=void 0}},l=n(4),s=r(l),c=n(5),f=(r(c),n(10)),p=r(f),d=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){this.setState({dirty:this.props.value!==e.value&&!this.state.dirty||this.state.dirty,displayValue:e.value})}},{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){this.props.onClick(this.state.displayValue,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="rtl"===this.props.direction?e.target.getBoundingClientRect().right-t:t-e.target.getBoundingClientRect().left;return n<0?0:n/e.target.offsetWidth}},{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,c=e.placeholderSymbol,f=this.state,d=f.displayValue,y=f.interacting,v=[],h=[].concat(u),b=[].concat(l),m=[].concat(c),g=void 0!==i&&0===o&&!y,O=void 0;O=g?i:n?o:d;for(var w=Math.floor(O),T=0;T<r;T++){var E=void 0;E=T-w<0?100:T-w===0?100*(O-T):0,v.push(s.default.createElement(p.default,{key:T,index:T,readonly:t,inactiveIcon:h[T%h.length],activeIcon:g?m[T%b.length]:b[T%b.length],percent:E,onClick:!t&&this.symbolClick,onMouseMove:!t&&this.symbolMouseMove,onTouchMove:!t&&this.symbolMouseMove,onTouchEnd:!t&&this.symbolClick,direction:a}))}return s.default.createElement("span",{style:{display:"inline-block",direction:a},onMouseEnter:t?void 0:this.onMouseEnter,onMouseLeave:t?void 0:this.onMouseLeave},v)}}]),t}(s.default.PureComponent);d.propTypes=!1,t.default=d,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 s=Object.getPrototypeOf(o);if(null===s)return;e=s,t=i,n=a,r=!0,u=s=void 0}},l=n(4),s=r(l),c=n(13),f=r(c),p=n(8),d=r(p),y=n(12),v=r(y),h=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,c=t.direction,f=t.start,p=t.stop;return s.default.createElement(d.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:c,emptySymbol:r,fullSymbol:o,placeholderSymbol:i,onClick:this.handleClick,onHover:this.handleHover})}}]),t}(s.default.PureComponent);h.defaultProps={start:0,stop:5,step:1,readonly:!1,quiet:!1,fractions:1,direction:"ltr",onChange:v.default,onHover:v.default,emptySymbol:f.default.empty,fullSymbol:f.default.full,placeholderSymbol:f.default.placeholder},h.propTypes=!1,t.default=h,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 s=Object.getPrototypeOf(o);if(null===s)return;e=s,t=i,n=a,r=!0,u=s=void 0}},s=n(4),c=r(s),f=n(5),p=(r(f),function(e){return c.default.isValidElement(e)?e:"object"==typeof e&&null!==e?c.default.createElement("span",{style:e}):"[object String]"===Object.prototype.toString.call(e)?c.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&&d(i,e)}var n,r=this.props,i=r.index,a=r.inactiveIcon,u=r.activeIcon,l=r.percent,s=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"===s?"right":"left",0),o(n,"width",l+"%"),n),m={cursor:f?"auto":"pointer",display:"inline-block",position:"relative"};return c.default.createElement("span",{style:m,onClick:t,onMouseMove:e,onTouchMove:e,onTouchEnd:t},v,c.default.createElement("span",{style:b},h))}}]),t}(c.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){"use strict";function n(e){}Object.defineProperty(t,"__esModule",{value:!0}),n._name="react_rating_noop",t.default=n,e.exports=t.default},function(e,t,n){"use strict";var r=n(11),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,n){(function(t){"use strict";function r(e,n,r,l,s){if("production"!==t.env.NODE_ENV)for(var c in e)if(e.hasOwnProperty(c)){var f;try{o("function"==typeof e[c],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",l||"React class",r,c),f=e[c](n,c,l,r,null,a)}catch(e){f=e}if(i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",l||"React class",r,c,typeof f),f instanceof Error&&!(f.message in u)){u[f.message]=!0;var p=s?s():"";i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(3),i=n(7),a=n(6),u={};e.exports=r}).call(t,n(1))},function(e,t,n){"use strict";var r=n(2),o=n(3);e.exports=function(){function e(){o(!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};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){(function(t){"use strict";var r=n(2),o=n(3),i=n(7),a=n(6),u=n(14);e.exports=function(e,n){function l(e){var t=e&&(j&&e[j]||e[_]);if("function"==typeof t)return t}function s(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function c(e){this.message=e,this.stack=""}function f(e){function r(r,s,f,p,d,y,v){if(p=p||M,y=y||f,v!==a)if(n)o(!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");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var h=p+":"+f;!u[h]&&l<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",y,p),u[h]=!0,l++)}return null==s[f]?r?new c(null===s[f]?"The "+d+" `"+y+"` is marked as required "+("in `"+p+"`, but its value is `null`."):"The "+d+" `"+y+"` is marked as required in "+("`"+p+"`, but its value is `undefined`.")):null:e(s,f,p,d,y)}if("production"!==t.env.NODE_ENV)var u={},l=0;var s=r.bind(null,!1);return s.isRequired=r.bind(null,!0),s}function p(e){function t(t,n,r,o,i,a){var u=t[n],l=k(u);if(l!==e){var s=x(u);return new c("Invalid "+o+" `"+i+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("`"+e+"`."))}return null}return f(t)}function d(){return f(r.thatReturnsNull)}function y(e){function t(t,n,r,o,i){if("function"!=typeof e)return new c("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u)){var l=k(u);return new c("Invalid "+o+" `"+i+"` of type "+("`"+l+"` supplied to `"+r+"`, expected an array."))}for(var s=0;s<u.length;s++){var f=e(u,s,r,o,i+"["+s+"]",a);if(f instanceof Error)return f}return null}return f(t)}function v(){function t(t,n,r,o,i){var a=t[n];if(!e(a)){var u=k(a);return new c("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return f(t)}function h(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var a=e.name||M,u=P(t[n]);return new c("Invalid "+o+" `"+i+"` of type "+("`"+u+"` supplied to `"+r+"`, expected ")+("instance of `"+a+"`."))}return null}return f(t)}function b(e){function n(t,n,r,o,i){for(var a=t[n],u=0;u<e.length;u++)if(s(a,e[u]))return null;var l=JSON.stringify(e);return new c("Invalid "+o+" `"+i+"` of value `"+a+"` "+("supplied to `"+r+"`, expected one of "+l+"."))}return Array.isArray(e)?f(n):("production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOf, expected an instance of array."):void 0,r.thatReturnsNull)}function m(e){function t(t,n,r,o,i){if("function"!=typeof e)return new c("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var u=t[n],l=k(u);if("object"!==l)return new c("Invalid "+o+" `"+i+"` of type "+("`"+l+"` supplied to `"+r+"`, expected an object."));for(var s in u)if(u.hasOwnProperty(s)){var f=e(u,s,r,o,i+"."+s,a);if(f instanceof Error)return f}return null}return f(t)}function g(e){function n(t,n,r,o,i){for(var u=0;u<e.length;u++){var l=e[u];if(null==l(t,n,r,o,i,a))return null}return new c("Invalid "+o+" `"+i+"` supplied to "+("`"+r+"`."))}return Array.isArray(e)?f(n):("production"!==t.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."):void 0,r.thatReturnsNull)}function O(){function e(e,t,n,r,o){return T(e[t])?null:new c("Invalid "+r+" `"+o+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return f(e)}function w(e){function t(t,n,r,o,i){var u=t[n],l=k(u);if("object"!==l)return new c("Invalid "+o+" `"+i+"` of type `"+l+"` "+("supplied to `"+r+"`, expected `object`."));for(var s in e){var f=e[s];if(f){var p=f(u,s,r,o,i+"."+s,a);if(p)return p}}return null}return f(t)}function T(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(T);if(null===t||e(t))return!0;var n=l(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!T(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!T(i[1]))return!1}return!0;default:return!1}}function E(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function k(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":E(t,e)?"symbol":t}function x(e){var t=k(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function P(e){return e.constructor&&e.constructor.name?e.constructor.name:M}var j="function"==typeof Symbol&&Symbol.iterator,_="@@iterator",M="<<anonymous>>",S={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:d(),arrayOf:y,element:v(),instanceOf:h,node:O(),objectOf:m,oneOf:b,oneOfType:g,shape:w};return c.prototype=Error.prototype,S.checkPropTypes=u,S.PropTypes=S,S}}).call(t,n(1))}])}); |
{ | ||
"name": "react-rating", | ||
"version": "0.9.1", | ||
"version": "1.0.0", | ||
"description": "A rating react component with custom symbols", | ||
@@ -5,0 +5,0 @@ "main": "lib/react-rating.js", |
@@ -5,3 +5,3 @@ # React Rating | ||
I intend to port the jQuery [bootstrap-rating](https://github.com/dreyescat/bootstrap-rating) to a React component. | ||
This React component was inspired by the jQuery plugin [bootstrap-rating](https://github.com/dreyescat/bootstrap-rating). | ||
@@ -30,2 +30,6 @@ ## Demo | ||
## Upgrade Warning | ||
If you are using a version of React Rating < v1.0 be aware that **there are API changes between anything < v1.0 and v1.0 .** See the **Properties** and **Deprecated Properties and Callbacks** sections below for a documentation of the current API and how it compares to the old. | ||
## Usage | ||
@@ -59,11 +63,12 @@ | ||
`stop` | *number* | 5 | Range stop value (inclusive). | ||
`step` | *number* | 1 | Step increment (positive) or decrement (negative). | ||
`placeholderRate` | *number* | undefined | Placeholder rate value. | ||
`initialRate` | *number* | undefined | Initial rate value. | ||
`empty` | *element* or *object* or *string* or *array* | Style.empty | React element, inline style object, or classes applied to the rating symbols when empty. Or an array of such symbols that will be applied in a circular manner (round-robin). | ||
`placeholder` | *element* or *object* or *string* or *array* | Style.full | React element, inline style object, or classes applied to the rating symbols in HTML input placeholder fashion. Or an array of such symbols that will be applied in a circular manner (round-robin). | ||
`full` | *element* or *object* or *string* or *array* | Style.full | React element, inline style object, or classes applied to the rating symbols when full. Or an array of such symbols that will be applied in a circular manner (round-robin). | ||
`step` | *number* | 1 | Describes how many values each Symbol represents. For example, for a `start` value of 0, a `stop` value of 10 and a `step` of 2, we will end up with 5 Symbols, with each Symbol representing value increments of 2. | ||
`fractions` | *number* | 1 | Number of equal subdivisions that can be selected as a rating in each Symbol. For example, for a `fractions` value of 2, you will be able to select a rating with a precision of down to half a Symbol. Must be >= 1 | ||
`initialRating` | *number* | 0 | The value that will be used as an initial rating. This is the old `initialRate`. | ||
`placeholderRating` | *number* | 0 | If you do not define an `initialRating` value, you can use a placeholder rating. Visually, this will have the same result as if you had defined an `initialRating` value. If `initialRating` is set `placeholderRating` is not taken into account. This is the old `placeholderRate` | ||
`readonly` | *bool* | false | Whether the rating can be modified or not. | ||
`quiet` | *bool* | false | Whether to animate rate hovering or not. | ||
`fractions` | *number* | 1 | Number of equal parts that make up a whole symbol. | ||
`direction` | *ltr* or *rtl* | ltr | The direction of the rating element contents | ||
`emptySymbol` | *element* or *object* or *string* or *array* | Style.empty | React element, inline style object, or classes applied to the rating symbols when empty. Can also be an array of such symbols that will be applied in a circular manner (round-robin). This is the old `empty`. | ||
`fullSymbol` | *element* or *object* or *string* or *array* | Style.full | React element, inline style object, or classes applied to the rating symbols when full. Can also be an array of such symbols that will be applied in a circular manner (round-robin). This is the old `full`. | ||
`placeholderSymbol` | *element* or *object* or *string* or *array* | Style.placeholder | React element, inline style object, or classes applied to the placeholder rating symbols. Can also be an array of such symbols that will be applied in a circular manner (round-robin). This is the old `placeholder`. | ||
@@ -74,8 +79,19 @@ ## Callbacks | ||
--- | --- | --- | ||
`onChange` | function (rate) {} | Called when the selected rate is changed. | ||
`onClick` | function (rate, event) {} | Called when a rate is clicked. | ||
`onRate` | function (rate) {} | Called when a rate is entered or left. When a rate is left it is called with `undefined`. | ||
`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. | ||
## Deprecated Properties and Callbacks | ||
This is a list of deprecated properties and callbacks from versions older than v1.0 | ||
* `onClick` | ||
* `onRate` | ||
* `initialRate` | ||
* `placeholderRate` | ||
* `empty` | ||
* `full` | ||
* `placeholder` | ||
## License | ||
[MIT License](https://github.com/dreyescat/react-rating/blob/master/LICENSE.md) |
@@ -1,95 +0,48 @@ | ||
'use strict'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types' | ||
import Style from './style'; | ||
import Symbol from './PercentageSymbol'; | ||
import PropTypes from 'prop-types'; | ||
import Symbol from './RatingSymbol'; | ||
// Returns the index of the rate in the range (start, stop, step). | ||
// Returns undefined index if the rate is outside the range. | ||
// NOTE: A range.step of 0 produces an empty range and consequently returns an | ||
// undefined index. | ||
const indexOf = (range, rate) => { | ||
// Check the rate is in the proper range [start..stop] according to | ||
// the start, stop and step properties in props. | ||
const step = range.step; | ||
const start = step > 0 ? range.start : range.stop; | ||
const stop = step > 0 ? range.stop : range.start; | ||
if (step && start <= rate && rate <= stop) { | ||
// The index corresponds to the number of steps of size props.step | ||
// that fits between rate and start. | ||
// This index does not need to be a whole number because we can have | ||
// fractional symbols, and consequently fractional/float indexes. | ||
return (rate - range.start) / step; | ||
} | ||
}; | ||
class Rating extends React.Component { | ||
class Rating extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
const index = props.initialRate !== undefined ? | ||
props.initialRate : props.placeholderRate; | ||
this.state = { | ||
index: indexOf(props, index), | ||
indexOver: undefined, | ||
// Default direction is left to right | ||
direction: 'ltr' | ||
// Indicates the value that is displayed to the user in the form of symbols. | ||
// It can be either 0 (for no displayed symbols) or (0, end] | ||
displayValue: this.props.value, | ||
// Indicates if the user is currently hovering over the rating element | ||
interacting: false, | ||
// Indicates if the rating element has been clicked even once | ||
dirty: false | ||
}; | ||
this.ratingContainer = null; | ||
this.handleClick = this.handleClick.bind(this); | ||
this.handleMouseLeave = this.handleMouseLeave.bind(this); | ||
this.handleMouseMove = this.handleMouseMove.bind(this); | ||
this.onMouseEnter = this.onMouseEnter.bind(this); | ||
this.onMouseLeave = this.onMouseLeave.bind(this); | ||
this.symbolMouseMove = this.symbolMouseMove.bind(this); | ||
this.symbolClick = this.symbolClick.bind(this); | ||
} | ||
componentDidMount() { | ||
this.setState({ | ||
// detect the computed direction style for the mounted component | ||
direction: window.getComputedStyle(this.ratingContainer, null).getPropertyValue("direction") | ||
}); | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
const rate = nextProps.initialRate !== undefined ? | ||
nextProps.initialRate : nextProps.placeholderRate; | ||
this.setState({ | ||
index: indexOf(nextProps, rate), | ||
selected: nextProps.initialRate !== undefined | ||
dirty: this.props.value !== nextProps.value && !this.state.dirty | ||
? true | ||
: this.state.dirty, | ||
displayValue: nextProps.value | ||
}); | ||
} | ||
handleClick(i, event) { | ||
if (this.props.readonly) { | ||
return | ||
componentDidUpdate(prevProps, prevState) { | ||
// Ensure we do not call this.props.onHover on clicks or on mouseLeave | ||
if (prevState.displayValue !== this.state.displayValue && this.state.interacting) { | ||
this.props.onHover(this.state.displayValue); | ||
} | ||
const index = i + this._fractionalIndex(event); | ||
this.props.onClick(this._indexToRate(index), event); | ||
if (this.state.index !== index) { | ||
this.props.onChange(this._indexToRate(index)); | ||
this.setState({ | ||
indexOver: undefined, | ||
index: index, | ||
selected: true | ||
}); | ||
} | ||
} | ||
handleMouseLeave() { | ||
if (this.props.readonly) { | ||
return | ||
} | ||
this.props.onRate(); | ||
this.setState({ | ||
indexOver: undefined | ||
}); | ||
symbolClick(symbolIndex, event) { | ||
this.props.onClick(this.state.displayValue, event); | ||
} | ||
handleMouseMove(i, event) { | ||
if (this.props.readonly) { | ||
return | ||
} | ||
const index = i + this._fractionalIndex(event); | ||
if (this.state.indexOver !== index) { | ||
this.props.onRate(this._indexToRate(index)); | ||
symbolMouseMove(symbolIndex, event) { | ||
const value = this.calculateDisplayValue(symbolIndex, event); | ||
if (value !== this.state.displayValue) { | ||
this.setState({ | ||
indexOver: index | ||
displayValue: value | ||
}); | ||
@@ -99,33 +52,40 @@ } | ||
// Calculate the rate of an index according the the start and step. | ||
_indexToRate(index) { | ||
return this.props.start + Math.floor(index) * this.props.step + | ||
this.props.step * this._roundToFraction(index % 1); | ||
onMouseEnter() { | ||
this.setState({ | ||
interacting: !this.props.readonly | ||
}); | ||
} | ||
// Calculate the corresponding index for a rate according to the provided | ||
// props or this.props. | ||
_rateToIndex(rate) { | ||
return indexOf(this.props, rate); | ||
onMouseLeave() { | ||
this.setState({ | ||
displayValue: this.props.value, | ||
interacting: false | ||
}); | ||
} | ||
_roundToFraction(index) { | ||
calculateDisplayValue(symbolIndex, event) { | ||
const percentage = this.calculateHoverPercentage(event); | ||
// Get the closest top fraction. | ||
const fraction = Math.ceil(index % 1 * this.props.fractions) / this.props.fractions; | ||
const fraction = Math.ceil(percentage % 1 * this.props.fractions) / this.props.fractions; | ||
// Truncate decimal trying to avoid float precission issues. | ||
const precision = Math.pow(10, this.props.scale); | ||
const roundedValue = Math.floor(index) + Math.floor(fraction * precision) / precision; | ||
// Handles bugs when the touchend is past the star stop | ||
return roundedValue > this.props.stop ? this.props.stop : roundedValue; | ||
const precision = 10 ** 3; | ||
const displayValue = | ||
symbolIndex + (Math.floor(percentage) + Math.floor(fraction * precision) / precision); | ||
// ensure the returned value is greater than 0 | ||
return displayValue > 0 ? displayValue : 1 / this.props.fractions; | ||
} | ||
_fractionalIndex(event) { | ||
const clientX = event.nativeEvent.type.indexOf("touch") > -1 ? | ||
event.nativeEvent.type.indexOf("touchend") > -1 ? | ||
event.changedTouches[0].clientX : event.touches[0].clientX | ||
calculateHoverPercentage(event) { | ||
const clientX = event.nativeEvent.type.indexOf("touch") > -1 | ||
? event.nativeEvent.type.indexOf("touchend") > -1 | ||
? event.changedTouches[0].clientX | ||
: event.touches[0].clientX | ||
: event.clientX; | ||
const x = this.state.direction === 'rtl' ? | ||
event.currentTarget.getBoundingClientRect().right - clientX : | ||
clientX - event.currentTarget.getBoundingClientRect().left; | ||
return this._roundToFraction(x / event.currentTarget.offsetWidth); | ||
const delta = this.props.direction === 'rtl' | ||
? event.target.getBoundingClientRect().right - clientX | ||
: clientX - event.target.getBoundingClientRect().left; | ||
// Returning 0 if the delta is negative solves the flickering issue | ||
return delta < 0 ? 0 : delta / event.target.offsetWidth; | ||
} | ||
@@ -135,58 +95,59 @@ | ||
const { | ||
start, | ||
stop, | ||
step, | ||
initialRate, | ||
placeholderRate, | ||
empty, | ||
full, | ||
placeholder, | ||
readonly, | ||
quiet, | ||
fractions, | ||
scale, | ||
onChange, | ||
onClick, | ||
onRate, | ||
...other | ||
totalSymbols, | ||
value, | ||
placeholderValue, | ||
direction, | ||
emptySymbol, | ||
fullSymbol, | ||
placeholderSymbol | ||
} = this.props; | ||
const { displayValue, interacting } = this.state; | ||
const symbolNodes = []; | ||
const emptySymbols = [].concat(this.props.empty); | ||
const placeholderSymbols = [].concat(this.props.placeholder); | ||
const fullSymbols = [].concat(this.props.full); | ||
// The symbol with the mouse over prevails over the selected one, | ||
// provided that we are not in quiet mode. | ||
const index = !quiet && this.state.indexOver !== undefined ? | ||
this.state.indexOver : this.state.index; | ||
// The index of the last full symbol or NaN if index is undefined. | ||
const lastFullIndex = Math.floor(index); | ||
// Render the number of whole symbols. | ||
const empty = [].concat(emptySymbol); | ||
const full = [].concat(fullSymbol); | ||
const placeholder = [].concat(placeholderSymbol); | ||
const shouldDisplayPlaceholder = | ||
placeholderValue !== undefined && | ||
value === 0 && | ||
!interacting; | ||
const icon = !this.state.selected && | ||
initialRate === undefined && | ||
placeholderRate !== undefined && | ||
(quiet || this.state.indexOver === undefined) ? | ||
placeholderSymbols : fullSymbols; | ||
// The value that will be used as base for calculating how to render the symbols | ||
let renderedValue; | ||
if (shouldDisplayPlaceholder) { | ||
renderedValue = placeholderValue; | ||
} else { | ||
renderedValue = quiet ? value : displayValue; | ||
} | ||
for (let i = 0; i < Math.floor(this._rateToIndex(stop)); i++) { | ||
// Return the percentage of the decimal part of the last full index, | ||
// 100 percent for those below the last full index or 0 percent for those | ||
// indexes NaN or above the last full index. | ||
const percent = i - lastFullIndex === 0 ? index % 1 * 100 : | ||
i - lastFullIndex < 0 ? 100 : 0; | ||
// The amount of full symbols | ||
const fullSymbols = Math.floor(renderedValue); | ||
const listeners = !readonly && { | ||
onClick: this.handleClick.bind(this, i), | ||
onMouseMove: this.handleMouseMove.bind(this, i), | ||
onTouchMove: this.handleMouseMove.bind(this, i), | ||
onTouchEnd: this.handleClick.bind(this, i) | ||
}; | ||
for (let i = 0; i < totalSymbols; i++) { | ||
let percent; | ||
// Calculate each symbol's fullness percentage | ||
if (i - fullSymbols < 0) { | ||
percent = 100; | ||
} else if (i - fullSymbols === 0) { | ||
percent = (renderedValue - i) * 100; | ||
} else { | ||
percent = 0; | ||
} | ||
symbolNodes.push( | ||
<Symbol | ||
key={i} | ||
background={emptySymbols[i % emptySymbols.length]} | ||
icon={icon[i % icon.length]} | ||
index={i} | ||
readonly={readonly} | ||
inactiveIcon={empty[i % empty.length]} | ||
activeIcon={ | ||
shouldDisplayPlaceholder ? placeholder[i % full.length] : full[i % full.length] | ||
} | ||
percent={percent} | ||
{...listeners} | ||
direction={this.state.direction} | ||
onClick={!readonly && this.symbolClick} | ||
onMouseMove={!readonly && this.symbolMouseMove} | ||
onTouchMove={!readonly && this.symbolMouseMove} | ||
onTouchEnd={!readonly && this.symbolClick} | ||
direction={direction} | ||
/> | ||
@@ -198,7 +159,5 @@ ); | ||
<span | ||
ref={container => { | ||
this.ratingContainer = container; | ||
}} | ||
onMouseLeave={!readonly ? this.handleMouseLeave : undefined} | ||
{...other} | ||
style={{ display: 'inline-block', direction }} | ||
onMouseEnter={!readonly ? this.onMouseEnter : undefined} | ||
onMouseLeave={!readonly ? this.onMouseLeave : undefined} | ||
> | ||
@@ -211,65 +170,39 @@ {symbolNodes} | ||
Rating.defaultProps = { | ||
start: 0, | ||
stop: 5, | ||
step: 1, | ||
empty: Style.empty, | ||
placeholder: Style.placeholder, | ||
full: Style.full, | ||
fractions: 1, | ||
scale: 3, | ||
onChange: function (rate) {}, | ||
onClick: function (rate) {}, | ||
onRate: function (rate) {} | ||
} | ||
// Define propTypes only in development. | ||
Rating.propTypes = typeof __DEV__ !== 'undefined' && __DEV__ && { | ||
start: PropTypes.number, | ||
stop: PropTypes.number, | ||
step: PropTypes.number, | ||
initialRate: PropTypes.number, | ||
placeholderRate: PropTypes.number, | ||
empty: PropTypes.oneOfType([ | ||
totalSymbols: PropTypes.number.isRequired, | ||
value: PropTypes.number.isRequired, // Always >= 0 | ||
placeholderValue: PropTypes.number.isRequired, | ||
readonly: PropTypes.bool.isRequired, | ||
quiet: PropTypes.bool.isRequired, | ||
fractions: PropTypes.number.isRequired, | ||
direction: PropTypes.string.isRequired, | ||
emptySymbol: PropTypes.oneOfType([ | ||
// Array of class names and/or style objects. | ||
PropTypes.arrayOf(PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object, | ||
PropTypes.element | ||
])), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.element])), | ||
// Class names. | ||
PropTypes.string, | ||
// Style objects. | ||
PropTypes.object]), | ||
placeholder: PropTypes.oneOfType([ | ||
PropTypes.object | ||
]).isRequired, | ||
fullSymbol: PropTypes.oneOfType([ | ||
// Array of class names and/or style objects. | ||
PropTypes.arrayOf(PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object, | ||
PropTypes.element | ||
])), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.element])), | ||
// Class names. | ||
PropTypes.string, | ||
// Style objects. | ||
PropTypes.object]), | ||
full: PropTypes.oneOfType([ | ||
PropTypes.object | ||
]).isRequired, | ||
placeholderSymbol: PropTypes.oneOfType([ | ||
// Array of class names and/or style objects. | ||
PropTypes.arrayOf(PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object, | ||
PropTypes.element | ||
])), | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.element])), | ||
// Class names. | ||
PropTypes.string, | ||
// Style objects. | ||
PropTypes.object]), | ||
readonly: PropTypes.bool, | ||
quiet: PropTypes.bool, | ||
fractions: PropTypes.number, | ||
scale: PropTypes.number, | ||
onChange: PropTypes.func, | ||
onClick: PropTypes.func, | ||
onRate: PropTypes.func | ||
PropTypes.object | ||
]), | ||
onClick: PropTypes.func.isRequired, | ||
onHover: PropTypes.func.isRequired | ||
}; | ||
module.exports = Rating; | ||
export default Rating; |
@@ -1,1 +0,1 @@ | ||
module.exports = require('./Rating'); | ||
module.exports = require('./RatingAPILayer'); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1949
1
94
1
105286