argous 1.2.161 → 1.2.164

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,20 @@ 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
+ * default: horizontal
50
+ * opções: horizontal ou vertical
51
+ */
52
+ orientation?: string;
53
+ /**
54
+ * Mostra o progresso percorrido
55
+ */
56
+ showProgress?: boolean;
43
57
  };
44
58
  defaultComponent: D;
45
59
  classKey: StepperClassKey;
@@ -50,8 +50,19 @@ 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
- top: 22,
53
+ alternativeLabel: function (_a) {
54
+ var orientation = _a.orientation;
55
+ return orientation === 'vertical' ? {
56
+ top: -28,
57
+ transform: 'rotate(90deg)',
58
+ left: 'calc(-50% + 40px)',
59
+ right: 'calc(50% + 10px)',
60
+ '&>span': {
61
+ minHeight: 3
62
+ }
63
+ } : {
64
+ top: 22,
65
+ };
55
66
  },
56
67
  active: {
57
68
  '& $line': {
@@ -72,7 +83,7 @@ var ColorlibConnector = core_1.withStyles(function (theme) { return ({
72
83
  backgroundPosition: 'right bottom',
73
84
  transition: 'background-position 500ms ease',
74
85
  borderRadius: 1,
75
- },
86
+ }
76
87
  }); })(core_1.StepConnector);
77
88
  var ColorlibStepIcon = core_1.withStyles(function (theme) { return ({
78
89
  root: {
@@ -148,11 +159,40 @@ var stepperStyles = function (theme) {
148
159
  selectedCaption: {
149
160
  color: theme.palette.text.secondary
150
161
  },
151
- stepper: (_a = {},
162
+ stepper: (_a = {
163
+ padding: function (_a) {
164
+ var orientation = _a.orientation;
165
+ return orientation === 'vertical' ? '0 0 0 136px' : '';
166
+ }
167
+ },
152
168
  _a[theme.breakpoints.down('sm')] = {
153
169
  padding: 0
154
170
  },
171
+ _a['&>div'] = {
172
+ display: 'flex',
173
+ padding: function (_a) {
174
+ var orientation = _a.orientation;
175
+ return orientation === 'vertical' ? '0 0 30px' : '';
176
+ },
177
+ '&>button': {
178
+ '&>span:nth-child(1)': {
179
+ flexDirection: function (_a) {
180
+ var orientation = _a.orientation;
181
+ return orientation === 'vertical' ? 'row' : 'column';
182
+ }
183
+ }
184
+ }
185
+ },
155
186
  _a),
187
+ subDescription: {
188
+ minWidth: 140,
189
+ display: 'flex',
190
+ alignItems: 'center',
191
+ justifyContent: 'end',
192
+ position: 'absolute',
193
+ top: 17,
194
+ left: -148,
195
+ },
156
196
  icon: {
157
197
  fontSize: theme.typography.fontSize * 2,
158
198
  '& path': {
@@ -161,34 +201,55 @@ var stepperStyles = function (theme) {
161
201
  },
162
202
  mobileDivider: {
163
203
  marginBottom: theme.spacing(2)
204
+ },
205
+ stepLabel: {
206
+ '&>span:nth-child(2)': {
207
+ margin: function (_a) {
208
+ var orientation = _a.orientation;
209
+ return orientation === 'vertical' ? '0 0 0 8px' : '';
210
+ },
211
+ '&>span:nth-child(1)': {
212
+ margin: function (_a) {
213
+ var orientation = _a.orientation;
214
+ return orientation === 'vertical' ? 0 : '';
215
+ }
216
+ }
217
+ },
164
218
  }
165
219
  });
166
220
  };
167
221
  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"]);
222
+ 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"]);
223
+ var theme = core_1.useTheme();
169
224
  var maxSteps = steps.length;
170
225
  var maxStep = maxStepProps || steps.length - 1;
171
- var _t = react_1.useState(-1), initialStep = _t[0], setInitialStep = _t[1];
172
- react_1.useEffect(function () { return (activeStep > initialStep && showProgress) && setInitialStep(activeStep); }, [activeStep, initialStep, showProgress]);
173
- var ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
174
- var theme = core_1.useTheme();
175
226
  var mobile = core_1.useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
227
+ var ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
228
+ var _v = react_1.useState(-1), initialStep = _v[0], setInitialStep = _v[1];
229
+ react_1.useEffect(function () { return (activeStep > initialStep && showProgress) && setInitialStep(activeStep); }, [activeStep, initialStep, showProgress]);
176
230
  return react_1.default.createElement(Component, __assign({}, props),
177
- mobile ? (react_1.default.createElement(core_1.Paper, { square: true, elevation: 0 },
231
+ mobile && orientation !== 'vertical' ? (react_1.default.createElement(core_1.Paper, { square: true, elevation: 0 },
178
232
  react_1.default.createElement(core_1.ListItem, { dense: true, className: classes.header },
179
233
  react_1.default.createElement(core_1.ListItemIcon, { className: classes.icon }, steps[activeStep][0]),
180
234
  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];
235
+ 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) {
236
+ var _b, _c, _d;
237
+ var icon = _a[0], label = _a[1], description = _a[2], subDescription = _a[3];
184
238
  return (react_1.default.createElement(core_1.Step, { key: label },
185
- react_1.default.createElement(core_1.StepButton, { disabled: i > maxStep, onClick: onClick(i), optional: react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_b = {}, _b[classes.selectedCaption] = activeStep >= i, _b)) }, description) },
186
- react_1.default.createElement(core_1.StepLabel, { disabled: i > maxStep, error: errors[i], StepIconComponent: ColorlibStepIcon, StepIconProps: { icon: icon, error: errors[i], initial: initialStep >= i, ambienteTeste: ambienteTeste } }, label))));
239
+ orientation === 'vertical' && subDescription &&
240
+ react_1.default.createElement("div", { className: classes.subDescription },
241
+ react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_b = {}, _b[classes.selectedCaption] = activeStep >= i, _b)) }, subDescription)),
242
+ react_1.default.createElement(core_1.StepButton, { onClick: onClick(i), disabled: i > maxStep, optional: react_1.default.createElement(react_1.default.Fragment, null,
243
+ react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_c = {}, _c[classes.selectedCaption] = activeStep >= i, _c)) }, description),
244
+ orientation !== 'vertical' && subDescription &&
245
+ react_1.default.createElement(core_1.Typography, { variant: 'caption', className: clsx_1.default(classes.caption, (_d = {}, _d[classes.selectedCaption] = activeStep >= i, _d)) }, subDescription)) },
246
+ 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
247
  }))),
