UNPKG

@mui/joy

Version:

Joy UI is an open-source React component library that implements MUI's own design principles. It's comprehensive and can be used in production out of the box.

156 lines (154 loc) 5.12 kB
'use client'; import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; const _excluded = ["className", "component", "children", "slots", "slotProps"]; import * as React from 'react'; import clsx from 'clsx'; import PropTypes from 'prop-types'; import { useThemeProps } from '../styles'; import styled from '../styles/styled'; import stepClasses from '../Step/stepClasses'; import stepperClasses from '../Stepper/stepperClasses'; import stepButtonClasses from './stepButtonClasses'; import useSlot from '../utils/useSlot'; import { jsx as _jsx } from "react/jsx-runtime"; const StepButtonRoot = styled('button', { name: 'JoyStepButton', slot: 'Root', overridesResolver: (props, styles) => styles.root })(({ theme }) => { return { [`.${stepClasses.indicator}:empty + &`]: { '--StepIndicator-size': '0px', '--Step-gap': '0px' }, [`.${stepClasses.horizontal} &`]: { '--_StepButton-alignSelf': 'stretch', '--_StepButton-gap': 'var(--Step-gap)' }, [`.${stepClasses.horizontal} &::before`]: { '--_StepButton-left': 'calc(-1 * (var(--StepIndicator-size) + var(--Step-gap)))' }, [`.${stepClasses.vertical} &::before`]: { '--_StepButton-top': 'calc(-1 * (var(--StepIndicator-size) + var(--Step-gap)))' }, [`.${stepperClasses.vertical} .${stepClasses.vertical} &`]: { '--_StepButton-alignItems': 'flex-start' }, [`.${stepperClasses.vertical} &::before`]: { '--_StepButton-left': 'calc(-1 * (var(--StepIndicator-size) + var(--Step-gap)))', '--_StepButton-top': '0px' }, WebkitTapHighlightColor: 'transparent', boxSizing: 'border-box', border: 'none', backgroundColor: 'transparent', cursor: 'pointer', position: 'relative', padding: 0, textDecoration: 'none', // prevent user agent underline when used as anchor font: 'inherit', display: 'inline-flex', flexDirection: 'inherit', alignItems: 'var(--_StepButton-alignItems, inherit)', alignSelf: 'var(--_StepButton-alignSelf)', gap: 'var(--_StepButton-gap)', [theme.focus.selector]: theme.focus.default, '&::before': { content: '""', display: 'block', position: 'absolute', top: 'var(--_StepButton-top, 0)', right: 0, bottom: 0, left: 'var(--_StepButton-left, 0)' } }; }); /** * * Demos: * * - [Stepper](https://mui.com/joy-ui/react-stepper/) * * API: * * - [StepButton API](https://mui.com/joy-ui/api/step-button/) */ const StepButton = /*#__PURE__*/React.forwardRef(function StepButton(inProps, ref) { const props = useThemeProps({ props: inProps, name: 'JoyStepButton' }); const { className, component = 'button', children, slots = {}, slotProps = {} } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const ownerState = _extends({}, props, { component }); const externalForwardedProps = _extends({}, other, { component, slots, slotProps }); const [SlotRoot, rootProps] = useSlot('root', { ref, className: clsx(stepButtonClasses.root, className), elementType: StepButtonRoot, externalForwardedProps, ownerState, additionalProps: { type: 'button' } }); return /*#__PURE__*/_jsx(SlotRoot, _extends({}, rootProps, { children: children })); }); process.env.NODE_ENV !== "production" ? StepButton.propTypes /* remove-proptypes */ = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * Used to render icon or text elements inside the StepButton if `src` is not set. * This can be an element, or just a string. */ children: PropTypes.node, /** * @ignore */ className: PropTypes.string, /** * The component used for the root node. * Either a string to use a HTML element or a component. */ component: PropTypes.elementType, /** * The props used for each slot inside. * @default {} */ slotProps: PropTypes.shape({ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]) }), /** * The components used for each slot inside. * @default {} */ slots: PropTypes.shape({ root: PropTypes.elementType }), /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]) } : void 0; export default StepButton;