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 ListContext from "./ListContext.js";
|
10 | import { getListUtilityClass } from "./listClasses.js";
|
11 | import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
12 | const useUtilityClasses = ownerState => {
|
13 | const {
|
14 | classes,
|
15 | disablePadding,
|
16 | dense,
|
17 | subheader
|
18 | } = ownerState;
|
19 | const slots = {
|
20 | root: ['root', !disablePadding && 'padding', dense && 'dense', subheader && 'subheader']
|
21 | };
|
22 | return composeClasses(slots, getListUtilityClass, classes);
|
23 | };
|
24 | const ListRoot = styled('ul', {
|
25 | name: 'MuiList',
|
26 | slot: 'Root',
|
27 | overridesResolver: (props, styles) => {
|
28 | const {
|
29 | ownerState
|
30 | } = props;
|
31 | return [styles.root, !ownerState.disablePadding && styles.padding, ownerState.dense && styles.dense, ownerState.subheader && styles.subheader];
|
32 | }
|
33 | })({
|
34 | listStyle: 'none',
|
35 | margin: 0,
|
36 | padding: 0,
|
37 | position: 'relative',
|
38 | variants: [{
|
39 | props: ({
|
40 | ownerState
|
41 | }) => !ownerState.disablePadding,
|
42 | style: {
|
43 | paddingTop: 8,
|
44 | paddingBottom: 8
|
45 | }
|
46 | }, {
|
47 | props: ({
|
48 | ownerState
|
49 | }) => ownerState.subheader,
|
50 | style: {
|
51 | paddingTop: 0
|
52 | }
|
53 | }]
|
54 | });
|
55 | const List = React.forwardRef(function List(inProps, ref) {
|
56 | const props = useDefaultProps({
|
57 | props: inProps,
|
58 | name: 'MuiList'
|
59 | });
|
60 | const {
|
61 | children,
|
62 | className,
|
63 | component = 'ul',
|
64 | dense = false,
|
65 | disablePadding = false,
|
66 | subheader,
|
67 | ...other
|
68 | } = props;
|
69 | const context = React.useMemo(() => ({
|
70 | dense
|
71 | }), [dense]);
|
72 | const ownerState = {
|
73 | ...props,
|
74 | component,
|
75 | dense,
|
76 | disablePadding
|
77 | };
|
78 | const classes = useUtilityClasses(ownerState);
|
79 | return _jsx(ListContext.Provider, {
|
80 | value: context,
|
81 | children: _jsxs(ListRoot, {
|
82 | as: component,
|
83 | className: clsx(classes.root, className),
|
84 | ref: ref,
|
85 | ownerState: ownerState,
|
86 | ...other,
|
87 | children: [subheader, children]
|
88 | })
|
89 | });
|
90 | });
|
91 | process.env.NODE_ENV !== "production" ? List.propTypes = {
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | |
97 |
|
98 |
|
99 | children: PropTypes.node,
|
100 | |
101 |
|
102 |
|
103 | classes: PropTypes.object,
|
104 | |
105 |
|
106 |
|
107 | className: PropTypes.string,
|
108 | |
109 |
|
110 |
|
111 |
|
112 | component: PropTypes.elementType,
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | dense: PropTypes.bool,
|
120 | |
121 |
|
122 |
|
123 |
|
124 | disablePadding: PropTypes.bool,
|
125 | |
126 |
|
127 |
|
128 | subheader: PropTypes.node,
|
129 | |
130 |
|
131 |
|
132 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
133 | } : void 0;
|
134 | export default List; |
\ | No newline at end of file |