Socket
Socket
Sign inDemoInstall

rc-rate

Package Overview
Dependencies
2
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.5.1 to 2.6.0

es/index.d.ts

167

es/Rate.js

@@ -0,1 +1,3 @@

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -5,2 +7,4 @@

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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -12,19 +16,19 @@

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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; }
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import findDOMNode from "rc-util/es/Dom/findDOMNode";
import classNames from 'classnames';
import { polyfill } from 'react-lifecycles-compat';
import KeyCode from "rc-util/es/KeyCode";

@@ -36,7 +40,7 @@ import { getOffsetLeft } from './util';

var Rate =
/*#__PURE__*/
function (_React$Component) {
var Rate = /*#__PURE__*/function (_React$Component) {
_inherits(Rate, _React$Component);
var _super = _createSuper(Rate);
function Rate(props) {

@@ -47,5 +51,5 @@ var _this;

_this = _possibleConstructorReturn(this, _getPrototypeOf(Rate).call(this, props));
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "onHover", function (event, index) {
_this.onHover = function (event, index) {
var onHoverChange = _this.props.onHoverChange;

@@ -65,5 +69,5 @@

onHoverChange(hoverValue);
});
};
_defineProperty(_assertThisInitialized(_this), "onMouseLeave", function () {
_this.onMouseLeave = function () {
var onHoverChange = _this.props.onHoverChange;

@@ -77,5 +81,5 @@

onHoverChange(undefined);
});
};
_defineProperty(_assertThisInitialized(_this), "onClick", function (event, index) {
_this.onClick = function (event, index) {
var allowClear = _this.props.allowClear;

@@ -92,3 +96,3 @@ var value = _this.state.value;

_this.onMouseLeave(true);
_this.onMouseLeave();

@@ -100,5 +104,5 @@ _this.changeValue(isReset ? 0 : newValue);

});
});
};
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
_this.onFocus = function () {
var onFocus = _this.props.onFocus;

@@ -113,5 +117,5 @@

}
});
};
_defineProperty(_assertThisInitialized(_this), "onBlur", function () {
_this.onBlur = function () {
var onBlur = _this.props.onBlur;

@@ -126,5 +130,5 @@

}
});
};
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
_this.onKeyDown = function (event) {
var keyCode = event.keyCode;

@@ -134,6 +138,8 @@ var _this$props = _this.props,

allowHalf = _this$props.allowHalf,
onKeyDown = _this$props.onKeyDown;
onKeyDown = _this$props.onKeyDown,
direction = _this$props.direction;
var reverse = direction === 'rtl';
var value = _this.state.value;
if (keyCode === KeyCode.RIGHT && value < count) {
if (keyCode === KeyCode.RIGHT && value < count && !reverse) {
if (allowHalf) {

@@ -148,3 +154,3 @@ value += 0.5;

event.preventDefault();
} else if (keyCode === KeyCode.LEFT && value > 0) {
} else if (keyCode === KeyCode.LEFT && value > 0 && !reverse) {
if (allowHalf) {

@@ -159,2 +165,22 @@ value -= 0.5;

event.preventDefault();
} else if (keyCode === KeyCode.RIGHT && value > 0 && reverse) {
if (allowHalf) {
value -= 0.5;
} else {
value -= 1;
}
_this.changeValue(value);
event.preventDefault();
} else if (keyCode === KeyCode.LEFT && value < count && reverse) {
if (allowHalf) {
value += 0.5;
} else {
value += 1;
}
_this.changeValue(value);
event.preventDefault();
}

@@ -165,18 +191,18 @@

}
});
};
_defineProperty(_assertThisInitialized(_this), "saveRef", function (index) {
_this.saveRef = function (index) {
return function (node) {
_this.stars[index] = node;
};
});
};
_defineProperty(_assertThisInitialized(_this), "saveRate", function (node) {
_this.saveRate = function (node) {
_this.rate = node;
});
};
var _value = props.value;
var value = props.value;
if (_value === undefined) {
_value = props.defaultValue;
if (value === undefined) {
value = props.defaultValue;
}

@@ -186,3 +212,3 @@

_this.state = {
value: _value,
value: value,
focused: false,

@@ -208,3 +234,3 @@ cleanedValue: null

value: function getStarDOM(index) {
return ReactDOM.findDOMNode(this.stars[index]);
return findDOMNode(this.stars[index]);
}

@@ -214,3 +240,6 @@ }, {

value: function getStarValue(index, x) {
var allowHalf = this.props.allowHalf;
var _this$props3 = this.props,
allowHalf = _this$props3.allowHalf,
direction = _this$props3.direction;
var reverse = direction === 'rtl';
var value = index + 1;

@@ -223,4 +252,6 @@

if (x - leftDis < width / 2) {
if (reverse && x - leftDis > width / 2) {
value -= 0.5;
} else if (!reverse && x - leftDis < width / 2) {
value -= 0.5;
}

@@ -265,12 +296,13 @@ }

value: function render() {
var _this$props3 = this.props,
count = _this$props3.count,
allowHalf = _this$props3.allowHalf,
style = _this$props3.style,
prefixCls = _this$props3.prefixCls,
disabled = _this$props3.disabled,
className = _this$props3.className,
character = _this$props3.character,
characterRender = _this$props3.characterRender,
tabIndex = _this$props3.tabIndex;
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;
var _this$state = this.state,

@@ -283,3 +315,3 @@ value = _this$state.value,

for (var index = 0; index < count; index++) {
for (var index = 0; index < count; index += 1) {
stars.push(React.createElement(Star, {

@@ -302,4 +334,5 @@ ref: this.saveRef(index),

var rateClassName = classNames(prefixCls, disabledClass, className, _defineProperty({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'));
return React.createElement("ul", {
className: classNames(prefixCls, disabledClass, className),
className: rateClassName,
style: style,

@@ -331,24 +364,3 @@ onMouseLeave: disabled ? null : this.onMouseLeave,

_defineProperty(Rate, "propTypes", {
disabled: PropTypes.bool,
value: PropTypes.number,
defaultValue: PropTypes.number,
count: PropTypes.number,
allowHalf: PropTypes.bool,
allowClear: PropTypes.bool,
style: PropTypes.object,
prefixCls: PropTypes.string,
onChange: PropTypes.func,
onHoverChange: PropTypes.func,
className: PropTypes.string,
character: PropTypes.node,
characterRender: PropTypes.func,
tabIndex: PropTypes.number,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onKeyDown: PropTypes.func,
autoFocus: PropTypes.bool
});
_defineProperty(Rate, "defaultProps", {
Rate.defaultProps = {
defaultValue: 0,

@@ -363,6 +375,5 @@ count: 5,

onHoverChange: noop,
tabIndex: 0
});
polyfill(Rate);
tabIndex: 0,
direction: 'ltr'
};
export default Rate;

@@ -0,1 +1,3 @@

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -7,25 +9,24 @@

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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; }
import React from 'react';
import PropTypes from 'prop-types';
var Star =
/*#__PURE__*/
function (_React$Component) {
var Star = /*#__PURE__*/function (_React$Component) {
_inherits(Star, _React$Component);
var _super = _createSuper(Star);
function Star() {
var _getPrototypeOf2;
var _this;

@@ -35,9 +36,5 @@

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.apply(this, arguments);
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Star)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "onHover", function (e) {
_this.onHover = function (e) {
var _this$props = _this.props,

@@ -47,5 +44,5 @@ onHover = _this$props.onHover,

onHover(e, index);
});
};
_defineProperty(_assertThisInitialized(_this), "onClick", function (e) {
_this.onClick = function (e) {
var _this$props2 = _this.props,

@@ -55,5 +52,5 @@ onClick = _this$props2.onClick,

onClick(e, index);
});
};
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (e) {
_this.onKeyDown = function (e) {
var _this$props3 = _this.props,

@@ -66,3 +63,3 @@ onClick = _this$props3.onClick,

}
});
};

@@ -144,16 +141,2 @@ return _this;

_defineProperty(Star, "propTypes", {
value: PropTypes.number,
index: PropTypes.number,
prefixCls: PropTypes.string,
allowHalf: PropTypes.bool,
disabled: PropTypes.bool,
onHover: PropTypes.func,
onClick: PropTypes.func,
character: PropTypes.node,
characterRender: PropTypes.func,
focused: PropTypes.bool,
count: PropTypes.number
});
export { Star as default };
/* eslint-disable import/prefer-default-export */
function getScroll(w, top) {
var ret = top ? w.pageYOffset : w.pageXOffset;
var method = top ? 'scrollTop' : 'scrollLeft';
function getScroll(w) {
var ret = w.pageXOffset;
var method = 'scrollLeft';

@@ -39,3 +39,4 @@ if (typeof ret !== 'number') {

var pos = getClientPosition(el);
var doc = el.ownerDocument;
var doc = el.ownerDocument; // Only IE use `parentWindow`
var w = doc.defaultView || doc.parentWindow;

@@ -42,0 +43,0 @@ pos.left += getScroll(w);

@@ -6,9 +6,9 @@ "use strict";

});
exports["default"] = void 0;
exports.default = void 0;
var _Rate = _interopRequireDefault(require("./Rate"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = _Rate["default"];
exports["default"] = _default;
var _default = _Rate.default;
exports.default = _default;

@@ -6,14 +6,10 @@ "use strict";

});
exports["default"] = void 0;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactDom = _interopRequireDefault(require("react-dom"));
var _findDOMNode = _interopRequireDefault(require("rc-util/lib/Dom/findDOMNode"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _reactLifecyclesCompat = require("react-lifecycles-compat");
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));

@@ -25,4 +21,6 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -32,2 +30,4 @@

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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -39,21 +39,23 @@

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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; }
function noop() {}
var Rate =
/*#__PURE__*/
function (_React$Component) {
var Rate = /*#__PURE__*/function (_React$Component) {
_inherits(Rate, _React$Component);
var _super = _createSuper(Rate);
function Rate(props) {

@@ -64,5 +66,5 @@ var _this;

_this = _possibleConstructorReturn(this, _getPrototypeOf(Rate).call(this, props));
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "onHover", function (event, index) {
_this.onHover = function (event, index) {
var onHoverChange = _this.props.onHoverChange;

@@ -82,5 +84,5 @@

onHoverChange(hoverValue);
});
};
_defineProperty(_assertThisInitialized(_this), "onMouseLeave", function () {
_this.onMouseLeave = function () {
var onHoverChange = _this.props.onHoverChange;

@@ -94,5 +96,5 @@

onHoverChange(undefined);
});
};
_defineProperty(_assertThisInitialized(_this), "onClick", function (event, index) {
_this.onClick = function (event, index) {
var allowClear = _this.props.allowClear;

@@ -109,3 +111,3 @@ var value = _this.state.value;

_this.onMouseLeave(true);
_this.onMouseLeave();

@@ -117,5 +119,5 @@ _this.changeValue(isReset ? 0 : newValue);

});
});
};
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
_this.onFocus = function () {
var onFocus = _this.props.onFocus;

@@ -130,5 +132,5 @@

}
});
};
_defineProperty(_assertThisInitialized(_this), "onBlur", function () {
_this.onBlur = function () {
var onBlur = _this.props.onBlur;

@@ -143,5 +145,5 @@

}
});
};
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
_this.onKeyDown = function (event) {
var keyCode = event.keyCode;

@@ -151,6 +153,8 @@ var _this$props = _this.props,

allowHalf = _this$props.allowHalf,
onKeyDown = _this$props.onKeyDown;
onKeyDown = _this$props.onKeyDown,
direction = _this$props.direction;
var reverse = direction === 'rtl';
var value = _this.state.value;
if (keyCode === _KeyCode["default"].RIGHT && value < count) {
if (keyCode === _KeyCode.default.RIGHT && value < count && !reverse) {
if (allowHalf) {

@@ -165,3 +169,3 @@ value += 0.5;

event.preventDefault();
} else if (keyCode === _KeyCode["default"].LEFT && value > 0) {
} else if (keyCode === _KeyCode.default.LEFT && value > 0 && !reverse) {
if (allowHalf) {

@@ -176,2 +180,22 @@ value -= 0.5;

event.preventDefault();
} else if (keyCode === _KeyCode.default.RIGHT && value > 0 && reverse) {
if (allowHalf) {
value -= 0.5;
} else {
value -= 1;
}
_this.changeValue(value);
event.preventDefault();
} else if (keyCode === _KeyCode.default.LEFT && value < count && reverse) {
if (allowHalf) {
value += 0.5;
} else {
value += 1;
}
_this.changeValue(value);
event.preventDefault();
}

@@ -182,18 +206,18 @@

}
});
};
_defineProperty(_assertThisInitialized(_this), "saveRef", function (index) {
_this.saveRef = function (index) {
return function (node) {
_this.stars[index] = node;
};
});
};
_defineProperty(_assertThisInitialized(_this), "saveRate", function (node) {
_this.saveRate = function (node) {
_this.rate = node;
});
};
var _value = props.value;
var value = props.value;
if (_value === undefined) {
_value = props.defaultValue;
if (value === undefined) {
value = props.defaultValue;
}

@@ -203,3 +227,3 @@

_this.state = {
value: _value,
value: value,
focused: false,

@@ -225,3 +249,3 @@ cleanedValue: null

value: function getStarDOM(index) {
return _reactDom["default"].findDOMNode(this.stars[index]);
return (0, _findDOMNode.default)(this.stars[index]);
}

@@ -231,3 +255,6 @@ }, {

value: function getStarValue(index, x) {
var allowHalf = this.props.allowHalf;
var _this$props3 = this.props,
allowHalf = _this$props3.allowHalf,
direction = _this$props3.direction;
var reverse = direction === 'rtl';
var value = index + 1;

@@ -240,4 +267,6 @@

if (x - leftDis < width / 2) {
if (reverse && x - leftDis > width / 2) {
value -= 0.5;
} else if (!reverse && x - leftDis < width / 2) {
value -= 0.5;
}

@@ -282,12 +311,13 @@ }

value: function render() {
var _this$props3 = this.props,
count = _this$props3.count,
allowHalf = _this$props3.allowHalf,
style = _this$props3.style,
prefixCls = _this$props3.prefixCls,
disabled = _this$props3.disabled,
className = _this$props3.className,
character = _this$props3.character,
characterRender = _this$props3.characterRender,
tabIndex = _this$props3.tabIndex;
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;
var _this$state = this.state,

@@ -300,4 +330,4 @@ value = _this$state.value,

for (var index = 0; index < count; index++) {
stars.push(_react["default"].createElement(_Star["default"], {
for (var index = 0; index < count; index += 1) {
stars.push(_react.default.createElement(_Star.default, {
ref: this.saveRef(index),

@@ -319,4 +349,5 @@ index: index,

return _react["default"].createElement("ul", {
className: (0, _classnames["default"])(prefixCls, disabledClass, className),
var rateClassName = (0, _classnames.default)(prefixCls, disabledClass, className, _defineProperty({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'));
return _react.default.createElement("ul", {
className: rateClassName,
style: style,

@@ -346,26 +377,5 @@ onMouseLeave: disabled ? null : this.onMouseLeave,

return Rate;
}(_react["default"].Component);
}(_react.default.Component);
_defineProperty(Rate, "propTypes", {
disabled: _propTypes["default"].bool,
value: _propTypes["default"].number,
defaultValue: _propTypes["default"].number,
count: _propTypes["default"].number,
allowHalf: _propTypes["default"].bool,
allowClear: _propTypes["default"].bool,
style: _propTypes["default"].object,
prefixCls: _propTypes["default"].string,
onChange: _propTypes["default"].func,
onHoverChange: _propTypes["default"].func,
className: _propTypes["default"].string,
character: _propTypes["default"].node,
characterRender: _propTypes["default"].func,
tabIndex: _propTypes["default"].number,
onFocus: _propTypes["default"].func,
onBlur: _propTypes["default"].func,
onKeyDown: _propTypes["default"].func,
autoFocus: _propTypes["default"].bool
});
_defineProperty(Rate, "defaultProps", {
Rate.defaultProps = {
defaultValue: 0,

@@ -380,7 +390,6 @@ count: 5,

onHoverChange: noop,
tabIndex: 0
});
(0, _reactLifecyclesCompat.polyfill)(Rate);
tabIndex: 0,
direction: 'ltr'
};
var _default = Rate;
exports["default"] = _default;
exports.default = _default;

@@ -6,9 +6,9 @@ "use strict";

});
exports["default"] = void 0;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -21,22 +21,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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 Star =
/*#__PURE__*/
function (_React$Component) {
var Star = /*#__PURE__*/function (_React$Component) {
_inherits(Star, _React$Component);
var _super = _createSuper(Star);
function Star() {
var _getPrototypeOf2;
var _this;

@@ -46,9 +46,5 @@

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.apply(this, arguments);
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Star)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "onHover", function (e) {
_this.onHover = function (e) {
var _this$props = _this.props,

@@ -58,5 +54,5 @@ onHover = _this$props.onHover,

onHover(e, index);
});
};
_defineProperty(_assertThisInitialized(_this), "onClick", function (e) {
_this.onClick = function (e) {
var _this$props2 = _this.props,

@@ -66,5 +62,5 @@ onClick = _this$props2.onClick,

onClick(e, index);
});
};
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (e) {
_this.onKeyDown = function (e) {
var _this$props3 = _this.props,

@@ -77,3 +73,3 @@ onClick = _this$props3.onClick,

}
});
};

@@ -128,5 +124,5 @@ return _this;

var start = _react["default"].createElement("li", {
var start = _react.default.createElement("li", {
className: this.getClassName()
}, _react["default"].createElement("div", {
}, _react.default.createElement("div", {
onClick: disabled ? null : onClick,

@@ -140,5 +136,5 @@ onKeyDown: disabled ? null : onKeyDown,

tabIndex: 0
}, _react["default"].createElement("div", {
}, _react.default.createElement("div", {
className: "".concat(prefixCls, "-first")
}, character), _react["default"].createElement("div", {
}, character), _react.default.createElement("div", {
className: "".concat(prefixCls, "-second")

@@ -156,18 +152,4 @@ }, character)));

return Star;
}(_react["default"].Component);
}(_react.default.Component);
exports["default"] = Star;
_defineProperty(Star, "propTypes", {
value: _propTypes["default"].number,
index: _propTypes["default"].number,
prefixCls: _propTypes["default"].string,
allowHalf: _propTypes["default"].bool,
disabled: _propTypes["default"].bool,
onHover: _propTypes["default"].func,
onClick: _propTypes["default"].func,
character: _propTypes["default"].node,
characterRender: _propTypes["default"].func,
focused: _propTypes["default"].bool,
count: _propTypes["default"].number
});
exports.default = Star;

@@ -9,5 +9,5 @@ "use strict";

/* eslint-disable import/prefer-default-export */
function getScroll(w, top) {
var ret = top ? w.pageYOffset : w.pageXOffset;
var method = top ? 'scrollTop' : 'scrollLeft';
function getScroll(w) {
var ret = w.pageXOffset;
var method = 'scrollLeft';

@@ -47,3 +47,4 @@ if (typeof ret !== 'number') {

var pos = getClientPosition(el);
var doc = el.ownerDocument;
var doc = el.ownerDocument; // Only IE use `parentWindow`
var w = doc.defaultView || doc.parentWindow;

@@ -50,0 +51,0 @@ pos.left += getScroll(w);

{
"name": "rc-rate",
"version": "2.5.1",
"version": "2.6.0",
"description": "React Star Rate Component",
"engines": {
"node": ">=8.x"
},
"keywords": [

@@ -24,45 +27,42 @@ "react",

],
"licenses": "MIT",
"license": "MIT",
"main": "./lib/index",
"module": "./es/index",
"config": {
"port": 8000
},
"scripts": {
"build": "rc-tools run build",
"compile": "rc-tools run compile --babel-runtime",
"gh-pages": "rc-tools run gh-pages",
"start": "rc-tools run server",
"pub": "rc-tools run pub",
"lint": "rc-tools run lint",
"test": "rc-tools run test",
"coverage": "rc-tools run test --coverage",
"pre-commit": "rc-tools run pre-commit",
"lint-staged": "lint-staged"
"start": "cross-env NODE_ENV=development father doc dev --storybook",
"build": "father doc build --storybook",
"compile": "father build && lessc assets/index.less assets/index.css",
"gh-pages": "npm run build && father doc deploy",
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
"postpublish": "npm run gh-pages",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"test": "father test",
"coverage": "father test --coverage"
},
"peerDependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"dependencies": {
"classnames": "^2.2.5",
"prop-types": "^15.5.8",
"rc-util": "^4.3.0",
"react-lifecycles-compat": "^3.0.4"
"rc-util": "^4.20.1"
},
"devDependencies": {
"@types/classnames": "^2.2.9",
"@types/jest": "^25.1.0",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@umijs/fabric": "^2.0.0",
"cross-env": "^7.0.0",
"enzyme": "^3.1.1",
"jest": "^21.2.1",
"lint-staged": "^8.1.0",
"pre-commit": "1.x",
"rc-tools": "^9.2.0",
"rc-tooltip": "^3.7.3",
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.1.2",
"father": "^2.22.0",
"np": "^6.0.0",
"rc-tooltip": "^4.0.3",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"pre-commit": [
"lint-staged"
],
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"npm run pre-commit",
"git add"
]
"react-dom": "^16.0.0",
"typescript": "^3.7.2"
}
}

@@ -71,3 +71,3 @@ # rc-rate

cosnt StyledRate = styled(Rate)`
const StyledRate = styled(Rate)`
&.rc-rate {

@@ -158,2 +158,8 @@ font-size: ${({ size }) => size}px;

</tr>
<tr>
<td>direction</td>
<td>string</td>
<td>ltr</td>
<td>The direction of rate</td>
</tr>
</tbody>

@@ -160,0 +166,0 @@ </table>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc