Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 1x 41x 41x 41x 41x 123x 123x 123x 1x 1x | import { Box, Step, Stepper, useMediaQuery } from "@mui/material";
import { forwardRef } from "react";
import GiveButton from "@shared/Button/GiveButton";
import GiveKotoLinearProgress from "./GiveKotoLinearProgress";
import GiveText from "@shared/Text/GiveText";
import { useAppTheme } from "@theme/v2/Provider";
import { useKotoStepper } from "../hooks/useKotoStepper";
import { IStepperProps } from "../types";
const SignupKotoStepper = forwardRef(
(
{
customSteps: steps,
isClickable = true,
setIsLoaded,
actionOnClick,
setStep,
defaultStep,
LinearProgressProps,
svgProps,
automateLast,
disableLastClick,
overriderActiveStep,
disableWithoutStyle,
alwaysEnable = false,
kotoStepClickHandler,
isCompletedColor,
showCompletedView = false,
...rest
}: IStepperProps,
ref,
) => {
const theme = useAppTheme();
const isMedium = useMediaQuery(theme.breakpoints.up("md"));
const {
activeStep,
visibleSteps,
getStepValue,
canActivateStep,
handleStepClick,
} = useKotoStepper({
ref,
steps,
defaultStep,
setIsLoaded,
actionOnClick,
setStep,
automateLast,
disableLastClick,
overriderActiveStep,
disableWithoutStyle,
alwaysEnable,
isClickable,
kotoStepClickHandler,
});
return (
<Box
sx={{
...rest.sx,
flexDirection: "row",
display: "flex",
alignItems: "center",
paddingRight: "40px",
paddingLeft: "40px",
}}
>
<Stepper nonLinear activeStep={activeStep} sx={{ ...KotoStepperStyle }}>
{visibleSteps.map((step, index) => {
const hideLabel = !isMedium && index !== activeStep;
const value = getStepValue(index);
return (
<Step
sx={{ width: "100%", height: "100%", alignItems: "start" }}
key={step?.label}
>
<GiveButton
data-testid={`stepper-${step?.label}-button`}
sx={{
padding: 0,
backgroundColor: "unset",
cursor: canActivateStep(index) ? "pointer" : "default",
verticalAlign: "top",
}}
onClick={() => handleStepClick(index)}
disabled={!canActivateStep(index)}
fullWidth
label={
<Box width={"100%"}>
<GiveKotoLinearProgress
hasDescription={true}
value={value}
label={hideLabel ? "" : step?.label}
isActive={index === activeStep && !showCompletedView}
isCompletedColor={isCompletedColor}
/>
</Box>
}
/>
</Step>
);
})}
</Stepper>
{!isMedium && (
<GiveText variant="bodyXS">
{activeStep + 1}/{visibleSteps.length}
</GiveText>
)}
</Box>
);
},
);
const KotoStepperStyle = {
justifyContent: "space-between",
alignItems: "flex-start",
width: "100%",
".MuiStepLabel-iconContainer, .MuiStepConnector-root": {
display: "none",
},
};
SignupKotoStepper.displayName = "KotoStepper";
export default SignupKotoStepper;
|