Completely updated React, fixed #11, (hopefully)
This commit is contained in:
137
goTorrentWebUI/node_modules/material-ui/Stepper/Stepper.js.flow
generated
vendored
Normal file
137
goTorrentWebUI/node_modules/material-ui/Stepper/Stepper.js.flow
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
// @inheritedComponent Paper
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import withStyles from '../styles/withStyles';
|
||||
import Paper from '../Paper';
|
||||
import StepConnector from './StepConnector';
|
||||
|
||||
export const styles = theme => ({
|
||||
root: {
|
||||
display: 'flex',
|
||||
padding: theme.spacing.unit * 3,
|
||||
},
|
||||
horizontal: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
vertical: {
|
||||
flexDirection: 'column',
|
||||
},
|
||||
alternativeLabel: {
|
||||
alignItems: 'flex-start',
|
||||
},
|
||||
});
|
||||
|
||||
function Stepper(props) {
|
||||
const {
|
||||
activeStep,
|
||||
alternativeLabel,
|
||||
children,
|
||||
classes,
|
||||
className: classNameProp,
|
||||
connector: connectorProp,
|
||||
nonLinear,
|
||||
orientation,
|
||||
...other
|
||||
} = props;
|
||||
|
||||
const className = classNames(
|
||||
classes.root,
|
||||
classes[orientation],
|
||||
{
|
||||
[classes.alternativeLabel]: alternativeLabel,
|
||||
},
|
||||
classNameProp,
|
||||
);
|
||||
|
||||
const connector = React.isValidElement(connectorProp)
|
||||
? React.cloneElement(connectorProp, { orientation })
|
||||
: null;
|
||||
const childrenArray = React.Children.toArray(children);
|
||||
const steps = childrenArray.map((step, index) => {
|
||||
const controlProps = {
|
||||
index,
|
||||
orientation,
|
||||
active: false,
|
||||
completed: false,
|
||||
disabled: false,
|
||||
last: index + 1 === childrenArray.length,
|
||||
alternativeLabel,
|
||||
connector: connectorProp,
|
||||
};
|
||||
|
||||
if (activeStep === index) {
|
||||
controlProps.active = true;
|
||||
} else if (!nonLinear && activeStep > index) {
|
||||
controlProps.completed = true;
|
||||
} else if (!nonLinear && activeStep < index) {
|
||||
controlProps.disabled = true;
|
||||
}
|
||||
|
||||
return [
|
||||
!alternativeLabel &&
|
||||
connector &&
|
||||
index > 0 &&
|
||||
React.cloneElement(connector, {
|
||||
key: index, // eslint-disable-line react/no-array-index-key
|
||||
}),
|
||||
React.cloneElement(step, { ...controlProps, ...step.props }),
|
||||
];
|
||||
});
|
||||
|
||||
return (
|
||||
<Paper square elevation={0} className={className} {...other}>
|
||||
{steps}
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
|
||||
Stepper.propTypes = {
|
||||
/**
|
||||
* Set the active step (zero based index).
|
||||
*/
|
||||
activeStep: PropTypes.number,
|
||||
/**
|
||||
* If set to 'true' and orientation is horizontal,
|
||||
* then the step label will be positioned under the icon.
|
||||
*/
|
||||
alternativeLabel: PropTypes.bool,
|
||||
/**
|
||||
* Two or more `<Step />` components.
|
||||
*/
|
||||
children: PropTypes.node.isRequired,
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* A component to be placed between each step.
|
||||
*/
|
||||
connector: PropTypes.element,
|
||||
/**
|
||||
* If set the `Stepper` will not assist in controlling steps for linear flow.
|
||||
*/
|
||||
nonLinear: PropTypes.bool,
|
||||
/**
|
||||
* The stepper orientation (layout flow direction).
|
||||
*/
|
||||
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
||||
};
|
||||
|
||||
Stepper.defaultProps = {
|
||||
activeStep: 0,
|
||||
alternativeLabel: false,
|
||||
connector: <StepConnector />,
|
||||
nonLinear: false,
|
||||
orientation: 'horizontal',
|
||||
};
|
||||
|
||||
Stepper.muiName = 'Stepper';
|
||||
|
||||
export default withStyles(styles, { name: 'MuiStepper' })(Stepper);
|
Reference in New Issue
Block a user