argous 1.2.161 → 1.2.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,6 +40,14 @@ export interface StepperTypeMap<P ={}, D extends React.ElementType = 'div'> {
|
|
|
40
40
|
* Array de booleans que mudam o passo para erro
|
|
41
41
|
*/
|
|
42
42
|
errors?: boolean[];
|
|
43
|
+
/**
|
|
44
|
+
* Desabilita ações/botões
|
|
45
|
+
*/
|
|
46
|
+
disableActions?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Orientação do Stepper
|
|
49
|
+
*/
|
|
50
|
+
orientation?: string;
|
|
43
51
|
};
|
|
44
52
|
defaultComponent: D;
|
|
45
53
|
classKey: StepperClassKey;
|
|
@@ -50,8 +50,18 @@ var react_1 = __importStar(require("react"));
|
|
|
50
50
|
var lib_1 = require("react-icons/lib");
|
|
51
51
|
var md_1 = require("react-icons/md");
|
|
52
52
|
var ColorlibConnector = core_1.withStyles(function (theme) { return ({
|
|
53
|
-
alternativeLabel: {
|
|
54
|
-
|
|
53
|
+
alternativeLabel: function (_a) {
|
|
54
|
+
var orientation = _a.orientation;
|
|
55
|
+
return orientation === 'vertical' ? {
|
|
56
|
+
top: -30,
|
|
57
|
+
transform: 'rotate(90deg)',
|
|
58
|
+
left: 'calc(-50% + 50px)',
|
|
59
|
+
'&>span': {
|
|
60
|
+
minHeight: 3
|
|
61
|
+
}
|
|
62
|
+
} : {
|
|
63
|
+
top: 22,
|
|
64
|
+
};
|
|
55
65
|
},
|
|
56
66
|
active: {
|
|
57
67
|
'& $line': {
|
|
@@ -72,7 +82,7 @@ var ColorlibConnector = core_1.withStyles(function (theme) { return ({
|
|
|
72
82
|
backgroundPosition: 'right bottom',
|
|
73
83
|
transition: 'background-position 500ms ease',
|
|
74
84
|
borderRadius: 1,
|
|
75
|
-
}
|
|
85
|
+
}
|
|
76
86
|
}); })(core_1.StepConnector);
|
|
77
87
|
var ColorlibStepIcon = core_1.withStyles(function (theme) { return ({
|
|
78
88
|
root: {
|
|
@@ -152,7 +162,31 @@ var stepperStyles = function (theme) {
|
|
|
152
162
|
_a[theme.breakpoints.down('sm')] = {
|
|
153
163
|
padding: 0
|
|
154
164
|
},
|
|
165
|
+
_a['&>div'] = {
|
|
166
|
+
display: 'flex',
|
|
167
|
+
padding: function (_a) {
|
|
168
|
+
var orientation = _a.orientation;
|
|
169
|
+
return orientation === 'vertical' ? '0 0 30px' : '';
|
|
170
|
+
},
|
|
171
|
+
'&>button': {
|
|
172
|
+
'&>span:nth-child(1)': {
|
|
173
|
+
flexDirection: function (_a) {
|
|
174
|
+
var orientation = _a.orientation;
|
|
175
|
+
return orientation === 'vertical' ? 'row' : 'column';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
155
180
|
_a),
|
|
181
|
+
subDescription: {
|
|
182
|
+
minWidth: 140,
|
|
183
|
+
display: 'flex',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
justifyContent: 'end',
|
|
186
|
+
position: 'absolute',
|
|
187
|
+
top: 'calc(50% - 24px)',
|
|
188
|
+
left: 'calc(-50% - 83px)',
|
|
189
|
+
},
|
|
156
190
|
icon: {
|
|
157
191
|
fontSize: theme.typography.fontSize * 2,
|
|
158
192
|
'& path': {
|
|
@@ -161,34 +195,49 @@ var stepperStyles = function (theme) {
|
|
|
161
195
|
},
|
|
162
196
|
mobileDivider: {
|
|
163
197
|
marginBottom: theme.spacing(2)
|
|
198
|
+
},
|
|
199
|
+
stepLabel: {
|
|
200
|
+
'&>span:nth-child(2)': {
|
|
201
|
+
margin: function (_a) {
|
|
202
|
+
var orientation = _a.orientation;
|
|
203
|
+
return orientation === 'vertical' ? '0 0 0 8px' : '';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
164
206
|
}
|
|
165
207
|
});
|
|
166
208
|
};
|
|
167
209
|
var Stepper = function (_a) {
|
|
168
|
-
var children = _a.children, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.steps, steps = _c === void 0 ? [] : _c, _d = _a.onClick, onClick = _d === void 0 ? function (index) { return function (event) { return void (index, event); }; } : _d, _e = _a.onNext, onNext = _e === void 0 ? function (event) { return void (event); } : _e, _f = _a.onPrevious, onPrevious = _f === void 0 ? function (event) { return void (event); } : _f, _g = _a.onFinish, onFinish = _g === void 0 ? function (event) { return void (event); } : _g, maxStepProps = _a.maxStep, _h = _a.activeStep, activeStep = _h === void 0 ? 0 : _h, _j = _a.errors, errors = _j === void 0 ? [] : _j, _k = _a.component, Component = _k === void 0 ? 'div' : _k, _l = _a.backLabel, backLabel = _l === void 0 ? 'Voltar' : _l, _m = _a.nextLabel, nextLabel = _m === void 0 ? 'Avançar' : _m, _o = _a.finishLabel, finishLabel = _o === void 0 ? 'Finalizar' : _o, _p = _a.disableFinish, disableFinish = _p === void 0 ? false : _p, _q = _a.disableNext, disableNext = _q === void 0 ? false : _q, _r = _a.disablePrevious, disablePrevious = _r === void 0 ? false : _r, _s = _a.showProgress, showProgress = _s === void 0 ? false : _s, props = __rest(_a, ["children", "classes", "steps", "onClick", "onNext", "onPrevious", "onFinish", "maxStep", "activeStep", "errors", "component", "backLabel", "nextLabel", "finishLabel", "disableFinish", "disableNext", "disablePrevious", "showProgress"]);
|
|
210
|
+
var children = _a.children, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.steps, steps = _c === void 0 ? [] : _c, _d = _a.onClick, onClick = _d === void 0 ? function (index) { return function (event) { return void (index, event); }; } : _d, _e = _a.onNext, onNext = _e === void 0 ? function (event) { return void (event); } : _e, _f = _a.onPrevious, onPrevious = _f === void 0 ? function (event) { return void (event); } : _f, _g = _a.onFinish, onFinish = _g === void 0 ? function (event) { return void (event); } : _g, maxStepProps = _a.maxStep, _h = _a.activeStep, activeStep = _h === void 0 ? 0 : _h, _j = _a.errors, errors = _j === void 0 ? [] : _j, _k = _a.component, Component = _k === void 0 ? 'div' : _k, _l = _a.backLabel, backLabel = _l === void 0 ? 'Voltar' : _l, _m = _a.nextLabel, nextLabel = _m === void 0 ? 'Avançar' : _m, _o = _a.finishLabel, finishLabel = _o === void 0 ? 'Finalizar' : _o, _p = _a.disableFinish, disableFinish = _p === void 0 ? false : _p, _q = _a.disableNext, disableNext = _q === void 0 ? false : _q, _r = _a.disablePrevious, disablePrevious = _r === void 0 ? false : _r, _s = _a.showProgress, showProgress = _s === void 0 ? false : _s, _t = _a.disableActions, disableActions = _t === void 0 ? false : _t, _u = _a.orientation, orientation = _u === void 0 ? 'horizontal' : _u, props = __rest(_a, ["children", "classes", "steps", "onClick", "onNext", "onPrevious", "onFinish", "maxStep", "activeStep", "errors", "component", "backLabel", "nextLabel", "finishLabel", "disableFinish", "disableNext", "disablePrevious", "showProgress", "disableActions", "orientation"]);
|
|
169
211
|
var maxSteps = steps.length;
|
|
170
212
|
var maxStep = maxStepProps || steps.length - 1;
|
|
171
|
-
var
|
|
213
|
+
var _v = react_1.useState(-1), initialStep = _v[0], setInitialStep = _v[1];
|
|
172
214
|
react_1.useEffect(function () { return (activeStep > initialStep && showProgress) && setInitialStep(activeStep); }, [activeStep, initialStep, showProgress]);
|
|
173
215
|
var ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
|
|
174
216
|
var theme = core_1.useTheme();
|
|
175
217
|
var mobile = core_1.useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
|
|
176
218
|
return react_1.default.createElement(Component, __assign({}, props),
|
|
177
|
-
mobile ? (react_1.default.createElement(core_1.Paper, { square: true, elevation: 0 },
|
|
219
|
+
mobile && orientation !== 'vertical' ? (react_1.default.createElement(core_1.Paper, { square: true, elevation: 0 },
|
|
178
220
|
react_1.default.createElement(core_1.ListItem, { dense: true, className: classes.header },
|
|
179
221
|
react_1.default.createElement(core_1.ListItemIcon, { className: classes.icon }, steps[activeStep][0]),
|
|
180
222
|
react_1.default.createElement(core_1.ListItemText, { primary: steps[activeStep][1], secondary: steps[activeStep][2] })),
|
|
181
|
-
react_1.default.createElement(core_1.Divider, { className: classes.mobileDivider }))) : (react_1.default.createElement(core_1.Stepper, { className: classes.stepper, alternativeLabel: true, activeStep: activeStep, connector: react_1.default.createElement(ColorlibConnector, null) }, steps.map(function (_a, i) {
|
|
182
|
-
var _b;
|
|
183
|
-
var icon = _a[0], label = _a[1], description = _a[2];
|
|
223
|
+
react_1.default.createElement(core_1.Divider, { className: classes.mobileDivider }))) : (react_1.default.createElement(core_1.Stepper, { className: classes.stepper, alternativeLabel: true, activeStep: activeStep, orientation: orientation, connector: react_1.default.createElement(ColorlibConnector, null) }, steps.map(function (_a, i) {
|
|
224
|
+
var _b, _c, _d;
|
|
225
|
+
var icon = _a[0], label = _a[1], description = _a[2], subDescription = _a[3];
|
|
184
226
|
return (react_1.default.createElement(core_1.Step, { key: label },
|
|
185
|
-
|
|
186
|
-
react_1.default.createElement(
|
|
227
|
+
orientation === 'vertical' && subDescription &&
|
|
228
|
+
react_1.default.createElement("div", { className: classes.subDescription },
|
|
229
|
+
react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_b = {}, _b[classes.selectedCaption] = activeStep >= i, _b)) }, subDescription)),
|
|
230
|
+
react_1.default.createElement(core_1.StepButton, { onClick: onClick(i), disabled: i > maxStep, optional: react_1.default.createElement(react_1.default.Fragment, null,
|
|
231
|
+
react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_c = {}, _c[classes.selectedCaption] = activeStep >= i, _c)) }, description),
|
|
232
|
+
orientation !== 'vertical' && subDescription &&
|
|
233
|
+
react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_d = {}, _d[classes.selectedCaption] = activeStep >= i, _d)) }, subDescription)) },
|
|
234
|
+
react_1.default.createElement(core_1.StepLabel, { className: classes.stepLabel, disabled: i > maxStep, error: errors[i], StepIconComponent: ColorlibStepIcon, StepIconProps: { icon: icon, error: errors[i], initial: initialStep >= i, ambienteTeste: ambienteTeste } }, label))));
|
|
187
235
|
}))),
|
|
188
|
-
|
|
189
|
-
|
|
236
|
+
children &&
|
|
237
|
+
react_1.default.createElement(core_1.Box, { padding: mobile ? 0 : 4, pt: 1, pb: 0 }, children),
|
|
238
|
+
mobile && orientation !== 'vertical' ? (react_1.default.createElement(core_1.MobileStepper, { steps: maxSteps, position: 'bottom', variant: 'dots', activeStep: activeStep, backButton: react_1.default.createElement(core_1.Button, { startIcon: react_1.default.createElement(md_1.MdChevronLeft, null), onClick: onPrevious, disabled: activeStep === 0 }, backLabel), nextButton: react_1.default.createElement(core_1.Button, { variant: 'contained', color: 'primary', endIcon: activeStep === maxSteps - 1 ? react_1.default.createElement(md_1.MdCheck, null) : react_1.default.createElement(md_1.MdChevronRight, null), onClick: activeStep === steps.length - 1 ? onFinish : onNext }, activeStep === steps.length - 1 ? finishLabel : nextLabel) })) : !disableActions ? (react_1.default.createElement(core_1.DialogActions, null,
|
|
190
239
|
react_1.default.createElement(core_1.Box, { padding: mobile ? 0 : 4, paddingTop: 1, paddingBottom: 1 },
|
|
191
240
|
react_1.default.createElement(core_1.Button, { disabled: activeStep === 0 || disablePrevious, onClick: onPrevious }, backLabel),
|
|
192
|
-
react_1.default.createElement(core_1.Button, { variant: 'contained', color: 'primary', onClick: activeStep === steps.length - 1 ? onFinish : onNext, disabled: activeStep === steps.length - 1 ? disableFinish : disableNext }, activeStep === steps.length - 1 ? finishLabel : nextLabel)))));
|
|
241
|
+
react_1.default.createElement(core_1.Button, { variant: 'contained', color: 'primary', onClick: activeStep === steps.length - 1 ? onFinish : onNext, disabled: activeStep === steps.length - 1 ? disableFinish : disableNext }, activeStep === steps.length - 1 ? finishLabel : nextLabel)))) : null);
|
|
193
242
|
};
|
|
194
243
|
exports.default = core_1.withStyles(stepperStyles, { name: 'ArgousStepper' })(Stepper);
|
|
@@ -40,6 +40,14 @@ export interface StepperTypeMap<P ={}, D extends React.ElementType = 'div'> {
|
|
|
40
40
|
* Array de booleans que mudam o passo para erro
|
|
41
41
|
*/
|
|
42
42
|
errors?: boolean[];
|
|
43
|
+
/**
|
|
44
|
+
* Desabilita ações/botões
|
|
45
|
+
*/
|
|
46
|
+
disableActions?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Orientação do Stepper
|
|
49
|
+
*/
|
|
50
|
+
orientation?: string;
|
|
43
51
|
};
|
|
44
52
|
defaultComponent: D;
|
|
45
53
|
classKey: StepperClassKey;
|
|
@@ -5,7 +5,14 @@ import { IconContext } from 'react-icons/lib';
|
|
|
5
5
|
import { MdCheck, MdChevronLeft, MdChevronRight } from 'react-icons/md';
|
|
6
6
|
|
|
7
7
|
const ColorlibConnector = withStyles(theme => ({
|
|
8
|
-
alternativeLabel: {
|
|
8
|
+
alternativeLabel: ({ orientation }) => orientation === 'vertical' ? {
|
|
9
|
+
top: -30,
|
|
10
|
+
transform: 'rotate(90deg)',
|
|
11
|
+
left: 'calc(-50% + 50px)',
|
|
12
|
+
'&>span': {
|
|
13
|
+
minHeight: 3
|
|
14
|
+
}
|
|
15
|
+
} : {
|
|
9
16
|
top: 22,
|
|
10
17
|
},
|
|
11
18
|
active: {
|
|
@@ -27,7 +34,7 @@ const ColorlibConnector = withStyles(theme => ({
|
|
|
27
34
|
backgroundPosition: 'right bottom',
|
|
28
35
|
transition: 'background-position 500ms ease',
|
|
29
36
|
borderRadius: 1,
|
|
30
|
-
}
|
|
37
|
+
}
|
|
31
38
|
}))(StepConnector);
|
|
32
39
|
|
|
33
40
|
const ColorlibStepIcon = withStyles(theme => ({
|
|
@@ -100,8 +107,26 @@ const stepperStyles = theme => ({
|
|
|
100
107
|
stepper: {
|
|
101
108
|
[theme.breakpoints.down('sm')]: {
|
|
102
109
|
padding: 0
|
|
110
|
+
},
|
|
111
|
+
'&>div': {
|
|
112
|
+
display: 'flex',
|
|
113
|
+
padding: ({ orientation }) => orientation === 'vertical' ? '0 0 30px' : '',
|
|
114
|
+
'&>button': {
|
|
115
|
+
'&>span:nth-child(1)': {
|
|
116
|
+
flexDirection: ({ orientation }) => orientation === 'vertical' ? 'row' : 'column'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
103
119
|
}
|
|
104
120
|
},
|
|
121
|
+
subDescription: {
|
|
122
|
+
minWidth: 140,
|
|
123
|
+
display: 'flex',
|
|
124
|
+
alignItems: 'center',
|
|
125
|
+
justifyContent: 'end',
|
|
126
|
+
position: 'absolute',
|
|
127
|
+
top: 'calc(50% - 24px)',
|
|
128
|
+
left: 'calc(-50% - 83px)',
|
|
129
|
+
},
|
|
105
130
|
icon: {
|
|
106
131
|
fontSize: theme.typography.fontSize * 2,
|
|
107
132
|
'& path': {
|
|
@@ -110,6 +135,11 @@ const stepperStyles = theme => ({
|
|
|
110
135
|
},
|
|
111
136
|
mobileDivider: {
|
|
112
137
|
marginBottom: theme.spacing(2)
|
|
138
|
+
},
|
|
139
|
+
stepLabel: {
|
|
140
|
+
'&>span:nth-child(2)': {
|
|
141
|
+
margin: ({ orientation }) => orientation === 'vertical' ? '0 0 0 8px' : ''
|
|
142
|
+
}
|
|
113
143
|
}
|
|
114
144
|
});
|
|
115
145
|
|
|
@@ -132,6 +162,8 @@ const Stepper = ({
|
|
|
132
162
|
disableNext = false,
|
|
133
163
|
disablePrevious = false,
|
|
134
164
|
showProgress = false,
|
|
165
|
+
disableActions = false,
|
|
166
|
+
orientation = 'horizontal',
|
|
135
167
|
...props
|
|
136
168
|
}) => {
|
|
137
169
|
const maxSteps = steps.length;
|
|
@@ -146,7 +178,7 @@ const Stepper = ({
|
|
|
146
178
|
const mobile = useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
|
|
147
179
|
|
|
148
180
|
return <Component {...props}>
|
|
149
|
-
{mobile ? (
|
|
181
|
+
{mobile && orientation !== 'vertical' ? (
|
|
150
182
|
<Paper square elevation={0}>
|
|
151
183
|
<ListItem dense className={classes.header}>
|
|
152
184
|
<ListItemIcon className={classes.icon}>{steps[activeStep][0]}</ListItemIcon>
|
|
@@ -159,20 +191,46 @@ const Stepper = ({
|
|
|
159
191
|
className={classes.stepper}
|
|
160
192
|
alternativeLabel
|
|
161
193
|
activeStep={activeStep}
|
|
162
|
-
|
|
163
|
-
{
|
|
194
|
+
orientation={orientation}
|
|
195
|
+
connector={<ColorlibConnector />}
|
|
196
|
+
>
|
|
197
|
+
{steps.map(([icon, label, description, subDescription], i) => (
|
|
164
198
|
<Step key={label}>
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
199
|
+
{orientation === 'vertical' && subDescription &&
|
|
200
|
+
<div className={classes.subDescription}>
|
|
201
|
+
<Typography
|
|
202
|
+
variant='caption'
|
|
203
|
+
className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
|
|
204
|
+
{subDescription}
|
|
205
|
+
</Typography>
|
|
206
|
+
</div>
|
|
207
|
+
}
|
|
208
|
+
<StepButton
|
|
209
|
+
onClick={onClick(i)}
|
|
210
|
+
disabled={i > maxStep}
|
|
211
|
+
optional={
|
|
212
|
+
<>
|
|
213
|
+
<Typography
|
|
214
|
+
variant='caption'
|
|
215
|
+
className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
|
|
216
|
+
{description}
|
|
217
|
+
</Typography>
|
|
218
|
+
{orientation !== 'vertical' && subDescription &&
|
|
219
|
+
<Typography
|
|
220
|
+
variant='caption'
|
|
221
|
+
className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
|
|
222
|
+
{subDescription}
|
|
223
|
+
</Typography>
|
|
224
|
+
}
|
|
225
|
+
</>
|
|
226
|
+
}
|
|
227
|
+
>
|
|
171
228
|
<StepLabel
|
|
229
|
+
className={classes.stepLabel}
|
|
172
230
|
disabled={i > maxStep}
|
|
173
231
|
error={errors[i]}
|
|
174
232
|
StepIconComponent={ColorlibStepIcon}
|
|
175
|
-
StepIconProps={{ icon, error: errors[i], initial: initialStep >= i, ambienteTeste }}
|
|
233
|
+
StepIconProps={{ icon, error: errors[i], initial: initialStep >= i, ambienteTeste }}
|
|
176
234
|
>
|
|
177
235
|
{label}
|
|
178
236
|
</StepLabel>
|
|
@@ -182,11 +240,13 @@ const Stepper = ({
|
|
|
182
240
|
</MuiStepper>
|
|
183
241
|
)}
|
|
184
242
|
|
|
185
|
-
|
|
186
|
-
{
|
|
187
|
-
|
|
243
|
+
{children &&
|
|
244
|
+
<Box padding={mobile ? 0 : 4} pt={1} pb={0}>
|
|
245
|
+
{children}
|
|
246
|
+
</Box>
|
|
247
|
+
}
|
|
188
248
|
|
|
189
|
-
{mobile ? (
|
|
249
|
+
{mobile && orientation !== 'vertical' ? (
|
|
190
250
|
<MobileStepper
|
|
191
251
|
steps={maxSteps}
|
|
192
252
|
position='bottom'
|
|
@@ -210,7 +270,7 @@ const Stepper = ({
|
|
|
210
270
|
</Button>
|
|
211
271
|
}
|
|
212
272
|
/>
|
|
213
|
-
) : (
|
|
273
|
+
) : !disableActions ? (
|
|
214
274
|
<DialogActions>
|
|
215
275
|
<Box padding={mobile ? 0 : 4} paddingTop={1} paddingBottom={1}>
|
|
216
276
|
<Button
|
|
@@ -228,7 +288,7 @@ const Stepper = ({
|
|
|
228
288
|
</Button>
|
|
229
289
|
</Box>
|
|
230
290
|
</DialogActions>
|
|
231
|
-
) }
|
|
291
|
+
) : null }
|
|
232
292
|
</Component>;
|
|
233
293
|
};
|
|
234
294
|
|