188
- react_1.default.createElement(core_1.Box, { padding: mobile ? 0 : 4, pt: 1, pb: 0 }, children),
189
- mobile ? (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) })) : (react_1.default.createElement(core_1.DialogActions, null,
248
+ children &&
249
+ react_1.default.createElement(core_1.Box, { padding: mobile ? 0 : 4, pt: 1, pb: 0 }, children),
250
+ 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
251
  react_1.default.createElement(core_1.Box, { padding: mobile ? 0 : 4, paddingTop: 1, paddingBottom: 1 },
191
252
  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)))));
253
+ 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
254
  };
194
255
  exports.default = core_1.withStyles(stepperStyles, { name: 'ArgousStepper' })(Stepper);
@@ -40,6 +40,20 @@ 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
+ * default: horizontal
50
+ * opções: horizontal ou vertical
51
+ */
52
+ orientation?: string;
53
+ /**
54
+ * Mostra o progresso percorrido
55
+ */
56
+ showProgress?: boolean;
43
57
  };
44
58
  defaultComponent: D;
45
59
  classKey: StepperClassKey;
@@ -5,7 +5,15 @@ 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: -28,
10
+ transform: 'rotate(90deg)',
11
+ left: 'calc(-50% + 40px)',
12
+ right: 'calc(50% + 10px)',
13
+ '&>span': {
14
+ minHeight: 3
15
+ }
16
+ } : {
9
17
  top: 22,
10
18
  },
11
19
  active: {
@@ -27,7 +35,7 @@ const ColorlibConnector = withStyles(theme => ({
27
35
  backgroundPosition: 'right bottom',
28
36
  transition: 'background-position 500ms ease',
29
37
  borderRadius: 1,
30
- },
38
+ }
31
39
  }))(StepConnector);
32
40
 
