Comparing version 2.9.2 to 2.9.3
@@ -5,3 +5,3 @@ import React from 'react'; | ||
declare function noop(): void; | ||
export interface RateProps extends Pick<StarProps, "count" | "character" | "characterRender" | "allowHalf" | "disabled"> { | ||
export interface RateProps extends Pick<StarProps, 'count' | 'character' | 'characterRender' | 'allowHalf' | 'disabled'> { | ||
value?: number; | ||
@@ -15,2 +15,3 @@ defaultValue?: number; | ||
className?: string; | ||
id?: string; | ||
tabIndex?: number; | ||
@@ -61,4 +62,4 @@ onFocus?: () => void; | ||
changeValue(value: number): void; | ||
render(): JSX.Element; | ||
render(): React.JSX.Element; | ||
} | ||
export default Rate; |
101
es/Rate.js
@@ -13,26 +13,16 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import Star from './Star'; | ||
function noop() {} | ||
var Rate = /*#__PURE__*/function (_React$Component) { | ||
_inherits(Rate, _React$Component); | ||
var _super = _createSuper(Rate); | ||
function Rate(props) { | ||
var _this; | ||
_classCallCheck(this, Rate); | ||
_this = _super.call(this, props); | ||
_this.stars = void 0; | ||
_this.rate = void 0; | ||
_this.onHover = function (event, index) { | ||
var onHoverChange = _this.props.onHoverChange; | ||
var hoverValue = _this.getStarValue(index, event.pageX); | ||
var cleanedValue = _this.state.cleanedValue; | ||
if (hoverValue !== cleanedValue) { | ||
@@ -44,9 +34,6 @@ _this.setState({ | ||
} | ||
onHoverChange(hoverValue); | ||
}; | ||
_this.onMouseLeave = function () { | ||
var onHoverChange = _this.props.onHoverChange; | ||
_this.setState({ | ||
@@ -56,22 +43,14 @@ hoverValue: undefined, | ||
}); | ||
onHoverChange(undefined); | ||
}; | ||
_this.onClick = function (event, index) { | ||
var allowClear = _this.props.allowClear; | ||
var value = _this.state.value; | ||
var newValue = _this.getStarValue(index, event.pageX); | ||
var isReset = false; | ||
if (allowClear) { | ||
isReset = newValue === value; | ||
} | ||
_this.onMouseLeave(); | ||
_this.changeValue(isReset ? 0 : newValue); | ||
_this.setState({ | ||
@@ -81,10 +60,7 @@ cleanedValue: isReset ? newValue : null | ||
}; | ||
_this.onFocus = function () { | ||
var onFocus = _this.props.onFocus; | ||
_this.setState({ | ||
focused: true | ||
}); | ||
if (onFocus) { | ||
@@ -94,10 +70,7 @@ onFocus(); | ||
}; | ||
_this.onBlur = function () { | ||
var onBlur = _this.props.onBlur; | ||
_this.setState({ | ||
focused: false | ||
}); | ||
if (onBlur) { | ||
@@ -107,13 +80,11 @@ onBlur(); | ||
}; | ||
_this.onKeyDown = function (event) { | ||
var keyCode = event.keyCode; | ||
var _this$props = _this.props, | ||
count = _this$props.count, | ||
allowHalf = _this$props.allowHalf, | ||
onKeyDown = _this$props.onKeyDown, | ||
direction = _this$props.direction; | ||
count = _this$props.count, | ||
allowHalf = _this$props.allowHalf, | ||
onKeyDown = _this$props.onKeyDown, | ||
direction = _this$props.direction; | ||
var reverse = direction === 'rtl'; | ||
var value = _this.state.value; | ||
if (keyCode === KeyCode.RIGHT && value < count && !reverse) { | ||
@@ -125,5 +96,3 @@ if (allowHalf) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
@@ -136,5 +105,3 @@ } else if (keyCode === KeyCode.LEFT && value > 0 && !reverse) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
@@ -147,5 +114,3 @@ } else if (keyCode === KeyCode.RIGHT && value > 0 && reverse) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
@@ -158,8 +123,5 @@ } else if (keyCode === KeyCode.LEFT && value < count && reverse) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
} | ||
if (onKeyDown) { | ||
@@ -169,3 +131,2 @@ onKeyDown(event); | ||
}; | ||
_this.saveRef = function (index) { | ||
@@ -176,13 +137,9 @@ return function (node) { | ||
}; | ||
_this.saveRate = function (node) { | ||
_this.rate = node; | ||
}; | ||
var _value = props.value; | ||
if (_value === undefined) { | ||
_value = props.defaultValue; | ||
} | ||
_this.stars = {}; | ||
@@ -196,3 +153,2 @@ _this.state = { | ||
} | ||
_createClass(Rate, [{ | ||
@@ -202,5 +158,4 @@ key: "componentDidMount", | ||
var _this$props2 = this.props, | ||
autoFocus = _this$props2.autoFocus, | ||
disabled = _this$props2.disabled; | ||
autoFocus = _this$props2.autoFocus, | ||
disabled = _this$props2.disabled; | ||
if (autoFocus && !disabled) { | ||
@@ -219,7 +174,6 @@ this.focus(); | ||
var _this$props3 = this.props, | ||
allowHalf = _this$props3.allowHalf, | ||
direction = _this$props3.direction; | ||
allowHalf = _this$props3.allowHalf, | ||
direction = _this$props3.direction; | ||
var reverse = direction === 'rtl'; | ||
var value = index + 1; | ||
if (allowHalf) { | ||
@@ -229,3 +183,2 @@ var starEle = this.getStarDOM(index); | ||
var width = starEle.clientWidth; | ||
if (reverse && x - leftDis > width / 2) { | ||
@@ -237,3 +190,2 @@ value -= 0.5; | ||
} | ||
return value; | ||
@@ -245,3 +197,2 @@ } | ||
var disabled = this.props.disabled; | ||
if (!disabled) { | ||
@@ -255,3 +206,2 @@ this.rate.focus(); | ||
var disabled = this.props.disabled; | ||
if (!disabled) { | ||
@@ -265,3 +215,2 @@ this.rate.blur(); | ||
var onChange = this.props.onChange; | ||
if (!('value' in this.props)) { | ||
@@ -272,3 +221,2 @@ this.setState({ | ||
} | ||
onChange(value); | ||
@@ -280,19 +228,19 @@ } | ||
var _this$props4 = this.props, | ||
count = _this$props4.count, | ||
allowHalf = _this$props4.allowHalf, | ||
style = _this$props4.style, | ||
prefixCls = _this$props4.prefixCls, | ||
disabled = _this$props4.disabled, | ||
className = _this$props4.className, | ||
character = _this$props4.character, | ||
characterRender = _this$props4.characterRender, | ||
tabIndex = _this$props4.tabIndex, | ||
direction = _this$props4.direction; | ||
count = _this$props4.count, | ||
allowHalf = _this$props4.allowHalf, | ||
style = _this$props4.style, | ||
id = _this$props4.id, | ||
prefixCls = _this$props4.prefixCls, | ||
disabled = _this$props4.disabled, | ||
className = _this$props4.className, | ||
character = _this$props4.character, | ||
characterRender = _this$props4.characterRender, | ||
tabIndex = _this$props4.tabIndex, | ||
direction = _this$props4.direction; | ||
var _this$state = this.state, | ||
value = _this$state.value, | ||
hoverValue = _this$state.hoverValue, | ||
focused = _this$state.focused; | ||
value = _this$state.value, | ||
hoverValue = _this$state.hoverValue, | ||
focused = _this$state.focused; | ||
var stars = []; | ||
var disabledClass = disabled ? "".concat(prefixCls, "-disabled") : ''; | ||
for (var index = 0; index < count; index += 1) { | ||
@@ -315,3 +263,2 @@ stars.push( /*#__PURE__*/React.createElement(Star, { | ||
} | ||
var rateClassName = classNames(prefixCls, disabledClass, className, _defineProperty({}, "".concat(prefixCls, "-rtl"), direction === 'rtl')); | ||
@@ -321,2 +268,3 @@ return /*#__PURE__*/React.createElement("ul", { | ||
style: style, | ||
id: id, | ||
onMouseLeave: disabled ? null : this.onMouseLeave, | ||
@@ -339,10 +287,7 @@ tabIndex: disabled ? -1 : tabIndex, | ||
} | ||
return state; | ||
} | ||
}]); | ||
return Rate; | ||
}(React.Component); | ||
Rate.defaultProps = { | ||
@@ -349,0 +294,0 @@ defaultValue: 0, |
@@ -6,38 +6,28 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import React from 'react'; | ||
var Star = /*#__PURE__*/function (_React$Component) { | ||
_inherits(Star, _React$Component); | ||
var _super = _createSuper(Star); | ||
function Star() { | ||
var _this; | ||
_classCallCheck(this, Star); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.onHover = function (e) { | ||
var _this$props = _this.props, | ||
onHover = _this$props.onHover, | ||
index = _this$props.index; | ||
onHover = _this$props.onHover, | ||
index = _this$props.index; | ||
onHover(e, index); | ||
}; | ||
_this.onClick = function (e) { | ||
var _this$props2 = _this.props, | ||
onClick = _this$props2.onClick, | ||
index = _this$props2.index; | ||
onClick = _this$props2.onClick, | ||
index = _this$props2.index; | ||
onClick(e, index); | ||
}; | ||
_this.onKeyDown = function (e) { | ||
var _this$props3 = _this.props, | ||
onClick = _this$props3.onClick, | ||
index = _this$props3.index; | ||
onClick = _this$props3.onClick, | ||
index = _this$props3.index; | ||
if (e.keyCode === 13) { | ||
@@ -47,6 +37,4 @@ onClick(e, index); | ||
}; | ||
return _this; | ||
} | ||
_createClass(Star, [{ | ||
@@ -56,10 +44,9 @@ key: "getClassName", | ||
var _this$props4 = this.props, | ||
prefixCls = _this$props4.prefixCls, | ||
index = _this$props4.index, | ||
value = _this$props4.value, | ||
allowHalf = _this$props4.allowHalf, | ||
focused = _this$props4.focused; | ||
prefixCls = _this$props4.prefixCls, | ||
index = _this$props4.index, | ||
value = _this$props4.value, | ||
allowHalf = _this$props4.allowHalf, | ||
focused = _this$props4.focused; | ||
var starValue = index + 1; | ||
var className = prefixCls; | ||
if (value === 0 && index === 0 && focused) { | ||
@@ -69,3 +56,2 @@ className += " ".concat(prefixCls, "-focused"); | ||
className += " ".concat(prefixCls, "-half ").concat(prefixCls, "-active"); | ||
if (focused) { | ||
@@ -76,3 +62,2 @@ className += " ".concat(prefixCls, "-focused"); | ||
className += starValue <= value ? " ".concat(prefixCls, "-full") : " ".concat(prefixCls, "-zero"); | ||
if (starValue === value && focused) { | ||
@@ -82,3 +67,2 @@ className += " ".concat(prefixCls, "-focused"); | ||
} | ||
return className; | ||
@@ -90,12 +74,12 @@ } | ||
var onHover = this.onHover, | ||
onClick = this.onClick, | ||
onKeyDown = this.onKeyDown; | ||
onClick = this.onClick, | ||
onKeyDown = this.onKeyDown; | ||
var _this$props5 = this.props, | ||
disabled = _this$props5.disabled, | ||
prefixCls = _this$props5.prefixCls, | ||
character = _this$props5.character, | ||
characterRender = _this$props5.characterRender, | ||
index = _this$props5.index, | ||
count = _this$props5.count, | ||
value = _this$props5.value; | ||
disabled = _this$props5.disabled, | ||
prefixCls = _this$props5.prefixCls, | ||
character = _this$props5.character, | ||
characterRender = _this$props5.characterRender, | ||
index = _this$props5.index, | ||
count = _this$props5.count, | ||
value = _this$props5.value; | ||
var characterNode = typeof character === 'function' ? character(this.props) : character; | ||
@@ -118,14 +102,10 @@ var start = /*#__PURE__*/React.createElement("li", { | ||
}, characterNode))); | ||
if (characterRender) { | ||
start = characterRender(start, this.props); | ||
} | ||
return start; | ||
} | ||
}]); | ||
return Star; | ||
}(React.Component); | ||
export { Star as default }; |
function getScroll(w) { | ||
var ret = w.pageXOffset; | ||
var method = 'scrollLeft'; | ||
if (typeof ret !== 'number') { | ||
var d = w.document; // ie6,7,8 standard mode | ||
var d = w.document; | ||
// ie6,7,8 standard mode | ||
ret = d.documentElement[method]; | ||
if (typeof ret !== 'number') { | ||
@@ -15,6 +13,4 @@ // quirks mode | ||
} | ||
return ret; | ||
} | ||
function getClientPosition(elem) { | ||
@@ -36,7 +32,6 @@ var x; | ||
} | ||
export function getOffsetLeft(el) { | ||
var pos = getClientPosition(el); | ||
var doc = el.ownerDocument; // Only IE use `parentWindow` | ||
var doc = el.ownerDocument; | ||
// Only IE use `parentWindow` | ||
var w = doc.defaultView || doc.parentWindow; | ||
@@ -43,0 +38,0 @@ pos.left += getScroll(w); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,6 +8,4 @@ value: true | ||
exports.default = void 0; | ||
var _Rate = _interopRequireDefault(require("./Rate")); | ||
var _default = _Rate.default; | ||
exports.default = _default; |
@@ -5,3 +5,3 @@ import React from 'react'; | ||
declare function noop(): void; | ||
export interface RateProps extends Pick<StarProps, "count" | "character" | "characterRender" | "allowHalf" | "disabled"> { | ||
export interface RateProps extends Pick<StarProps, 'count' | 'character' | 'characterRender' | 'allowHalf' | 'disabled'> { | ||
value?: number; | ||
@@ -15,2 +15,3 @@ defaultValue?: number; | ||
className?: string; | ||
id?: string; | ||
tabIndex?: number; | ||
@@ -61,4 +62,4 @@ onFocus?: () => void; | ||
changeValue(value: number): void; | ||
render(): JSX.Element; | ||
render(): React.JSX.Element; | ||
} | ||
export default Rate; |
112
lib/Rate.js
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,37 +8,20 @@ value: true | ||
exports.default = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _findDOMNode = _interopRequireDefault(require("rc-util/lib/Dom/findDOMNode")); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode")); | ||
var _util = require("./util"); | ||
var _Star = _interopRequireDefault(require("./Star")); | ||
function noop() {} | ||
var Rate = /*#__PURE__*/function (_React$Component) { | ||
(0, _inherits2.default)(Rate, _React$Component); | ||
var _super = (0, _createSuper2.default)(Rate); | ||
function Rate(props) { | ||
var _this; | ||
(0, _classCallCheck2.default)(this, Rate); | ||
@@ -49,10 +31,6 @@ _this = _super.call(this, props); | ||
_this.rate = void 0; | ||
_this.onHover = function (event, index) { | ||
var onHoverChange = _this.props.onHoverChange; | ||
var hoverValue = _this.getStarValue(index, event.pageX); | ||
var cleanedValue = _this.state.cleanedValue; | ||
if (hoverValue !== cleanedValue) { | ||
@@ -64,9 +42,6 @@ _this.setState({ | ||
} | ||
onHoverChange(hoverValue); | ||
}; | ||
_this.onMouseLeave = function () { | ||
var onHoverChange = _this.props.onHoverChange; | ||
_this.setState({ | ||
@@ -76,22 +51,14 @@ hoverValue: undefined, | ||
}); | ||
onHoverChange(undefined); | ||
}; | ||
_this.onClick = function (event, index) { | ||
var allowClear = _this.props.allowClear; | ||
var value = _this.state.value; | ||
var newValue = _this.getStarValue(index, event.pageX); | ||
var isReset = false; | ||
if (allowClear) { | ||
isReset = newValue === value; | ||
} | ||
_this.onMouseLeave(); | ||
_this.changeValue(isReset ? 0 : newValue); | ||
_this.setState({ | ||
@@ -101,10 +68,7 @@ cleanedValue: isReset ? newValue : null | ||
}; | ||
_this.onFocus = function () { | ||
var onFocus = _this.props.onFocus; | ||
_this.setState({ | ||
focused: true | ||
}); | ||
if (onFocus) { | ||
@@ -114,10 +78,7 @@ onFocus(); | ||
}; | ||
_this.onBlur = function () { | ||
var onBlur = _this.props.onBlur; | ||
_this.setState({ | ||
focused: false | ||
}); | ||
if (onBlur) { | ||
@@ -127,13 +88,11 @@ onBlur(); | ||
}; | ||
_this.onKeyDown = function (event) { | ||
var keyCode = event.keyCode; | ||
var _this$props = _this.props, | ||
count = _this$props.count, | ||
allowHalf = _this$props.allowHalf, | ||
onKeyDown = _this$props.onKeyDown, | ||
direction = _this$props.direction; | ||
count = _this$props.count, | ||
allowHalf = _this$props.allowHalf, | ||
onKeyDown = _this$props.onKeyDown, | ||
direction = _this$props.direction; | ||
var reverse = direction === 'rtl'; | ||
var value = _this.state.value; | ||
if (keyCode === _KeyCode.default.RIGHT && value < count && !reverse) { | ||
@@ -145,5 +104,3 @@ if (allowHalf) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
@@ -156,5 +113,3 @@ } else if (keyCode === _KeyCode.default.LEFT && value > 0 && !reverse) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
@@ -167,5 +122,3 @@ } else if (keyCode === _KeyCode.default.RIGHT && value > 0 && reverse) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
@@ -178,8 +131,5 @@ } else if (keyCode === _KeyCode.default.LEFT && value < count && reverse) { | ||
} | ||
_this.changeValue(value); | ||
event.preventDefault(); | ||
} | ||
if (onKeyDown) { | ||
@@ -189,3 +139,2 @@ onKeyDown(event); | ||
}; | ||
_this.saveRef = function (index) { | ||
@@ -196,13 +145,9 @@ return function (node) { | ||
}; | ||
_this.saveRate = function (node) { | ||
_this.rate = node; | ||
}; | ||
var _value = props.value; | ||
if (_value === undefined) { | ||
_value = props.defaultValue; | ||
} | ||
_this.stars = {}; | ||
@@ -216,3 +161,2 @@ _this.state = { | ||
} | ||
(0, _createClass2.default)(Rate, [{ | ||
@@ -222,5 +166,4 @@ key: "componentDidMount", | ||
var _this$props2 = this.props, | ||
autoFocus = _this$props2.autoFocus, | ||
disabled = _this$props2.disabled; | ||
autoFocus = _this$props2.autoFocus, | ||
disabled = _this$props2.disabled; | ||
if (autoFocus && !disabled) { | ||
@@ -239,7 +182,6 @@ this.focus(); | ||
var _this$props3 = this.props, | ||
allowHalf = _this$props3.allowHalf, | ||
direction = _this$props3.direction; | ||
allowHalf = _this$props3.allowHalf, | ||
direction = _this$props3.direction; | ||
var reverse = direction === 'rtl'; | ||
var value = index + 1; | ||
if (allowHalf) { | ||
@@ -249,3 +191,2 @@ var starEle = this.getStarDOM(index); | ||
var width = starEle.clientWidth; | ||
if (reverse && x - leftDis > width / 2) { | ||
@@ -257,3 +198,2 @@ value -= 0.5; | ||
} | ||
return value; | ||
@@ -265,3 +205,2 @@ } | ||
var disabled = this.props.disabled; | ||
if (!disabled) { | ||
@@ -275,3 +214,2 @@ this.rate.focus(); | ||
var disabled = this.props.disabled; | ||
if (!disabled) { | ||
@@ -285,3 +223,2 @@ this.rate.blur(); | ||
var onChange = this.props.onChange; | ||
if (!('value' in this.props)) { | ||
@@ -292,3 +229,2 @@ this.setState({ | ||
} | ||
onChange(value); | ||
@@ -300,19 +236,19 @@ } | ||
var _this$props4 = this.props, | ||
count = _this$props4.count, | ||
allowHalf = _this$props4.allowHalf, | ||
style = _this$props4.style, | ||
prefixCls = _this$props4.prefixCls, | ||
disabled = _this$props4.disabled, | ||
className = _this$props4.className, | ||
character = _this$props4.character, | ||
characterRender = _this$props4.characterRender, | ||
tabIndex = _this$props4.tabIndex, | ||
direction = _this$props4.direction; | ||
count = _this$props4.count, | ||
allowHalf = _this$props4.allowHalf, | ||
style = _this$props4.style, | ||
id = _this$props4.id, | ||
prefixCls = _this$props4.prefixCls, | ||
disabled = _this$props4.disabled, | ||
className = _this$props4.className, | ||
character = _this$props4.character, | ||
characterRender = _this$props4.characterRender, | ||
tabIndex = _this$props4.tabIndex, | ||
direction = _this$props4.direction; | ||
var _this$state = this.state, | ||
value = _this$state.value, | ||
hoverValue = _this$state.hoverValue, | ||
focused = _this$state.focused; | ||
value = _this$state.value, | ||
hoverValue = _this$state.hoverValue, | ||
focused = _this$state.focused; | ||
var stars = []; | ||
var disabledClass = disabled ? "".concat(prefixCls, "-disabled") : ''; | ||
for (var index = 0; index < count; index += 1) { | ||
@@ -335,3 +271,2 @@ stars.push( /*#__PURE__*/_react.default.createElement(_Star.default, { | ||
} | ||
var rateClassName = (0, _classnames.default)(prefixCls, disabledClass, className, (0, _defineProperty2.default)({}, "".concat(prefixCls, "-rtl"), direction === 'rtl')); | ||
@@ -341,2 +276,3 @@ return /*#__PURE__*/_react.default.createElement("ul", { | ||
style: style, | ||
id: id, | ||
onMouseLeave: disabled ? null : this.onMouseLeave, | ||
@@ -359,3 +295,2 @@ tabIndex: disabled ? -1 : tabIndex, | ||
} | ||
return state; | ||
@@ -366,3 +301,2 @@ } | ||
}(_react.default.Component); | ||
Rate.defaultProps = { | ||
@@ -369,0 +303,0 @@ defaultValue: 0, |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,48 +8,33 @@ value: true | ||
exports.default = void 0; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var Star = /*#__PURE__*/function (_React$Component) { | ||
(0, _inherits2.default)(Star, _React$Component); | ||
var _super = (0, _createSuper2.default)(Star); | ||
function Star() { | ||
var _this; | ||
(0, _classCallCheck2.default)(this, Star); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.onHover = function (e) { | ||
var _this$props = _this.props, | ||
onHover = _this$props.onHover, | ||
index = _this$props.index; | ||
onHover = _this$props.onHover, | ||
index = _this$props.index; | ||
onHover(e, index); | ||
}; | ||
_this.onClick = function (e) { | ||
var _this$props2 = _this.props, | ||
onClick = _this$props2.onClick, | ||
index = _this$props2.index; | ||
onClick = _this$props2.onClick, | ||
index = _this$props2.index; | ||
onClick(e, index); | ||
}; | ||
_this.onKeyDown = function (e) { | ||
var _this$props3 = _this.props, | ||
onClick = _this$props3.onClick, | ||
index = _this$props3.index; | ||
onClick = _this$props3.onClick, | ||
index = _this$props3.index; | ||
if (e.keyCode === 13) { | ||
@@ -60,6 +44,4 @@ onClick(e, index); | ||
}; | ||
return _this; | ||
} | ||
(0, _createClass2.default)(Star, [{ | ||
@@ -69,10 +51,9 @@ key: "getClassName", | ||
var _this$props4 = this.props, | ||
prefixCls = _this$props4.prefixCls, | ||
index = _this$props4.index, | ||
value = _this$props4.value, | ||
allowHalf = _this$props4.allowHalf, | ||
focused = _this$props4.focused; | ||
prefixCls = _this$props4.prefixCls, | ||
index = _this$props4.index, | ||
value = _this$props4.value, | ||
allowHalf = _this$props4.allowHalf, | ||
focused = _this$props4.focused; | ||
var starValue = index + 1; | ||
var className = prefixCls; | ||
if (value === 0 && index === 0 && focused) { | ||
@@ -82,3 +63,2 @@ className += " ".concat(prefixCls, "-focused"); | ||
className += " ".concat(prefixCls, "-half ").concat(prefixCls, "-active"); | ||
if (focused) { | ||
@@ -89,3 +69,2 @@ className += " ".concat(prefixCls, "-focused"); | ||
className += starValue <= value ? " ".concat(prefixCls, "-full") : " ".concat(prefixCls, "-zero"); | ||
if (starValue === value && focused) { | ||
@@ -95,3 +74,2 @@ className += " ".concat(prefixCls, "-focused"); | ||
} | ||
return className; | ||
@@ -103,14 +81,13 @@ } | ||
var onHover = this.onHover, | ||
onClick = this.onClick, | ||
onKeyDown = this.onKeyDown; | ||
onClick = this.onClick, | ||
onKeyDown = this.onKeyDown; | ||
var _this$props5 = this.props, | ||
disabled = _this$props5.disabled, | ||
prefixCls = _this$props5.prefixCls, | ||
character = _this$props5.character, | ||
characterRender = _this$props5.characterRender, | ||
index = _this$props5.index, | ||
count = _this$props5.count, | ||
value = _this$props5.value; | ||
disabled = _this$props5.disabled, | ||
prefixCls = _this$props5.prefixCls, | ||
character = _this$props5.character, | ||
characterRender = _this$props5.characterRender, | ||
index = _this$props5.index, | ||
count = _this$props5.count, | ||
value = _this$props5.value; | ||
var characterNode = typeof character === 'function' ? character(this.props) : character; | ||
var start = /*#__PURE__*/_react.default.createElement("li", { | ||
@@ -132,7 +109,5 @@ className: this.getClassName() | ||
}, characterNode))); | ||
if (characterRender) { | ||
start = characterRender(start, this.props); | ||
} | ||
return start; | ||
@@ -143,3 +118,2 @@ } | ||
}(_react.default.Component); | ||
exports.default = Star; |
@@ -7,12 +7,9 @@ "use strict"; | ||
exports.getOffsetLeft = getOffsetLeft; | ||
function getScroll(w) { | ||
var ret = w.pageXOffset; | ||
var method = 'scrollLeft'; | ||
if (typeof ret !== 'number') { | ||
var d = w.document; // ie6,7,8 standard mode | ||
var d = w.document; | ||
// ie6,7,8 standard mode | ||
ret = d.documentElement[method]; | ||
if (typeof ret !== 'number') { | ||
@@ -23,6 +20,4 @@ // quirks mode | ||
} | ||
return ret; | ||
} | ||
function getClientPosition(elem) { | ||
@@ -44,7 +39,6 @@ var x; | ||
} | ||
function getOffsetLeft(el) { | ||
var pos = getClientPosition(el); | ||
var doc = el.ownerDocument; // Only IE use `parentWindow` | ||
var doc = el.ownerDocument; | ||
// Only IE use `parentWindow` | ||
var w = doc.defaultView || doc.parentWindow; | ||
@@ -51,0 +45,0 @@ pos.left += getScroll(w); |
{ | ||
"name": "rc-rate", | ||
"version": "2.9.2", | ||
"version": "2.9.3", | ||
"description": "React Star Rate Component", | ||
@@ -35,3 +35,3 @@ "engines": { | ||
"compile": "father build && lessc assets/index.less assets/index.css", | ||
"prepublishOnly": "npm run compile && np --yolo --no-publish", | ||
"prepublishOnly": "npm run compile && np --yolo --no-publish --branch 2.9.x", | ||
"postpublish": "npm run gh-pages", | ||
@@ -38,0 +38,0 @@ "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1135
43038