mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
90 lines
4.0 KiB
JavaScript
90 lines
4.0 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
|
|
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; }
|
|
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classNames from 'classnames';
|
|
import { mapToCssModules, tagPropType, toNumber } from './utils';
|
|
var propTypes = {
|
|
children: PropTypes.node,
|
|
bar: PropTypes.bool,
|
|
multi: PropTypes.bool,
|
|
tag: tagPropType,
|
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
animated: PropTypes.bool,
|
|
striped: PropTypes.bool,
|
|
color: PropTypes.string,
|
|
className: PropTypes.string,
|
|
barClassName: PropTypes.string,
|
|
cssModule: PropTypes.object,
|
|
style: PropTypes.object,
|
|
barStyle: PropTypes.object,
|
|
barAriaValueText: PropTypes.string,
|
|
barAriaLabelledBy: PropTypes.string
|
|
};
|
|
var defaultProps = {
|
|
tag: 'div',
|
|
value: 0,
|
|
min: 0,
|
|
max: 100,
|
|
style: {},
|
|
barStyle: {}
|
|
};
|
|
|
|
var Progress = function Progress(props) {
|
|
var children = props.children,
|
|
className = props.className,
|
|
barClassName = props.barClassName,
|
|
cssModule = props.cssModule,
|
|
value = props.value,
|
|
min = props.min,
|
|
max = props.max,
|
|
animated = props.animated,
|
|
striped = props.striped,
|
|
color = props.color,
|
|
bar = props.bar,
|
|
multi = props.multi,
|
|
Tag = props.tag,
|
|
style = props.style,
|
|
barStyle = props.barStyle,
|
|
barAriaValueText = props.barAriaValueText,
|
|
barAriaLabelledBy = props.barAriaLabelledBy,
|
|
attributes = _objectWithoutPropertiesLoose(props, ["children", "className", "barClassName", "cssModule", "value", "min", "max", "animated", "striped", "color", "bar", "multi", "tag", "style", "barStyle", "barAriaValueText", "barAriaLabelledBy"]);
|
|
|
|
var percent = toNumber(value) / toNumber(max) * 100;
|
|
var progressClasses = mapToCssModules(classNames(className, 'progress'), cssModule);
|
|
var progressBarClasses = mapToCssModules(classNames('progress-bar', bar ? className || barClassName : barClassName, animated ? 'progress-bar-animated' : null, color ? "bg-" + color : null, striped || animated ? 'progress-bar-striped' : null), cssModule);
|
|
var progressBarProps = {
|
|
className: progressBarClasses,
|
|
style: _objectSpread(_objectSpread(_objectSpread({}, bar ? style : {}), barStyle), {}, {
|
|
width: percent + "%"
|
|
}),
|
|
role: 'progressbar',
|
|
'aria-valuenow': value,
|
|
'aria-valuemin': min,
|
|
'aria-valuemax': max,
|
|
'aria-valuetext': barAriaValueText,
|
|
'aria-labelledby': barAriaLabelledBy,
|
|
children: children
|
|
};
|
|
|
|
if (bar) {
|
|
return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, progressBarProps));
|
|
}
|
|
|
|
return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
|
|
style: style,
|
|
className: progressClasses
|
|
}), multi ? children : /*#__PURE__*/React.createElement("div", progressBarProps));
|
|
};
|
|
|
|
Progress.propTypes = propTypes;
|
|
Progress.defaultProps = defaultProps;
|
|
export default Progress; |