wix-style-react
Version:
95 lines (78 loc) • 3.96 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
var _excluded = ["errorMessage", "skin", "light", "dataHook", "error", "shouldLoadAsync"];
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React from 'react';
import PropTypes from 'prop-types';
import { st, classes } from './LinearProgressBar.st.css';
import { LinearProgressBar as CoreLinearProgressBar } from "wix-ui-core/dist/es/src/components/linear-progress-bar";
import ToggleOn from 'wix-ui-icons-common/system/ToggleOn';
import StatusIndicator from '../StatusIndicator';
import { dataHooks } from './constants';
/**
* This component is used for indicating a progress along a process.*/
var LinearProgressBar = /*#__PURE__*/function (_React$PureComponent) {
_inherits(LinearProgressBar, _React$PureComponent);
var _super = _createSuper(LinearProgressBar);
function LinearProgressBar() {
_classCallCheck(this, LinearProgressBar);
return _super.apply(this, arguments);
}
_createClass(LinearProgressBar, [{
key: "render",
value: function render() {
var _this$props = this.props,
errorMessage = _this$props.errorMessage,
skin = _this$props.skin,
light = _this$props.light,
dataHook = _this$props.dataHook,
error = _this$props.error,
shouldLoadAsync = _this$props.shouldLoadAsync,
otherProps = _objectWithoutProperties(_this$props, _excluded);
return /*#__PURE__*/React.createElement(CoreLinearProgressBar, _extends({
"data-hook": dataHook,
className: st(classes.root, {
light: light,
skin: skin
}),
"data-skin": skin
}, otherProps, {
error: error,
successIcon: /*#__PURE__*/React.createElement(ToggleOn, null),
errorIcon: /*#__PURE__*/React.createElement(StatusIndicator, {
dataHook: dataHooks.errorIcon,
status: "error",
message: errorMessage
})
}));
}
}]);
return LinearProgressBar;
}(React.PureComponent);
LinearProgressBar.displayName = 'LinearProgressBar';
LinearProgressBar.propTypes = {
/** Hook for testing purposes. */
dataHook: PropTypes.string,
/** Use to apply error styles */
error: PropTypes.bool,
/** Message to display when an error happens */
errorMessage: PropTypes.string,
/** Use light theme instead of dark theme */
light: PropTypes.bool,
/** Use to display a percentage progress.*/
showProgressIndication: PropTypes.bool,
/** The number of the percentage progress */
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/** Sets the skin of the Linear Progress Bar. */
skin: PropTypes.oneOf(['standard', 'success', 'warning', 'premium'])
};
LinearProgressBar.defaultProps = {
skin: 'standard'
};
export default LinearProgressBar;