1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import Paper from '../Paper';
|
8 | import capitalize from '../utils/capitalize';
|
9 | import LinearProgress from '../LinearProgress';
|
10 | export const styles = theme => ({
|
11 |
|
12 | root: {
|
13 | display: 'flex',
|
14 | flexDirection: 'row',
|
15 | justifyContent: 'space-between',
|
16 | alignItems: 'center',
|
17 | background: theme.palette.background.default,
|
18 | padding: 8
|
19 | },
|
20 |
|
21 |
|
22 | positionBottom: {
|
23 | position: 'fixed',
|
24 | bottom: 0,
|
25 | left: 0,
|
26 | right: 0,
|
27 | zIndex: theme.zIndex.mobileStepper
|
28 | },
|
29 |
|
30 |
|
31 | positionTop: {
|
32 | position: 'fixed',
|
33 | top: 0,
|
34 | left: 0,
|
35 | right: 0,
|
36 | zIndex: theme.zIndex.mobileStepper
|
37 | },
|
38 |
|
39 |
|
40 | positionStatic: {},
|
41 |
|
42 |
|
43 | dots: {
|
44 | display: 'flex',
|
45 | flexDirection: 'row'
|
46 | },
|
47 |
|
48 |
|
49 | dot: {
|
50 | backgroundColor: theme.palette.action.disabled,
|
51 | borderRadius: '50%',
|
52 | width: 8,
|
53 | height: 8,
|
54 | margin: '0 2px'
|
55 | },
|
56 |
|
57 |
|
58 | dotActive: {
|
59 | backgroundColor: theme.palette.primary.main
|
60 | },
|
61 |
|
62 |
|
63 | progress: {
|
64 | width: '50%'
|
65 | }
|
66 | });
|
67 | const MobileStepper = React.forwardRef(function MobileStepper(props, ref) {
|
68 | const {
|
69 | activeStep = 0,
|
70 | backButton,
|
71 | classes,
|
72 | className,
|
73 | LinearProgressProps,
|
74 | nextButton,
|
75 | position = 'bottom',
|
76 | steps,
|
77 | variant = 'dots'
|
78 | } = props,
|
79 | other = _objectWithoutPropertiesLoose(props, ["activeStep", "backButton", "classes", "className", "LinearProgressProps", "nextButton", "position", "steps", "variant"]);
|
80 |
|
81 | return React.createElement(Paper, _extends({
|
82 | square: true,
|
83 | elevation: 0,
|
84 | className: clsx(classes.root, classes[`position${capitalize(position)}`], className),
|
85 | ref: ref
|
86 | }, other), backButton, variant === 'text' && React.createElement(React.Fragment, null, activeStep + 1, " / ", steps), variant === 'dots' && React.createElement("div", {
|
87 | className: classes.dots
|
88 | }, [...new Array(steps)].map((_, index) => React.createElement("div", {
|
89 | key: index,
|
90 | className: clsx(classes.dot, index === activeStep && classes.dotActive)
|
91 | }))), variant === 'progress' && React.createElement(LinearProgress, _extends({
|
92 | className: classes.progress,
|
93 | variant: "determinate",
|
94 | value: Math.ceil(activeStep / (steps - 1) * 100)
|
95 | }, LinearProgressProps)), nextButton);
|
96 | });
|
97 | process.env.NODE_ENV !== "production" ? MobileStepper.propTypes = {
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 | activeStep: PropTypes.number,
|
108 |
|
109 | |
110 |
|
111 |
|
112 | backButton: PropTypes.node,
|
113 |
|
114 | |
115 |
|
116 |
|
117 |
|
118 | classes: PropTypes.object,
|
119 |
|
120 | |
121 |
|
122 |
|
123 | className: PropTypes.string,
|
124 |
|
125 | |
126 |
|
127 |
|
128 | LinearProgressProps: PropTypes.object,
|
129 |
|
130 | |
131 |
|
132 |
|
133 | nextButton: PropTypes.node,
|
134 |
|
135 | |
136 |
|
137 |
|
138 | position: PropTypes.oneOf(['bottom', 'static', 'top']),
|
139 |
|
140 | |
141 |
|
142 |
|
143 | steps: PropTypes.number.isRequired,
|
144 |
|
145 | |
146 |
|
147 |
|
148 | variant: PropTypes.oneOf(['dots', 'progress', 'text'])
|
149 | } : void 0;
|
150 | export default withStyles(styles, {
|
151 | name: 'MuiMobileStepper'
|
152 | })(MobileStepper); |
\ | No newline at end of file |