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