33
41
  const ColorlibStepIcon = withStyles(theme => ({
@@ -98,10 +106,29 @@ const stepperStyles = theme => ({
98
106
  color: theme.palette.text.secondary
99
107
  },
100
108
  stepper: {
109
+ padding: ({ orientation }) => orientation === 'vertical' ? '0 0 0 136px' : '',
101
110
  [theme.breakpoints.down('sm')]: {
102
111
  padding: 0
112
+ },
113
+ '&>div': {
114
+ display: 'flex',
115
+ padding: ({ orientation }) => orientation === 'vertical' ? '0 0 30px' : '',
116
+ '&>button': {
117
+ '&>span:nth-child(1)': {
118
+ flexDirection: ({ orientation }) => orientation === 'vertical' ? 'row' : 'column'
119
+ }
120
+ }
103
121
  }
104
122
  },
123
+ subDescription: {
124
+ minWidth: 140,
125
+ display: 'flex',
126
+ alignItems: 'center',
127
+ justifyContent: 'end',
128
+ position: 'absolute',
129
+ top: 17,
130
+ left: -148,
131
+ },
105
132
  icon: {
106
133
  fontSize: theme.typography.fontSize * 2,
107
134
  '& path': {
@@ -110,6 +137,14 @@ const stepperStyles = theme => ({
110
137
  },
111
138
  mobileDivider: {
112
139
  marginBottom: theme.spacing(2)
140
+ },
141
+ stepLabel: {
142
+ '&>span:nth-child(2)': {
143
+ margin: ({ orientation }) => orientation === 'vertical' ? '0 0 0 8px' : '',
144
+ '&>span:nth-child(1)': {
145
+ margin: ({ orientation }) => orientation === 'vertical' ? 0 : ''
146
+ }
147
+ },
113
148
  }
114
149
  });
115
150
 
@@ -132,21 +167,20 @@ const Stepper = ({
132
167
  disableNext = false,
133
168
  disablePrevious = false,
134
169
  showProgress = false,
170
+ disableActions = false,
171
+ orientation = 'horizontal',
135
172
  ...props
136
173
  }) => {
174
+ const theme = useTheme();
137
175
  const maxSteps = steps.length;
138
176
  const maxStep = maxStepProps || steps.length - 1;
139
-
177
+ const mobile = useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
178
+ const ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
140
179
  const [initialStep, setInitialStep] = useState(-1);
141
180
  useEffect(() => (activeStep > initialStep && showProgress) && setInitialStep(activeStep), [activeStep, initialStep, showProgress]);
142
181
 
143
- const ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
144
-
145
- const theme = useTheme();
146
- const mobile = useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
147
-
148
182
  return <Component {...props}>
149
- {mobile ? (
183
+ {mobile && orientation !== 'vertical' ? (
150
184
  <Paper square elevation={0}>
151
185
  <ListItem dense className={classes.header}>
152
186
  <ListItemIcon className={classes.icon}>{steps[activeStep][0]}</ListItemIcon>
@@ -159,20 +193,46 @@ const Stepper = ({
159
193
  className={classes.stepper}
160
194
  alternativeLabel
161
195
  activeStep={activeStep}
162
- connector={<ColorlibConnector />}>
163
- {steps.map(([icon, label, description], i) => (
196
+ orientation={orientation}
197
+ connector={<ColorlibConnector />}
198
+ >
199
+ {steps.map(([icon, label, description, subDescription], i) => (
164
200
  <Step key={label}>
165
- <StepButton disabled={i > maxStep} onClick={onClick(i)} optional={
166
- <Typography
167
- variant='caption'
168
- className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
169
- {description}
170
- </Typography>}>
201
+ {orientation === 'vertical' && subDescription &&
202
+ <div className={classes.subDescription}>
203
+ <Typography
204
+ variant='caption'
205
+ className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
206
+ {subDescription}
207
+ </Typography>
208
+ </div>
209
+ }
210
+ <StepButton
211
+ onClick={onClick(i)}
212
+ disabled={i > maxStep}
213
+ optional={
214
+ <>
215
+ <Typography
216
+ variant='caption'
217
+ className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
218
+ {description}
219
+ </Typography>
220
+ {orientation !== 'vertical' && subDescription &&
221
+ <Typography
222
+ variant='caption'
223
+ className={clsx(classes.caption, { [classes.selectedCaption]: activeStep >= i })}>
224
+ {subDescription}
225
+ </Typography>
226
+ }
227
+ </>
228
+ }
229
+ >
171
230
  <StepLabel
231
+ className={classes.stepLabel}
172
232
  disabled={i > maxStep}
173
233
  error={errors[i]}
174
234
  StepIconComponent={ColorlibStepIcon}
175
- StepIconProps={{ icon, error: errors[i], initial: initialStep >= i, ambienteTeste }}
235
+ StepIconProps={{ icon, error: errors[i], initial: initialStep >= i, ambienteTeste }}
176
236
  >
177
237
  {label}
178
238
  </StepLabel>
@@ -182,11 +242,13 @@ const Stepper = ({
182
242
  </MuiStepper>
183
243
  )}
184
244
 
185
- <Box padding={mobile ? 0 : 4} pt={1} pb={0}>
186
- {children}
187
- </Box>
245
+ {children &&
246
+ <Box padding={mobile ? 0 : 4} pt={1} pb={0}>
247
+ {children}
248
+ </Box>
249
+ }
188
250
 
189
- {mobile ? (
251
+ {mobile && orientation !== 'vertical' ? (
190
252
  <MobileStepper
191
253
  steps={maxSteps}
192
254
  position='bottom'
@@ -210,7 +272,7 @@ const Stepper = ({
210
272
  </Button>
211
273
  }
212
274
  />
213
- ) : (
275
+ ) : !disableActions ? (
214
276
  <DialogActions>
215
277
  <Box padding={mobile ? 0 : 4} paddingTop={1} paddingBottom={1}>
216
278
  <Button
@@ -228,7 +290,7 @@ const Stepper = ({
228
290
  </Button>
229
291
  </Box>
230
292
  </DialogActions>
231
- ) }
293
+ ) : null }
232
294
  </Component>;
233
295
  };
234
296
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.161",
3
+ "version": "1.2.164",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",