Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,30 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface CircularProgressProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
CircularProgressClassKey
> {
color?: 'primary' | 'accent' | 'inherit';
max?: number;
min?: number;
mode?: 'determinate' | 'indeterminate';
size?: number;
value?: number;
thickness?: number;
}
export type CircularProgressClassKey =
| 'root'
| 'primaryColor'
| 'accentColor'
| 'svg'
| 'indeterminateSvg'
| 'circle'
| 'indeterminateCircle'
| 'determinateCircle'
;
declare const CircularProgress: React.ComponentType<CircularProgressProps>;
export default CircularProgress

View File

@@ -0,0 +1,227 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _withStyles = require('../styles/withStyles');
var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var SIZE = 50;
function getRelativeValue(value, min, max) {
var clampedValue = Math.min(Math.max(min, value), max);
return (clampedValue - min) / (max - min);
}
var styles = exports.styles = function styles(theme) {
return {
root: {
display: 'inline-block'
},
primaryColor: {
color: theme.palette.primary[500]
},
accentColor: {
color: theme.palette.secondary.A200
},
svgIndeterminate: {
animation: 'mui-progress-circular-rotate 1.4s linear infinite'
},
svgDeterminate: {
transform: 'rotate(-90deg)'
},
circle: {
stroke: 'currentColor',
strokeLinecap: 'round'
},
circleIndeterminate: {
animation: 'mui-progress-circular-dash 1.4s ease-in-out infinite',
// Some default value that looks fine waiting for the animation to kicks in.
strokeDasharray: '80,200',
strokeDashoffset: 0
},
'@keyframes mui-progress-circular-rotate': {
'100%': {
transform: 'rotate(360deg)'
}
},
'@keyframes mui-progress-circular-dash': {
'0%': {
strokeDasharray: '1,200',
strokeDashoffset: 0
},
'50%': {
strokeDasharray: '100,200',
strokeDashoffset: -15
},
'100%': {
strokeDasharray: '100,200',
strokeDashoffset: -120
}
}
};
};
var babelPluginFlowReactPropTypes_proptype_Color = require('prop-types').oneOf(['primary', 'accent', 'inherit']);
var babelPluginFlowReactPropTypes_proptype_Mode = require('prop-types').oneOf(['determinate', 'indeterminate']);
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color: require('prop-types').oneOf(['primary', 'accent', 'inherit']),
/**
* The max value of progress in determinate mode.
*/
max: require('prop-types').number,
/**
* The min value of progress in determinate mode.
*/
min: require('prop-types').number,
/**
* The mode of show your progress. Indeterminate
* for when there is no value for progress.
* Determinate for controlled progress value.
*/
mode: require('prop-types').oneOf(['determinate', 'indeterminate']),
/**
* The size of the circle.
*/
size: require('prop-types').number,
/**
* @ignore
*/
style: require('prop-types').object,
/**
* The thickness of the circle.
*/
thickness: require('prop-types').number,
/**
* The value of progress in determinate mode.
*/
value: require('prop-types').number
};
function CircularProgress(props) {
var _classNames;
var classes = props.classes,
className = props.className,
color = props.color,
size = props.size,
style = props.style,
thickness = props.thickness,
mode = props.mode,
value = props.value,
min = props.min,
max = props.max,
other = (0, _objectWithoutProperties3.default)(props, ['classes', 'className', 'color', 'size', 'style', 'thickness', 'mode', 'value', 'min', 'max']);
var rootProps = {};
var circleStyle = {};
if (mode === 'determinate') {
var relVal = getRelativeValue(value, min, max) * 100;
var circumference = 2 * Math.PI * (SIZE / 2 - 5);
circleStyle.strokeDashoffset = Math.round((100 - relVal) / 100 * circumference * 1000) / 1000 + 'px';
circleStyle.strokeDasharray = Math.round(circumference * 1000) / 1000;
rootProps['aria-valuenow'] = value;
rootProps['aria-valuemin'] = min;
rootProps['aria-valuemax'] = max;
}
return _react2.default.createElement(
'div',
(0, _extends3.default)({
className: (0, _classnames2.default)(classes.root, color !== 'inherit' && classes[color + 'Color'], className),
style: (0, _extends3.default)({ width: size, height: size }, style),
role: 'progressbar'
}, rootProps, other),
_react2.default.createElement(
'svg',
{
className: (0, _classnames2.default)((_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.svgIndeterminate, mode === 'indeterminate'), (0, _defineProperty3.default)(_classNames, classes.svgDeterminate, mode === 'determinate'), _classNames)),
viewBox: '0 0 ' + SIZE + ' ' + SIZE
},
_react2.default.createElement('circle', {
className: (0, _classnames2.default)(classes.circle, (0, _defineProperty3.default)({}, classes.circleIndeterminate, mode === 'indeterminate')),
style: circleStyle,
cx: SIZE / 2,
cy: SIZE / 2,
r: SIZE / 2 - 5,
fill: 'none',
strokeWidth: thickness
})
)
);
}
CircularProgress.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
color: require('prop-types').oneOf(['primary', 'accent', 'inherit']).isRequired,
size: require('prop-types').number.isRequired,
mode: require('prop-types').oneOf(['determinate', 'indeterminate']).isRequired,
value: require('prop-types').number.isRequired,
min: require('prop-types').number.isRequired,
max: require('prop-types').number.isRequired
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'color', require('prop-types').oneOf(['primary', 'accent', 'inherit'])), (0, _defineProperty3.default)(_ref, 'max', require('prop-types').number), (0, _defineProperty3.default)(_ref, 'min', require('prop-types').number), (0, _defineProperty3.default)(_ref, 'mode', require('prop-types').oneOf(['determinate', 'indeterminate'])), (0, _defineProperty3.default)(_ref, 'size', require('prop-types').number), (0, _defineProperty3.default)(_ref, 'style', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'thickness', require('prop-types').number), (0, _defineProperty3.default)(_ref, 'value', require('prop-types').number), _ref) : {};
CircularProgress.defaultProps = {
color: 'primary',
size: 40,
thickness: 3.6,
mode: 'indeterminate',
value: 0,
min: 0,
max: 100
};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiCircularProgress' })(CircularProgress);

