UNPKG

3.52 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import composeClasses from '@mui/utils/composeClasses';
7import { styled } from "../zero-styled/index.js";
8import { useDefaultProps } from "../DefaultPropsProvider/index.js";
9import ListContext from "../List/ListContext.js";
10import { getListItemSecondaryActionClassesUtilityClass } from "./listItemSecondaryActionClasses.js";
11import { jsx as _jsx } from "react/jsx-runtime";
12const useUtilityClasses = ownerState => {
13 const {
14 disableGutters,
15 classes
16 } = ownerState;
17 const slots = {
18 root: ['root', disableGutters && 'disableGutters']
19 };
20 return composeClasses(slots, getListItemSecondaryActionClassesUtilityClass, classes);
21};
22const ListItemSecondaryActionRoot = styled('div', {
23 name: 'MuiListItemSecondaryAction',
24 slot: 'Root',
25 overridesResolver: (props, styles) => {
26 const {
27 ownerState
28 } = props;
29 return [styles.root, ownerState.disableGutters && styles.disableGutters];
30 }
31})({
32 position: 'absolute',
33 right: 16,
34 top: '50%',
35 transform: 'translateY(-50%)',
36 variants: [{
37 props: ({
38 ownerState
39 }) => ownerState.disableGutters,
40 style: {
41 right: 0
42 }
43 }]
44});
45
46/**
47 * Must be used as the last child of ListItem to function properly.
48 *
49 * @deprecated Use the `secondaryAction` prop in the `ListItem` component instead. This component will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
50 */
51const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemSecondaryAction(inProps, ref) {
52 const props = useDefaultProps({
53 props: inProps,
54 name: 'MuiListItemSecondaryAction'
55 });
56 const {
57 className,
58 ...other
59 } = props;
60 const context = React.useContext(ListContext);
61 const ownerState = {
62 ...props,
63 disableGutters: context.disableGutters
64 };
65 const classes = useUtilityClasses(ownerState);
66 return /*#__PURE__*/_jsx(ListItemSecondaryActionRoot, {
67 className: clsx(classes.root, className),
68 ownerState: ownerState,
69 ref: ref,
70 ...other
71 });
72});
73process.env.NODE_ENV !== "production" ? ListItemSecondaryAction.propTypes /* remove-proptypes */ = {
74 // ┌────────────────────────────── Warning ──────────────────────────────┐
75 // │ These PropTypes are generated from the TypeScript type definitions. │
76 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
77 // └─────────────────────────────────────────────────────────────────────┘
78 /**
79 * The content of the component, normally an `IconButton` or selection control.
80 */
81 children: PropTypes.node,
82 /**
83 * Override or extend the styles applied to the component.
84 */
85 classes: PropTypes.object,
86 /**
87 * @ignore
88 */
89 className: PropTypes.string,
90 /**
91 * The system prop that allows defining system overrides as well as additional CSS styles.
92 */
93 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
94} : void 0;
95ListItemSecondaryAction.muiName = 'ListItemSecondaryAction';
96export default ListItemSecondaryAction;
\No newline at end of file