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.

143 lines (141 loc) 4.97 kB
'use client'; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; import _extends from "@babel/runtime/helpers/esm/extends"; const _excluded = ["className", "component", "color", "children", "variant", "slots", "slotProps"]; import * as React from 'react'; import clsx from 'clsx'; import PropTypes from 'prop-types'; import { unstable_composeClasses as composeClasses } from '@mui/base'; import { unstable_capitalize as capitalize } from '@mui/utils'; import { useThemeProps } from '../styles'; import styled from '../styles/styled'; import { getStepIndicatorUtilityClass } from './stepIndicatorClasses'; import useSlot from '../utils/useSlot'; import { jsx as _jsx } from "react/jsx-runtime"; const useUtilityClasses = ownerState => { const { color, variant } = ownerState; const slots = { root: ['root', color && `color${capitalize(color)}`, variant && `variant${capitalize(variant)}`] }; return composeClasses(slots, getStepIndicatorUtilityClass, {}); }; const StepIndicatorRoot = styled('div', { name: 'JoyStepIndicator', slot: 'Root', overridesResolver: (props, styles) => styles.root })(({ theme, ownerState }) => { return _extends({ '--Icon-fontSize': 'calc(var(--StepIndicator-size, 2rem) / 2)', '--Icon-color': 'currentColor', boxSizing: 'border-box', display: 'flex', alignItems: 'center', justifyContent: 'center', font: 'inherit', borderRadius: '50%', width: 'var(--StepIndicator-size, 1.5rem)', height: 'var(--StepIndicator-size, 1.5rem)' }, theme.variants[ownerState.variant]?.[ownerState.color]); }); /** * * Demos: * * - [Stepper](https://mui.com/joy-ui/react-stepper/) * * API: * * - [StepIndicator API](https://mui.com/joy-ui/api/step-indicator/) */ const StepIndicator = /*#__PURE__*/React.forwardRef(function StepIndicator(inProps, ref) { const props = useThemeProps({ props: inProps, name: 'JoyStepIndicator' }); const { className, component = 'div', color = 'neutral', children, variant = 'soft', slots = {}, slotProps = {} } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const ownerState = _extends({}, props, { component, color, variant }); const classes = useUtilityClasses(ownerState); const externalForwardedProps = _extends({}, other, { component, slots, slotProps }); const [SlotRoot, rootProps] = useSlot('root', { ref, className: clsx(classes.root, className), elementType: StepIndicatorRoot, externalForwardedProps, ownerState }); return /*#__PURE__*/_jsx(SlotRoot, _extends({}, rootProps, { children: children })); }); process.env.NODE_ENV !== "production" ? StepIndicator.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 StepIndicator if `src` is not set. * This can be an element, or just a string. */ children: PropTypes.node, /** * @ignore */ className: PropTypes.string, /** * The color of the component. It supports those theme colors that make sense for this component. * @default 'neutral' */ color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['danger', 'neutral', 'primary', 'success', 'warning']), 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]), /** * The [global variant](https://mui.com/joy-ui/main-features/global-variants/) to use. * @default 'soft' */ variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['outlined', 'plain', 'soft', 'solid']), PropTypes.string]) } : void 0; export default StepIndicator;