View File

@@ -0,0 +1,195 @@
// @flow
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
const SIZE = 50;
function getRelativeValue(value, min, max) {
const clampedValue = Math.min(Math.max(min, value), max);
return (clampedValue - min) / (max - min);
}
export const styles = (theme: Object) => ({
root: {
display: 'inline-block',
},
primaryColor: {
color: theme.palette.primary[500],
},
accentColor: {
color: theme.palette.secondary.A200,
},
svgIndeterminate: {
animation: 'mui-progress-circular-rotate 1.4s linear infinite',
},
svgDeterminate: {
transform: 'rotate(-90deg)',
},
circle: {
stroke: 'currentColor',
strokeLinecap: 'round',
},
circleIndeterminate: {
animation: 'mui-progress-circular-dash 1.4s ease-in-out infinite',
// Some default value that looks fine waiting for the animation to kicks in.
strokeDasharray: '80,200',
strokeDashoffset: 0,
},
'@keyframes mui-progress-circular-rotate': {
'100%': {
transform: 'rotate(360deg)',
},
},
'@keyframes mui-progress-circular-dash': {
'0%': {
strokeDasharray: '1,200',
strokeDashoffset: 0,
},
'50%': {
strokeDasharray: '100,200',
strokeDashoffset: -15,
},
'100%': {
strokeDasharray: '100,200',
strokeDashoffset: -120,
},
},
});
export type Color = 'primary' | 'accent' | 'inherit';
export type Mode = 'determinate' | 'indeterminate';
type ProvidedProps = {
classes: Object,
color: Color,
size: number,
mode: Mode,
value: number,
min: number,
max: number,
};
export type Props = {
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color?: Color,
/**
* The max value of progress in determinate mode.
*/
max?: number,
/**
* The min value of progress in determinate mode.
*/
min?: number,
/**
* The mode of show your progress. Indeterminate
* for when there is no value for progress.
* Determinate for controlled progress value.
*/
mode?: Mode,
/**
* The size of the circle.
*/
size?: number,
/**
* @ignore
*/
style?: Object,
/**
* The thickness of the circle.
*/
thickness?: number,
/**
* The value of progress in determinate mode.
*/
value?: number,
};
function CircularProgress(props: ProvidedProps & Props) {
const {
classes,
className,
color,
size,
style,
thickness,
mode,
value,
min,
max,
...other
} = props;
const rootProps = {};
const circleStyle = {};
if (mode === 'determinate') {
const relVal = getRelativeValue(value, min, max) * 100;
const circumference = 2 * Math.PI * (SIZE / 2 - 5);
circleStyle.strokeDashoffset = `${Math.round((100 - relVal) / 100 * circumference * 1000) /
1000}px`;
circleStyle.strokeDasharray = Math.round(circumference * 1000) / 1000;
rootProps['aria-valuenow'] = value;
rootProps['aria-valuemin'] = min;
rootProps['aria-valuemax'] = max;
}
return (
<div
className={classNames(
classes.root,
color !== 'inherit' && classes[`${color}Color`],
className,
)}
style={{ width: size, height: size, ...style }}
role="progressbar"
{...rootProps}
{...other}
>
<svg
className={classNames({
[classes.svgIndeterminate]: mode === 'indeterminate',
[classes.svgDeterminate]: mode === 'determinate',
})}
viewBox={`0 0 ${SIZE} ${SIZE}`}
>
<circle
className={classNames(classes.circle, {
[classes.circleIndeterminate]: mode === 'indeterminate',
})}
style={circleStyle}
cx={SIZE / 2}
cy={SIZE / 2}
r={SIZE / 2 - 5}
fill="none"
strokeWidth={thickness}
/>
</svg>
</div>
);
}
CircularProgress.defaultProps = {
color: 'primary',
size: 40,
thickness: 3.6,
mode: 'indeterminate',
value: 0,
min: 0,
max: 100,
};
export default withStyles(styles, { name: 'MuiCircularProgress' })(CircularProgress);

