Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-progress

Package Overview
Dependencies
Maintainers
5
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-progress - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1

es/enhancer.js

230

es/Circle.js

@@ -0,23 +1,38 @@

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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _extends() { _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; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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); } }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { 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 _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 _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; }
/* eslint react/prop-types: 0 */
import React, { useMemo } from 'react';
import classNames from 'classnames';
import { useTransitionDuration, defaultProps } from './common';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import enhancer from './enhancer';
import { propTypes, defaultProps } from './types';
var gradientSeed = 0;

@@ -80,87 +95,128 @@

var Circle = function Circle(_ref) {
var prefixCls = _ref.prefixCls,
strokeWidth = _ref.strokeWidth,
trailWidth = _ref.trailWidth,
gapDegree = _ref.gapDegree,
gapPosition = _ref.gapPosition,
trailColor = _ref.trailColor,
strokeLinecap = _ref.strokeLinecap,
style = _ref.style,
className = _ref.className,
strokeColor = _ref.strokeColor,
percent = _ref.percent,
restProps = _objectWithoutProperties(_ref, ["prefixCls", "strokeWidth", "trailWidth", "gapDegree", "gapPosition", "trailColor", "strokeLinecap", "style", "className", "strokeColor", "percent"]);
var Circle = /*#__PURE__*/function (_Component) {
_inherits(Circle, _Component);
var gradientId = useMemo(function () {
var _super = _createSuper(Circle);
function Circle() {
var _this;
_classCallCheck(this, Circle);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "paths", {});
_defineProperty(_assertThisInitialized(_this), "gradientId", 0);
_this.gradientId = gradientSeed;
gradientSeed += 1;
return gradientSeed;
}, []);
return _this;
}
var _getPathStyles = getPathStyles(0, 100, trailColor, strokeWidth, gapDegree, gapPosition),
pathString = _getPathStyles.pathString,
pathStyle = _getPathStyles.pathStyle;
_createClass(Circle, [{
key: "getStokeList",
value: function getStokeList() {
var _this2 = this;
var percentList = toArray(percent);
var strokeColorList = toArray(strokeColor);
var gradient = strokeColorList.find(function (color) {
return Object.prototype.toString.call(color) === '[object Object]';
});
var _this$props = this.props,
prefixCls = _this$props.prefixCls,
percent = _this$props.percent,
strokeColor = _this$props.strokeColor,
strokeWidth = _this$props.strokeWidth,
strokeLinecap = _this$props.strokeLinecap,
gapDegree = _this$props.gapDegree,
gapPosition = _this$props.gapPosition;
var percentList = toArray(percent);
var strokeColorList = toArray(strokeColor);
var stackPtg = 0;
return percentList.map(function (ptg, index) {
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
var stroke = Object.prototype.toString.call(color) === '[object Object]' ? "url(#".concat(prefixCls, "-gradient-").concat(_this2.gradientId, ")") : '';
var _useTransitionDuratio = useTransitionDuration(percentList),
_useTransitionDuratio2 = _slicedToArray(_useTransitionDuratio, 1),
paths = _useTransitionDuratio2[0];
var _getPathStyles = getPathStyles(stackPtg, ptg, color, strokeWidth, gapDegree, gapPosition),
pathString = _getPathStyles.pathString,
pathStyle = _getPathStyles.pathStyle;
var getStokeList = function getStokeList() {
var stackPtg = 0;
return percentList.map(function (ptg, index) {
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
var stroke = Object.prototype.toString.call(color) === '[object Object]' ? "url(#".concat(prefixCls, "-gradient-").concat(gradientId, ")") : '';
var pathStyles = getPathStyles(stackPtg, ptg, color, strokeWidth, gapDegree, gapPosition);
stackPtg += ptg;
return /*#__PURE__*/React.createElement("path", {
key: index,
className: "".concat(prefixCls, "-circle-path"),
d: pathStyles.pathString,
stroke: stroke,
stackPtg += ptg;
return /*#__PURE__*/React.createElement("path", {
key: index,
className: "".concat(prefixCls, "-circle-path"),
d: pathString,
stroke: stroke,
strokeLinecap: strokeLinecap,
strokeWidth: strokeWidth,
opacity: ptg === 0 ? 0 : 1,
fillOpacity: "0",
style: pathStyle,
ref: function ref(path) {
_this2.paths[index] = path;
}
});
});
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
prefixCls = _this$props2.prefixCls,
strokeWidth = _this$props2.strokeWidth,
trailWidth = _this$props2.trailWidth,
gapDegree = _this$props2.gapDegree,
gapPosition = _this$props2.gapPosition,
trailColor = _this$props2.trailColor,
strokeLinecap = _this$props2.strokeLinecap,
style = _this$props2.style,
className = _this$props2.className,
strokeColor = _this$props2.strokeColor,
restProps = _objectWithoutProperties(_this$props2, ["prefixCls", "strokeWidth", "trailWidth", "gapDegree", "gapPosition", "trailColor", "strokeLinecap", "style", "className", "strokeColor"]);
var _getPathStyles2 = getPathStyles(0, 100, trailColor, strokeWidth, gapDegree, gapPosition),
pathString = _getPathStyles2.pathString,
pathStyle = _getPathStyles2.pathStyle;
delete restProps.percent;
var strokeColorList = toArray(strokeColor);
var gradient = strokeColorList.find(function (color) {
return Object.prototype.toString.call(color) === '[object Object]';
});
return /*#__PURE__*/React.createElement("svg", _extends({
className: "".concat(prefixCls, "-circle ").concat(className),
viewBox: "0 0 100 100",
style: style
}, restProps), gradient && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
id: "".concat(prefixCls, "-gradient-").concat(this.gradientId),
x1: "100%",
y1: "0%",
x2: "0%",
y2: "0%"
}, Object.keys(gradient).sort(function (a, b) {
return stripPercentToNumber(a) - stripPercentToNumber(b);
}).map(function (key, index) {
return /*#__PURE__*/React.createElement("stop", {
key: index,
offset: key,
stopColor: gradient[key]
});
}))), /*#__PURE__*/React.createElement("path", {
className: "".concat(prefixCls, "-circle-trail"),
d: pathString,
stroke: trailColor,
strokeLinecap: strokeLinecap,
strokeWidth: strokeWidth,
opacity: ptg === 0 ? 0 : 1,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0",
style: pathStyles.pathStyle,
ref: paths[index]
});
});
};
style: pathStyle
}), this.getStokeList().reverse());
}
}]);
return /*#__PURE__*/React.createElement("svg", _extends({
className: classNames("".concat(prefixCls, "-circle"), className),
viewBox: "0 0 100 100",
style: style
}, restProps), gradient && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
id: "".concat(prefixCls, "-gradient-").concat(gradientId),
x1: "100%",
y1: "0%",
x2: "0%",
y2: "0%"
}, Object.keys(gradient).sort(function (a, b) {
return stripPercentToNumber(a) - stripPercentToNumber(b);
}).map(function (key, index) {
return /*#__PURE__*/React.createElement("stop", {
key: index,
offset: key,
stopColor: gradient[key]
});
}))), /*#__PURE__*/React.createElement("path", {
className: "".concat(prefixCls, "-circle-trail"),
d: pathString,
stroke: trailColor,
strokeLinecap: strokeLinecap,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0",
style: pathStyle
}), getStokeList().reverse());
};
return Circle;
}(Component);
Circle.defaultProps = defaultProps;
export default Circle;
Circle.propTypes = _objectSpread(_objectSpread({}, propTypes), {}, {
gapPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right'])
});
Circle.defaultProps = _objectSpread(_objectSpread({}, defaultProps), {}, {
gapPosition: 'top'
});
export default enhancer(Circle);
function _extends() { _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; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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); } }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
/* eslint react/prop-types: 0 */
import React from 'react';
import classNames from 'classnames';
import { useTransitionDuration, defaultProps } from './common';
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
var Line = function Line(_ref) {
var className = _ref.className,
percent = _ref.percent,
prefixCls = _ref.prefixCls,
strokeColor = _ref.strokeColor,
strokeLinecap = _ref.strokeLinecap,
strokeWidth = _ref.strokeWidth,
style = _ref.style,
trailColor = _ref.trailColor,
trailWidth = _ref.trailWidth,
transition = _ref.transition,
restProps = _objectWithoutProperties(_ref, ["className", "percent", "prefixCls", "strokeColor", "strokeLinecap", "strokeWidth", "style", "trailColor", "trailWidth", "transition"]);
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
delete restProps.gapPosition;
var percentList = Array.isArray(percent) ? percent : [percent];
var strokeColorList = Array.isArray(strokeColor) ? strokeColor : [strokeColor];
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; } }
var _useTransitionDuratio = useTransitionDuration(percentList),
_useTransitionDuratio2 = _slicedToArray(_useTransitionDuratio, 1),
paths = _useTransitionDuratio2[0];
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var center = strokeWidth / 2;
var right = 100 - strokeWidth / 2;
var pathString = "M ".concat(strokeLinecap === 'round' ? center : 0, ",").concat(center, "\n L ").concat(strokeLinecap === 'round' ? right : 100, ",").concat(center);
var viewBoxString = "0 0 100 ".concat(strokeWidth);
var stackPtg = 0;
return /*#__PURE__*/React.createElement("svg", _extends({
className: classNames("".concat(prefixCls, "-line"), className),
viewBox: viewBoxString,
preserveAspectRatio: "none",
style: style
}, restProps), /*#__PURE__*/React.createElement("path", {
className: "".concat(prefixCls, "-line-trail"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: trailColor,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0"
}), percentList.map(function (ptg, index) {
var pathStyle = {
strokeDasharray: "".concat(ptg, "px, 100px"),
strokeDashoffset: "-".concat(stackPtg, "px"),
transition: transition || 'stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear'
};
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
stackPtg += ptg;
return /*#__PURE__*/React.createElement("path", {
key: index,
className: "".concat(prefixCls, "-line-path"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: color,
strokeWidth: strokeWidth,
fillOpacity: "0",
ref: paths[index],
style: pathStyle
});
}));
};
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, { Component } from 'react';
import enhancer from './enhancer';
import { propTypes, defaultProps } from './types';
var Line = /*#__PURE__*/function (_Component) {
_inherits(Line, _Component);
var _super = _createSuper(Line);
function Line() {
var _this;
_classCallCheck(this, Line);
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));
_defineProperty(_assertThisInitialized(_this), "paths", {});
return _this;
}
_createClass(Line, [{
key: "render",
value: function render() {
var _this2 = this;
var _this$props = this.props,
className = _this$props.className,
percent = _this$props.percent,
prefixCls = _this$props.prefixCls,
strokeColor = _this$props.strokeColor,
strokeLinecap = _this$props.strokeLinecap,
strokeWidth = _this$props.strokeWidth,
style = _this$props.style,
trailColor = _this$props.trailColor,
trailWidth = _this$props.trailWidth,
transition = _this$props.transition,
restProps = _objectWithoutProperties(_this$props, ["className", "percent", "prefixCls", "strokeColor", "strokeLinecap", "strokeWidth", "style", "trailColor", "trailWidth", "transition"]);
delete restProps.gapPosition;
var percentList = Array.isArray(percent) ? percent : [percent];
var strokeColorList = Array.isArray(strokeColor) ? strokeColor : [strokeColor];
var center = strokeWidth / 2;
var right = 100 - strokeWidth / 2;
var pathString = "M ".concat(strokeLinecap === 'round' ? center : 0, ",").concat(center, "\n L ").concat(strokeLinecap === 'round' ? right : 100, ",").concat(center);
var viewBoxString = "0 0 100 ".concat(strokeWidth);
var stackPtg = 0;
return /*#__PURE__*/React.createElement("svg", _extends({
className: "".concat(prefixCls, "-line ").concat(className),
viewBox: viewBoxString,
preserveAspectRatio: "none",
style: style
}, restProps), /*#__PURE__*/React.createElement("path", {
className: "".concat(prefixCls, "-line-trail"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: trailColor,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0"
}), percentList.map(function (ptg, index) {
var pathStyle = {
strokeDasharray: "".concat(ptg, "px, 100px"),
strokeDashoffset: "-".concat(stackPtg, "px"),
transition: transition || 'stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear'
};
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
stackPtg += ptg;
return /*#__PURE__*/React.createElement("path", {
key: index,
className: "".concat(prefixCls, "-line-path"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: color,
strokeWidth: strokeWidth,
fillOpacity: "0",
ref: function ref(path) {
_this2.paths[index] = path;
},
style: pathStyle
});
}));
}
}]);
return Line;
}(Component);
Line.propTypes = propTypes;
Line.defaultProps = defaultProps;
export default Line;
export default enhancer(Line);

@@ -5,6 +5,2 @@ # History

## 2.6.0
- Refactor to hooks.
## 2.5.0

@@ -11,0 +7,0 @@

@@ -10,30 +10,46 @@ "use strict";

var _classnames = _interopRequireDefault(require("classnames"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _common = require("./common");
var _enhancer = _interopRequireDefault(require("./enhancer"));
var _types = require("./types");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _extends() { _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; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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); } }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { 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 _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 _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 gradientSeed = 0;

@@ -96,88 +112,131 @@

var Circle = function Circle(_ref) {
var prefixCls = _ref.prefixCls,
strokeWidth = _ref.strokeWidth,
trailWidth = _ref.trailWidth,
gapDegree = _ref.gapDegree,
gapPosition = _ref.gapPosition,
trailColor = _ref.trailColor,
strokeLinecap = _ref.strokeLinecap,
style = _ref.style,
className = _ref.className,
strokeColor = _ref.strokeColor,
percent = _ref.percent,
restProps = _objectWithoutProperties(_ref, ["prefixCls", "strokeWidth", "trailWidth", "gapDegree", "gapPosition", "trailColor", "strokeLinecap", "style", "className", "strokeColor", "percent"]);
var Circle = /*#__PURE__*/function (_Component) {
_inherits(Circle, _Component);
var gradientId = (0, _react.useMemo)(function () {
var _super = _createSuper(Circle);
function Circle() {
var _this;
_classCallCheck(this, Circle);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "paths", {});
_defineProperty(_assertThisInitialized(_this), "gradientId", 0);
_this.gradientId = gradientSeed;
gradientSeed += 1;
return gradientSeed;
}, []);
return _this;
}
var _getPathStyles = getPathStyles(0, 100, trailColor, strokeWidth, gapDegree, gapPosition),
pathString = _getPathStyles.pathString,
pathStyle = _getPathStyles.pathStyle;
_createClass(Circle, [{
key: "getStokeList",
value: function getStokeList() {
var _this2 = this;
var percentList = toArray(percent);
var strokeColorList = toArray(strokeColor);
var gradient = strokeColorList.find(function (color) {
return Object.prototype.toString.call(color) === '[object Object]';
});
var _this$props = this.props,
prefixCls = _this$props.prefixCls,
percent = _this$props.percent,
strokeColor = _this$props.strokeColor,
strokeWidth = _this$props.strokeWidth,
strokeLinecap = _this$props.strokeLinecap,
gapDegree = _this$props.gapDegree,
gapPosition = _this$props.gapPosition;
var percentList = toArray(percent);
var strokeColorList = toArray(strokeColor);
var stackPtg = 0;
return percentList.map(function (ptg, index) {
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
var stroke = Object.prototype.toString.call(color) === '[object Object]' ? "url(#".concat(prefixCls, "-gradient-").concat(_this2.gradientId, ")") : '';
var _useTransitionDuratio = (0, _common.useTransitionDuration)(percentList),
_useTransitionDuratio2 = _slicedToArray(_useTransitionDuratio, 1),
paths = _useTransitionDuratio2[0];
var _getPathStyles = getPathStyles(stackPtg, ptg, color, strokeWidth, gapDegree, gapPosition),
pathString = _getPathStyles.pathString,
pathStyle = _getPathStyles.pathStyle;
var getStokeList = function getStokeList() {
var stackPtg = 0;
return percentList.map(function (ptg, index) {
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
var stroke = Object.prototype.toString.call(color) === '[object Object]' ? "url(#".concat(prefixCls, "-gradient-").concat(gradientId, ")") : '';
var pathStyles = getPathStyles(stackPtg, ptg, color, strokeWidth, gapDegree, gapPosition);
stackPtg += ptg;
return /*#__PURE__*/_react["default"].createElement("path", {
key: index,
className: "".concat(prefixCls, "-circle-path"),
d: pathStyles.pathString,
stroke: stroke,
stackPtg += ptg;
return /*#__PURE__*/_react["default"].createElement("path", {
key: index,
className: "".concat(prefixCls, "-circle-path"),
d: pathString,
stroke: stroke,
strokeLinecap: strokeLinecap,
strokeWidth: strokeWidth,
opacity: ptg === 0 ? 0 : 1,
fillOpacity: "0",
style: pathStyle,
ref: function ref(path) {
_this2.paths[index] = path;
}
});
});
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
prefixCls = _this$props2.prefixCls,
strokeWidth = _this$props2.strokeWidth,
trailWidth = _this$props2.trailWidth,
gapDegree = _this$props2.gapDegree,
gapPosition = _this$props2.gapPosition,
trailColor = _this$props2.trailColor,
strokeLinecap = _this$props2.strokeLinecap,
style = _this$props2.style,
className = _this$props2.className,
strokeColor = _this$props2.strokeColor,
restProps = _objectWithoutProperties(_this$props2, ["prefixCls", "strokeWidth", "trailWidth", "gapDegree", "gapPosition", "trailColor", "strokeLinecap", "style", "className", "strokeColor"]);
var _getPathStyles2 = getPathStyles(0, 100, trailColor, strokeWidth, gapDegree, gapPosition),
pathString = _getPathStyles2.pathString,
pathStyle = _getPathStyles2.pathStyle;
delete restProps.percent;
var strokeColorList = toArray(strokeColor);
var gradient = strokeColorList.find(function (color) {
return Object.prototype.toString.call(color) === '[object Object]';
});
return /*#__PURE__*/_react["default"].createElement("svg", _extends({
className: "".concat(prefixCls, "-circle ").concat(className),
viewBox: "0 0 100 100",
style: style
}, restProps), gradient && /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement("linearGradient", {
id: "".concat(prefixCls, "-gradient-").concat(this.gradientId),
x1: "100%",
y1: "0%",
x2: "0%",
y2: "0%"
}, Object.keys(gradient).sort(function (a, b) {
return stripPercentToNumber(a) - stripPercentToNumber(b);
}).map(function (key, index) {
return /*#__PURE__*/_react["default"].createElement("stop", {
key: index,
offset: key,
stopColor: gradient[key]
});
}))), /*#__PURE__*/_react["default"].createElement("path", {
className: "".concat(prefixCls, "-circle-trail"),
d: pathString,
stroke: trailColor,
strokeLinecap: strokeLinecap,
strokeWidth: strokeWidth,
opacity: ptg === 0 ? 0 : 1,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0",
style: pathStyles.pathStyle,
ref: paths[index]
});
});
};
style: pathStyle
}), this.getStokeList().reverse());
}
}]);
return /*#__PURE__*/_react["default"].createElement("svg", _extends({
className: (0, _classnames["default"])("".concat(prefixCls, "-circle"), className),
viewBox: "0 0 100 100",
style: style
}, restProps), gradient && /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement("linearGradient", {
id: "".concat(prefixCls, "-gradient-").concat(gradientId),
x1: "100%",
y1: "0%",
x2: "0%",
y2: "0%"
}, Object.keys(gradient).sort(function (a, b) {
return stripPercentToNumber(a) - stripPercentToNumber(b);
}).map(function (key, index) {
return /*#__PURE__*/_react["default"].createElement("stop", {
key: index,
offset: key,
stopColor: gradient[key]
});
}))), /*#__PURE__*/_react["default"].createElement("path", {
className: "".concat(prefixCls, "-circle-trail"),
d: pathString,
stroke: trailColor,
strokeLinecap: strokeLinecap,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0",
style: pathStyle
}), getStokeList().reverse());
};
return Circle;
}(_react.Component);
Circle.defaultProps = _common.defaultProps;
var _default = Circle;
Circle.propTypes = _objectSpread(_objectSpread({}, _types.propTypes), {}, {
gapPosition: _propTypes["default"].oneOf(['top', 'bottom', 'left', 'right'])
});
Circle.defaultProps = _objectSpread(_objectSpread({}, _types.defaultProps), {}, {
gapPosition: 'top'
});
var _default = (0, _enhancer["default"])(Circle);
exports["default"] = _default;

