1 | var _excluded = ["children", "className", "barClassName", "cssModule", "value", "min", "max", "animated", "striped", "color", "bar", "multi", "tag", "style", "barStyle", "barAriaValueText", "barAriaLabelledBy"];
|
2 | function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
3 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5 | 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; }
|
6 | 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; }
|
7 | 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; }
|
8 | import React from 'react';
|
9 | import PropTypes from 'prop-types';
|
10 | import classNames from 'classnames';
|
11 | import { mapToCssModules, tagPropType, toNumber } from './utils';
|
12 | var propTypes = {
|
13 |
|
14 | animated: PropTypes.bool,
|
15 | bar: PropTypes.bool,
|
16 | barAriaLabelledBy: PropTypes.string,
|
17 | barAriaValueText: PropTypes.string,
|
18 | barClassName: PropTypes.string,
|
19 | barStyle: PropTypes.object,
|
20 | children: PropTypes.node,
|
21 |
|
22 | className: PropTypes.string,
|
23 |
|
24 | cssModule: PropTypes.object,
|
25 |
|
26 | color: PropTypes.string,
|
27 |
|
28 | max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
29 |
|
30 | min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
31 | multi: PropTypes.bool,
|
32 |
|
33 | striped: PropTypes.bool,
|
34 | style: PropTypes.object,
|
35 |
|
36 | tag: tagPropType,
|
37 |
|
38 | value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
39 | };
|
40 | function Progress(props) {
|
41 | var children = props.children,
|
42 | className = props.className,
|
43 | barClassName = props.barClassName,
|
44 | cssModule = props.cssModule,
|
45 | _props$value = props.value,
|
46 | value = _props$value === void 0 ? 0 : _props$value,
|
47 | _props$min = props.min,
|
48 | min = _props$min === void 0 ? 0 : _props$min,
|
49 | _props$max = props.max,
|
50 | max = _props$max === void 0 ? 100 : _props$max,
|
51 | animated = props.animated,
|
52 | striped = props.striped,
|
53 | color = props.color,
|
54 | bar = props.bar,
|
55 | multi = props.multi,
|
56 | _props$tag = props.tag,
|
57 | Tag = _props$tag === void 0 ? 'div' : _props$tag,
|
58 | _props$style = props.style,
|
59 | style = _props$style === void 0 ? {} : _props$style,
|
60 | _props$barStyle = props.barStyle,
|
61 | barStyle = _props$barStyle === void 0 ? {} : _props$barStyle,
|
62 | barAriaValueText = props.barAriaValueText,
|
63 | barAriaLabelledBy = props.barAriaLabelledBy,
|
64 | attributes = _objectWithoutProperties(props, _excluded);
|
65 | var percent = toNumber(value) / toNumber(max) * 100;
|
66 | var progressClasses = mapToCssModules(classNames(className, 'progress'), cssModule);
|
67 | var progressBarClasses = mapToCssModules(classNames('progress-bar', bar ? className || barClassName : barClassName, animated ? 'progress-bar-animated' : null, color ? "bg-".concat(color) : null, striped || animated ? 'progress-bar-striped' : null), cssModule);
|
68 | var progressBarProps = {
|
69 | className: progressBarClasses,
|
70 | style: _objectSpread(_objectSpread(_objectSpread({}, bar ? style : {}), barStyle), {}, {
|
71 | width: "".concat(percent, "%")
|
72 | }),
|
73 | role: 'progressbar',
|
74 | 'aria-valuenow': value,
|
75 | 'aria-valuemin': min,
|
76 | 'aria-valuemax': max,
|
77 | 'aria-valuetext': barAriaValueText,
|
78 | 'aria-labelledby': barAriaLabelledBy,
|
79 | children: children
|
80 | };
|
81 | if (bar) {
|
82 | return React.createElement(Tag, _extends({}, attributes, progressBarProps));
|
83 | }
|
84 | return React.createElement(Tag, _extends({}, attributes, {
|
85 | style: style,
|
86 | className: progressClasses
|
87 | }), multi ? children : React.createElement("div", progressBarProps));
|
88 | }
|
89 | Progress.propTypes = propTypes;
|
90 | export default Progress; |
\ | No newline at end of file |