View File

@@ -0,0 +1,37 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface LinearProgressProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
LinearProgressClassKey
> {
color?: 'primary' | 'accent';
mode?: 'determinate' | 'indeterminate' | 'buffer' | 'query';
value?: number;
valueBuffer?: number;
}
export type LinearProgressClassKey =
| 'root'
| 'primaryColor'
| 'primaryColorBar'
| 'primaryDashed'
| 'accentColor'
| 'accentColorBar'
| 'accentDashed'
| 'bar'
| 'dashed'
| 'bufferBar2'
| 'rootBuffer'
| 'rootQuery'
| 'indeterminateBar1'
| 'indeterminateBar2'
| 'determinateBar1'
| 'bufferBar1'
| 'bufferBar2Primary'
| 'bufferBar2Accent'
;
declare const LinearProgress: React.ComponentType<LinearProgressProps>;
export default LinearProgress;

View File

@@ -0,0 +1,265 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.styles = undefined;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _warning = require('warning');
var _warning2 = _interopRequireDefault(_warning);
var _withStyles = require('../styles/withStyles');
var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var TRANSITION_DURATION = 4; // 400ms
var styles = exports.styles = function styles(theme) {
return {
root: {
position: 'relative',
overflow: 'hidden',
height: 5
},
primaryColor: {
backgroundColor: theme.palette.primary[100]
},
primaryColorBar: {
backgroundColor: theme.palette.primary[500]
},
primaryDashed: {
background: 'radial-gradient(' + theme.palette.primary[100] + ' 0%, ' + theme.palette.primary[100] + ' 16%, transparent 42%)',
backgroundSize: '10px 10px',
backgroundPosition: '0px -23px'
},
accentColor: {
backgroundColor: theme.palette.secondary.A100
},
accentColorBar: {
backgroundColor: theme.palette.secondary.A400
},
accentDashed: {
background: 'radial-gradient(' + theme.palette.secondary.A100 + ' 0%, ' + theme.palette.secondary.A100 + ' 16%, transparent 42%)',
backgroundSize: '10px 10px',
backgroundPosition: '0px -23px'
},
bar: {
width: '100%',
position: 'absolute',
left: 0,
bottom: 0,
top: 0,
transition: 'transform 0.2s linear',
transformOrigin: 'left'
},
dashed: {
position: 'absolute',
marginTop: 0,
height: '100%',
width: '100%',
animation: 'buffer 3s infinite linear'
},
bufferBar2: {
transition: 'transform .' + TRANSITION_DURATION + 's linear'
},
rootBuffer: {
backgroundColor: 'transparent'
},
rootQuery: {
transform: 'rotate(180deg)'
},
indeterminateBar1: {
width: 'auto',
willChange: 'left, right',
animation: 'mui-indeterminate1 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite'
},
indeterminateBar2: {
width: 'auto',
willChange: 'left, right',
animation: 'mui-indeterminate2 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite',
animationDelay: '1.15s'
},
determinateBar1: {
willChange: 'transform',
transition: 'transform .' + TRANSITION_DURATION + 's linear'
},
bufferBar1: {
zIndex: 1,
transition: 'transform .' + TRANSITION_DURATION + 's linear'
},
bufferBar2Primary: {
transition: 'transform .' + TRANSITION_DURATION + 's linear',
backgroundColor: theme.palette.primary[100]
},
bufferBar2Accent: {
transition: 'transform .' + TRANSITION_DURATION + 's linear',
backgroundColor: theme.palette.secondary.A100
},
// Legends:
// || represents the viewport
// - represents a light background
// x represents a dark background
'@keyframes mui-indeterminate1': {
// |-----|---x-||-----||-----|
'0%': {
left: '-35%',
right: '100%'
},
// |-----|-----||-----||xxxx-|
'60%': {
left: '100%',
right: '-90%'
},
'100%': {
left: '100%',
right: '-90%'
}
},
'@keyframes mui-indeterminate2': {
// |xxxxx|xxxxx||-----||-----|
'0%': {
left: '-200%',
right: '100%'
},
// |-----|-----||-----||-x----|
'60%': {
left: '107%',
right: '-8%'
},
'100%': {
left: '107%',
right: '-8%'
}
},
'@keyframes buffer': {
'0%': {
opacity: 1,
backgroundPosition: '0px -23px'
},
'50%': {
opacity: 0,
backgroundPosition: '0px -23px'
},
'100%': {
opacity: 1,
backgroundPosition: '-200px -23px'
}
}
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color: require('prop-types').oneOf(['primary', 'accent']),
/**
* The mode of show your progress, indeterminate
* for when there is no value for progress.
*/
mode: require('prop-types').oneOf(['determinate', 'indeterminate', 'buffer', 'query']),
/**
* The value of progress, only works in determinate and buffer mode.
* Value between 0 and 100.
*/
value: require('prop-types').number,
/**
* The value of buffer, only works in buffer mode.
* Value between 0 and 100.
*/
valueBuffer: require('prop-types').number
};
function LinearProgress(props) {
var _classNames, _classNames2, _classNames3, _classNames4;
var classes = props.classes,
className = props.className,
color = props.color,
mode = props.mode,
value = props.value,
valueBuffer = props.valueBuffer,
other = (0, _objectWithoutProperties3.default)(props, ['classes', 'className', 'color', 'mode', 'value', 'valueBuffer']);
var dashedClass = (0, _classnames2.default)(classes.dashed, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.primaryDashed, color === 'primary'), (0, _defineProperty3.default)(_classNames, classes.accentDashed, color === 'accent'), _classNames));
var rootClassName = (0, _classnames2.default)(classes.root, (_classNames2 = {}, (0, _defineProperty3.default)(_classNames2, classes.primaryColor, color === 'primary'), (0, _defineProperty3.default)(_classNames2, classes.accentColor, color === 'accent'), (0, _defineProperty3.default)(_classNames2, classes.rootBuffer, mode === 'buffer'), (0, _defineProperty3.default)(_classNames2, classes.rootQuery, mode === 'query'), _classNames2), className);
var primaryClassName = (0, _classnames2.default)(classes.bar, (_classNames3 = {}, (0, _defineProperty3.default)(_classNames3, classes.primaryColorBar, color === 'primary'), (0, _defineProperty3.default)(_classNames3, classes.accentColorBar, color === 'accent'), (0, _defineProperty3.default)(_classNames3, classes.indeterminateBar1, mode === 'indeterminate' || mode === 'query'), (0, _defineProperty3.default)(_classNames3, classes.determinateBar1, mode === 'determinate'), (0, _defineProperty3.default)(_classNames3, classes.bufferBar1, mode === 'buffer'), _classNames3));
var secondaryClassName = (0, _classnames2.default)(classes.bar, (_classNames4 = {}, (0, _defineProperty3.default)(_classNames4, classes.bufferBar2, mode === 'buffer'), (0, _defineProperty3.default)(_classNames4, classes.primaryColorBar, color === 'primary' && mode !== 'buffer'), (0, _defineProperty3.default)(_classNames4, classes.primaryColor, color === 'primary' && mode === 'buffer'), (0, _defineProperty3.default)(_classNames4, classes.accentColorBar, color === 'accent' && mode !== 'buffer'), (0, _defineProperty3.default)(_classNames4, classes.accentColor, color === 'accent' && mode === 'buffer'), (0, _defineProperty3.default)(_classNames4, classes.indeterminateBar2, mode === 'indeterminate' || mode === 'query'), _classNames4));
var inlineStyles = { primary: {}, secondary: {} };
var rootProps = {};
if (mode === 'determinate') {
if (value !== undefined) {
inlineStyles.primary.transform = 'scaleX(' + value / 100 + ')';
rootProps['aria-valuenow'] = Math.round(value);
} else {
process.env.NODE_ENV !== "production" ? (0, _warning2.default)(false, 'Material-UI: you need to provide a value property ' + 'when LinearProgress is in determinate mode.') : void 0;
}
} else if (mode === 'buffer') {
if (value !== undefined) {
inlineStyles.primary.transform = 'scaleX(' + value / 100 + ')';
inlineStyles.secondary.transform = 'scaleX(' + (valueBuffer || 0) / 100 + ')';
} else {
process.env.NODE_ENV !== "production" ? (0, _warning2.default)(false, 'Material-UI: you need to provide a value property when LinearProgress is in buffer mode.') : void 0;
}
}
return _react2.default.createElement(
'div',
(0, _extends3.default)({ className: rootClassName }, rootProps, other),
mode === 'buffer' ? _react2.default.createElement('div', { className: dashedClass }) : null,
_react2.default.createElement('div', { className: primaryClassName, style: inlineStyles.primary }),
mode === 'determinate' ? null : _react2.default.createElement('div', { className: secondaryClassName, style: inlineStyles.secondary })
);
}
LinearProgress.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'color', require('prop-types').oneOf(['primary', 'accent'])), (0, _defineProperty3.default)(_ref, 'mode', require('prop-types').oneOf(['determinate', 'indeterminate', 'buffer', 'query'])), (0, _defineProperty3.default)(_ref, 'value', require('prop-types').number), (0, _defineProperty3.default)(_ref, 'valueBuffer', require('prop-types').number), _ref) : {};
LinearProgress.defaultProps = {
color: 'primary',
mode: 'indeterminate'
};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiLinearProgress' })(LinearProgress);