@@ -8,90 +8,134 @@ "use strict";

var _react = _interopRequireDefault(require("react"));
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _enhancer = _interopRequireDefault(require("./enhancer"));
var _common = require("./common");
var _types = require("./types");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _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; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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); } }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
var Line = function Line(_ref) {
var className = _ref.className,
percent = _ref.percent,
prefixCls = _ref.prefixCls,
strokeColor = _ref.strokeColor,
strokeLinecap = _ref.strokeLinecap,
strokeWidth = _ref.strokeWidth,
style = _ref.style,
trailColor = _ref.trailColor,
trailWidth = _ref.trailWidth,
transition = _ref.transition,
restProps = _objectWithoutProperties(_ref, ["className", "percent", "prefixCls", "strokeColor", "strokeLinecap", "strokeWidth", "style", "trailColor", "trailWidth", "transition"]);
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
delete restProps.gapPosition;
var percentList = Array.isArray(percent) ? percent : [percent];
var strokeColorList = Array.isArray(strokeColor) ? strokeColor : [strokeColor];
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var _useTransitionDuratio = (0, _common.useTransitionDuration)(percentList),
_useTransitionDuratio2 = _slicedToArray(_useTransitionDuratio, 1),
paths = _useTransitionDuratio2[0];
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; } }
var center = strokeWidth / 2;
var right = 100 - strokeWidth / 2;
var pathString = "M ".concat(strokeLinecap === 'round' ? center : 0, ",").concat(center, "\n L ").concat(strokeLinecap === 'round' ? right : 100, ",").concat(center);
var viewBoxString = "0 0 100 ".concat(strokeWidth);
var stackPtg = 0;
return /*#__PURE__*/_react["default"].createElement("svg", _extends({
className: (0, _classnames["default"])("".concat(prefixCls, "-line"), className),
viewBox: viewBoxString,
preserveAspectRatio: "none",
style: style
}, restProps), /*#__PURE__*/_react["default"].createElement("path", {
className: "".concat(prefixCls, "-line-trail"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: trailColor,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0"
}), percentList.map(function (ptg, index) {
var pathStyle = {
strokeDasharray: "".concat(ptg, "px, 100px"),
strokeDashoffset: "-".concat(stackPtg, "px"),
transition: transition || 'stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear'
};
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
stackPtg += ptg;
return /*#__PURE__*/_react["default"].createElement("path", {
key: index,
className: "".concat(prefixCls, "-line-path"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: color,
strokeWidth: strokeWidth,
fillOpacity: "0",
ref: paths[index],
style: pathStyle
});
}));
};
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
Line.defaultProps = _common.defaultProps;
var _default = Line;
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 Line = /*#__PURE__*/function (_Component) {
_inherits(Line, _Component);
var _super = _createSuper(Line);
function Line() {
var _this;
_classCallCheck(this, Line);
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));
_defineProperty(_assertThisInitialized(_this), "paths", {});
return _this;
}
_createClass(Line, [{
key: "render",
value: function render() {
var _this2 = this;
var _this$props = this.props,
className = _this$props.className,
percent = _this$props.percent,
prefixCls = _this$props.prefixCls,
strokeColor = _this$props.strokeColor,
strokeLinecap = _this$props.strokeLinecap,
strokeWidth = _this$props.strokeWidth,
style = _this$props.style,
trailColor = _this$props.trailColor,
trailWidth = _this$props.trailWidth,
transition = _this$props.transition,
restProps = _objectWithoutProperties(_this$props, ["className", "percent", "prefixCls", "strokeColor", "strokeLinecap", "strokeWidth", "style", "trailColor", "trailWidth", "transition"]);
delete restProps.gapPosition;
var percentList = Array.isArray(percent) ? percent : [percent];
var strokeColorList = Array.isArray(strokeColor) ? strokeColor : [strokeColor];
var center = strokeWidth / 2;
var right = 100 - strokeWidth / 2;
var pathString = "M ".concat(strokeLinecap === 'round' ? center : 0, ",").concat(center, "\n L ").concat(strokeLinecap === 'round' ? right : 100, ",").concat(center);
var viewBoxString = "0 0 100 ".concat(strokeWidth);
var stackPtg = 0;
return /*#__PURE__*/_react["default"].createElement("svg", _extends({
className: "".concat(prefixCls, "-line ").concat(className),
viewBox: viewBoxString,
preserveAspectRatio: "none",
style: style
}, restProps), /*#__PURE__*/_react["default"].createElement("path", {
className: "".concat(prefixCls, "-line-trail"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: trailColor,
strokeWidth: trailWidth || strokeWidth,
fillOpacity: "0"
}), percentList.map(function (ptg, index) {
var pathStyle = {
strokeDasharray: "".concat(ptg, "px, 100px"),
strokeDashoffset: "-".concat(stackPtg, "px"),
transition: transition || 'stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear'
};
var color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
stackPtg += ptg;
return /*#__PURE__*/_react["default"].createElement("path", {
key: index,
className: "".concat(prefixCls, "-line-path"),
d: pathString,
strokeLinecap: strokeLinecap,
stroke: color,
strokeWidth: strokeWidth,
fillOpacity: "0",
ref: function ref(path) {
_this2.paths[index] = path;
},
style: pathStyle
});
}));
}
}]);
return Line;
}(_react.Component);
Line.propTypes = _types.propTypes;
Line.defaultProps = _types.defaultProps;
var _default = (0, _enhancer["default"])(Line);
exports["default"] = _default;
{
"name": "rc-progress",
"version": "2.6.0",
"version": "2.6.1",
"description": "progress ui component for react",

@@ -12,2 +12,3 @@ "keywords": [

"homepage": "http://github.com/react-component/progress",
"author": "tsjxyz@gmail.com",
"repository": {

@@ -20,3 +21,3 @@ "type": "git",

},
"license": "MIT",
"licenses": "MIT",
"main": "lib/index",

@@ -46,4 +47,4 @@ "module": "es/index",

"start": "rc-tools run server",
"compile": "rc-tools run compile",
"pub": "rc-tools run pub",
"compile": "rc-tools run compile --babel-runtime",
"pub": "rc-tools run pub --babel-runtime",
"lint": "rc-tools run lint",

@@ -74,4 +75,5 @@ "lint:fix": "rc-tools run lint --fix",

"dependencies": {
"classnames": "^2.2.6"
"babel-runtime": "6.x",
"prop-types": "^15.5.8"
}
}

@@ -8,24 +8,31 @@ # rc-progress

[![Test coverage][coveralls-image]][coveralls-url]
[![Dependencies][david-image]][david-url]
[![DevDependencies][david-dev-image]][david-dev-url]
[![gemnasium deps][gemnasium-image]][gemnasium-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]
[npm-image]: http://img.shields.io/npm/v/rc-progress.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-progress
[travis-image]: https://img.shields.io/travis/react-component/progress/master?style=flat-square
[travis-image]: https://img.shields.io/travis/react-component/progress.svg?style=flat-square
[travis-url]: https://travis-ci.org/react-component/progress
[circleci-image]: https://img.shields.io/circleci/react-component/progress/master?style=flat-square
[circleci-url]: https://circleci.com/gh/react-component/progress
[coveralls-image]: https://img.shields.io/coveralls/react-component/progress.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/react-component/progress?branch=master
[david-url]: https://david-dm.org/react-component/progress
[david-image]: https://david-dm.org/react-component/progress/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/progress?type=dev
[david-dev-image]: https://david-dm.org/react-component/progress/dev-status.svg?style=flat-square
[gemnasium-image]: http://img.shields.io/gemnasium/react-component/progress.svg?style=flat-square
[gemnasium-url]: https://gemnasium.com/react-component/progress
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/rc-progress.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-progress
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-progress
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-progress
## Example
http://react-component.github.io/progress/
## Screenshots
<img src="https://t.alipayobjects.com/images/T12p8gXjpgXXXXXXXX.gif" />
## Browsers
* support IE9+, Chrome, Firefox, Safari
## Install

@@ -37,19 +44,11 @@

```js
```jsx
import { Line, Circle } from 'rc-progress';
export default () => (
<>
<Line percent="10" strokeWidth="4" strokeColor="#D3D3D3" />
<Circle percent="10" strokeWidth="4" strokeColor="#D3D3D3" />
</>
);
ReactDOM.render(<div>
<Line percent="10" strokeWidth="4" strokeColor="#D3D3D3" />
<Circle percent="10" strokeWidth="4" strokeColor="#D3D3D3" />
</div>, container);
```
## Compatibility
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
| --- | --- | --- | --- | --- |
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
## API

@@ -56,0 +55,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc