@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.
126 lines (125 loc) • 4.51 kB
JavaScript
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["component", "children", "orientation", "slots", "slotProps"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { unstable_composeClasses as composeClasses } from '@mui/base';
import { useThemeProps } from '../styles';
import styled from '../styles/styled';
import { getDialogContentUtilityClass } from './dialogContentClasses';
import useSlot from '../utils/useSlot';
import ModalDialogVariantColorContext from '../ModalDialog/ModalDialogVariantColorContext';
import { StyledCardContentRoot } from '../CardContent/CardContent';
import modalDialogClasses from '../ModalDialog/modalDialogClasses';
import dialogTitleClasses from '../DialogTitle/dialogTitleClasses';
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = () => {
const slots = {
root: ['root']
};
return composeClasses(slots, getDialogContentUtilityClass, {});
};
const DialogContentRoot = styled(StyledCardContentRoot, {
name: 'JoyDialogContent',
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({
theme
}) => ({
color: `var(--DialogContent-color, ${theme.vars.palette.text.tertiary})`,
overflow: 'auto',
margin: 'var(--unstable_DialogContent-margin)',
[`.${modalDialogClasses.root} > .${dialogTitleClasses.root} + &`]: {
'--unstable_DialogContent-margin': '-0.375em 0 0 0'
}
}));
/**
*
* Demos:
*
* - [Drawer](https://mui.com/joy-ui/react-drawer/)
* - [Modal](https://mui.com/joy-ui/react-modal/)
*
* API:
*
* - [DialogContent API](https://mui.com/joy-ui/api/dialog-content/)
*/
const DialogContent = /*#__PURE__*/React.forwardRef(function DialogContent(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: 'JoyDialogContent'
});
const context = React.useContext(ModalDialogVariantColorContext);
const {
component = 'div',
children,
orientation = 'vertical',
slots = {},
slotProps = {}
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const externalForwardedProps = _extends({}, other, {
component,
slots,
slotProps
});
const ownerState = _extends({}, props, {
component,
orientation
});
const classes = useUtilityClasses();
const [SlotRoot, rootProps] = useSlot('root', {
ref,
className: classes.root,
elementType: DialogContentRoot,
externalForwardedProps,
ownerState,
additionalProps: {
id: context == null ? void 0 : context.describedBy
}
});
return /*#__PURE__*/_jsx(SlotRoot, _extends({}, rootProps, {
children: children
}));
});
process.env.NODE_ENV !== "production" ? DialogContent.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 CardContent if `src` is not set.
* This can be an element, or just a string.
*/
children: PropTypes.node,
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: PropTypes.elementType,
/**
* The component orientation.
* @default 'vertical'
*/
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
/**
* 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 DialogContent;