View File

@@ -0,0 +1,253 @@
// @flow
import React from 'react';
import classNames from 'classnames';
import warning from 'warning';
import withStyles from '../styles/withStyles';
const TRANSITION_DURATION = 4; // 400ms
export const styles = (theme: Object) => ({
root: {
position: 'relative',
overflow: 'hidden',
height: 5,
},
primaryColor: {
backgroundColor: theme.palette.primary[100],
},
primaryColorBar: {
backgroundColor: theme.palette.primary[500],
},
primaryDashed: {
background: `radial-gradient(${theme.palette.primary[100]} 0%, ${theme.palette
.primary[100]} 16%, transparent 42%)`,
backgroundSize: '10px 10px',
backgroundPosition: '0px -23px',
},
accentColor: {
backgroundColor: theme.palette.secondary.A100,
},
accentColorBar: {
backgroundColor: theme.palette.secondary.A400,
},
accentDashed: {
background: `radial-gradient(${theme.palette.secondary.A100} 0%, ${theme.palette.secondary
.A100} 16%, transparent 42%)`,
backgroundSize: '10px 10px',
backgroundPosition: '0px -23px',
},
bar: {
width: '100%',
position: 'absolute',
left: 0,
bottom: 0,
top: 0,
transition: 'transform 0.2s linear',
transformOrigin: 'left',
},
dashed: {
position: 'absolute',
marginTop: 0,
height: '100%',
width: '100%',
animation: 'buffer 3s infinite linear',
},
bufferBar2: {
transition: `transform .${TRANSITION_DURATION}s linear`,
},
rootBuffer: {
backgroundColor: 'transparent',
},
rootQuery: {
transform: 'rotate(180deg)',
},
indeterminateBar1: {
width: 'auto',
willChange: 'left, right',
animation: 'mui-indeterminate1 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite',
},
indeterminateBar2: {
width: 'auto',
willChange: 'left, right',
animation: 'mui-indeterminate2 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite',
animationDelay: '1.15s',
},
determinateBar1: {
willChange: 'transform',
transition: `transform .${TRANSITION_DURATION}s linear`,
},
bufferBar1: {
zIndex: 1,
transition: `transform .${TRANSITION_DURATION}s linear`,
},
bufferBar2Primary: {
transition: `transform .${TRANSITION_DURATION}s linear`,
backgroundColor: theme.palette.primary[100],
},
bufferBar2Accent: {
transition: `transform .${TRANSITION_DURATION}s linear`,
backgroundColor: theme.palette.secondary.A100,
},
// Legends:
// || represents the viewport
// - represents a light background
// x represents a dark background
'@keyframes mui-indeterminate1': {
// |-----|---x-||-----||-----|
'0%': {
left: '-35%',
right: '100%',
},
// |-----|-----||-----||xxxx-|
'60%': {
left: '100%',
right: '-90%',
},
'100%': {
left: '100%',
right: '-90%',
},
},
'@keyframes mui-indeterminate2': {
// |xxxxx|xxxxx||-----||-----|
'0%': {
left: '-200%',
right: '100%',
},
// |-----|-----||-----||-x----|
'60%': {
left: '107%',
right: '-8%',
},
'100%': {
left: '107%',
right: '-8%',
},
},
'@keyframes buffer': {
'0%': {
opacity: 1,
backgroundPosition: '0px -23px',
},
'50%': {
opacity: 0,
backgroundPosition: '0px -23px',
},
'100%': {
opacity: 1,
backgroundPosition: '-200px -23px',
},
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color?: 'primary' | 'accent',
/**
* The mode of show your progress, indeterminate
* for when there is no value for progress.
*/
mode?: 'determinate' | 'indeterminate' | 'buffer' | 'query',
/**
* The value of progress, only works in determinate and buffer mode.
* Value between 0 and 100.
*/
value?: number,
/**
* The value of buffer, only works in buffer mode.
* Value between 0 and 100.
*/
valueBuffer?: number,
};
function LinearProgress(props: ProvidedProps & Props) {
const { classes, className, color, mode, value, valueBuffer, ...other } = props;
const dashedClass = classNames(classes.dashed, {
[classes.primaryDashed]: color === 'primary',
[classes.accentDashed]: color === 'accent',
});
const rootClassName = classNames(
classes.root,
{
[classes.primaryColor]: color === 'primary',
[classes.accentColor]: color === 'accent',
[classes.rootBuffer]: mode === 'buffer',
[classes.rootQuery]: mode === 'query',
},
className,
);
const primaryClassName = classNames(classes.bar, {
[classes.primaryColorBar]: color === 'primary',
[classes.accentColorBar]: color === 'accent',
[classes.indeterminateBar1]: mode === 'indeterminate' || mode === 'query',
[classes.determinateBar1]: mode === 'determinate',
[classes.bufferBar1]: mode === 'buffer',
});
const secondaryClassName = classNames(classes.bar, {
[classes.bufferBar2]: mode === 'buffer',
[classes.primaryColorBar]: color === 'primary' && mode !== 'buffer',
[classes.primaryColor]: color === 'primary' && mode === 'buffer',
[classes.accentColorBar]: color === 'accent' && mode !== 'buffer',
[classes.accentColor]: color === 'accent' && mode === 'buffer',
[classes.indeterminateBar2]: mode === 'indeterminate' || mode === 'query',
});
const inlineStyles = { primary: {}, secondary: {} };
const rootProps = {};
if (mode === 'determinate') {
if (value !== undefined) {
inlineStyles.primary.transform = `scaleX(${value / 100})`;
rootProps['aria-valuenow'] = Math.round(value);
} else {
warning(
false,
'Material-UI: you need to provide a value property ' +
'when LinearProgress is in determinate mode.',
);
}
} else if (mode === 'buffer') {
if (value !== undefined) {
inlineStyles.primary.transform = `scaleX(${value / 100})`;
inlineStyles.secondary.transform = `scaleX(${(valueBuffer || 0) / 100})`;
} else {
warning(
false,
'Material-UI: you need to provide a value property when LinearProgress is in buffer mode.',
);
}
}
return (
<div className={rootClassName} {...rootProps} {...other}>
{mode === 'buffer' ? <div className={dashedClass} /> : null}
<div className={primaryClassName} style={inlineStyles.primary} />
{mode === 'determinate' ? null : (
<div className={secondaryClassName} style={inlineStyles.secondary} />
)}
</div>
);
}
LinearProgress.defaultProps = {
color: 'primary',
mode: 'indeterminate',
};
export default withStyles(styles, { name: 'MuiLinearProgress' })(LinearProgress);

View File

@@ -0,0 +1,4 @@
export { default as CircularProgress } from './CircularProgress';
export * from './CircularProgress';
export { default as LinearProgress } from './LinearProgress';
export * from './LinearProgress';

View File

@@ -0,0 +1,25 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _CircularProgress = require('./CircularProgress');
Object.defineProperty(exports, 'CircularProgress', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CircularProgress).default;
}
});
var _LinearProgress = require('./LinearProgress');
Object.defineProperty(exports, 'LinearProgress', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_LinearProgress).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View File

@@ -0,0 +1,3 @@
// @flow
export { default as CircularProgress } from './CircularProgress';
export { default as LinearProgress } from './LinearProgress';