1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import { styled } from "../zero-styled/index.js";
|
8 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
9 | import ButtonBase from "../ButtonBase/index.js";
|
10 | import StepLabel from "../StepLabel/index.js";
|
11 | import isMuiElement from "../utils/isMuiElement.js";
|
12 | import StepperContext from "../Stepper/StepperContext.js";
|
13 | import StepContext from "../Step/StepContext.js";
|
14 | import stepButtonClasses, { getStepButtonUtilityClass } from "./stepButtonClasses.js";
|
15 | import { jsx as _jsx } from "react/jsx-runtime";
|
16 | const useUtilityClasses = ownerState => {
|
17 | const {
|
18 | classes,
|
19 | orientation
|
20 | } = ownerState;
|
21 | const slots = {
|
22 | root: ['root', orientation],
|
23 | touchRipple: ['touchRipple']
|
24 | };
|
25 | return composeClasses(slots, getStepButtonUtilityClass, classes);
|
26 | };
|
27 | const StepButtonRoot = styled(ButtonBase, {
|
28 | name: 'MuiStepButton',
|
29 | slot: 'Root',
|
30 | overridesResolver: (props, styles) => {
|
31 | const {
|
32 | ownerState
|
33 | } = props;
|
34 | return [{
|
35 | [`& .${stepButtonClasses.touchRipple}`]: styles.touchRipple
|
36 | }, styles.root, styles[ownerState.orientation]];
|
37 | }
|
38 | })({
|
39 | width: '100%',
|
40 | padding: '24px 16px',
|
41 | margin: '-24px -16px',
|
42 | boxSizing: 'content-box',
|
43 | [`& .${stepButtonClasses.touchRipple}`]: {
|
44 | color: 'rgba(0, 0, 0, 0.3)'
|
45 | },
|
46 | variants: [{
|
47 | props: {
|
48 | orientation: 'vertical'
|
49 | },
|
50 | style: {
|
51 | justifyContent: 'flex-start',
|
52 | padding: '8px',
|
53 | margin: '-8px'
|
54 | }
|
55 | }]
|
56 | });
|
57 | const StepButton = React.forwardRef(function StepButton(inProps, ref) {
|
58 | const props = useDefaultProps({
|
59 | props: inProps,
|
60 | name: 'MuiStepButton'
|
61 | });
|
62 | const {
|
63 | children,
|
64 | className,
|
65 | icon,
|
66 | optional,
|
67 | ...other
|
68 | } = props;
|
69 | const {
|
70 | disabled,
|
71 | active
|
72 | } = React.useContext(StepContext);
|
73 | const {
|
74 | orientation
|
75 | } = React.useContext(StepperContext);
|
76 | const ownerState = {
|
77 | ...props,
|
78 | orientation
|
79 | };
|
80 | const classes = useUtilityClasses(ownerState);
|
81 | const childProps = {
|
82 | icon,
|
83 | optional
|
84 | };
|
85 | const child = isMuiElement(children, ['StepLabel']) ? (React.cloneElement(children, childProps)) : _jsx(StepLabel, {
|
86 | ...childProps,
|
87 | children: children
|
88 | });
|
89 | return _jsx(StepButtonRoot, {
|
90 | focusRipple: true,
|
91 | disabled: disabled,
|
92 | TouchRippleProps: {
|
93 | className: classes.touchRipple
|
94 | },
|
95 | className: clsx(classes.root, className),
|
96 | ref: ref,
|
97 | ownerState: ownerState,
|
98 | "aria-current": active ? 'step' : undefined,
|
99 | ...other,
|
100 | children: child
|
101 | });
|
102 | });
|
103 | process.env.NODE_ENV !== "production" ? StepButton.propTypes = {
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | |
109 |
|
110 |
|
111 | children: PropTypes.node,
|
112 | |
113 |
|
114 |
|
115 | classes: PropTypes.object,
|
116 | |
117 |
|
118 |
|
119 | className: PropTypes.string,
|
120 | |
121 |
|
122 |
|
123 | icon: PropTypes.node,
|
124 | |
125 |
|
126 |
|
127 | optional: PropTypes.node,
|
128 | |
129 |
|
130 |
|
131 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
132 | } : void 0;
|
133 | export default StepButton; |
\ | No newline at end of file |