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 { alpha } from '@mui/system/colorManipulator';
|
8 | import { styled } from "../zero-styled/index.js";
|
9 | import memoTheme from "../utils/memoTheme.js";
|
10 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
11 | import { getDividerUtilityClass } from "./dividerClasses.js";
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | absolute,
|
16 | children,
|
17 | classes,
|
18 | flexItem,
|
19 | light,
|
20 | orientation,
|
21 | textAlign,
|
22 | variant
|
23 | } = ownerState;
|
24 | const slots = {
|
25 | root: ['root', absolute && 'absolute', variant, light && 'light', orientation === 'vertical' && 'vertical', flexItem && 'flexItem', children && 'withChildren', children && orientation === 'vertical' && 'withChildrenVertical', textAlign === 'right' && orientation !== 'vertical' && 'textAlignRight', textAlign === 'left' && orientation !== 'vertical' && 'textAlignLeft'],
|
26 | wrapper: ['wrapper', orientation === 'vertical' && 'wrapperVertical']
|
27 | };
|
28 | return composeClasses(slots, getDividerUtilityClass, classes);
|
29 | };
|
30 | const DividerRoot = styled('div', {
|
31 | name: 'MuiDivider',
|
32 | slot: 'Root',
|
33 | overridesResolver: (props, styles) => {
|
34 | const {
|
35 | ownerState
|
36 | } = props;
|
37 | return [styles.root, ownerState.absolute && styles.absolute, styles[ownerState.variant], ownerState.light && styles.light, ownerState.orientation === 'vertical' && styles.vertical, ownerState.flexItem && styles.flexItem, ownerState.children && styles.withChildren, ownerState.children && ownerState.orientation === 'vertical' && styles.withChildrenVertical, ownerState.textAlign === 'right' && ownerState.orientation !== 'vertical' && styles.textAlignRight, ownerState.textAlign === 'left' && ownerState.orientation !== 'vertical' && styles.textAlignLeft];
|
38 | }
|
39 | })(memoTheme(({
|
40 | theme
|
41 | }) => ({
|
42 | margin: 0,
|
43 |
|
44 | flexShrink: 0,
|
45 | borderWidth: 0,
|
46 | borderStyle: 'solid',
|
47 | borderColor: (theme.vars || theme).palette.divider,
|
48 | borderBottomWidth: 'thin',
|
49 | variants: [{
|
50 | props: {
|
51 | absolute: true
|
52 | },
|
53 | style: {
|
54 | position: 'absolute',
|
55 | bottom: 0,
|
56 | left: 0,
|
57 | width: '100%'
|
58 | }
|
59 | }, {
|
60 | props: {
|
61 | light: true
|
62 | },
|
63 | style: {
|
64 | borderColor: theme.vars ? `rgba(${theme.vars.palette.dividerChannel} / 0.08)` : alpha(theme.palette.divider, 0.08)
|
65 | }
|
66 | }, {
|
67 | props: {
|
68 | variant: 'inset'
|
69 | },
|
70 | style: {
|
71 | marginLeft: 72
|
72 | }
|
73 | }, {
|
74 | props: {
|
75 | variant: 'middle',
|
76 | orientation: 'horizontal'
|
77 | },
|
78 | style: {
|
79 | marginLeft: theme.spacing(2),
|
80 | marginRight: theme.spacing(2)
|
81 | }
|
82 | }, {
|
83 | props: {
|
84 | variant: 'middle',
|
85 | orientation: 'vertical'
|
86 | },
|
87 | style: {
|
88 | marginTop: theme.spacing(1),
|
89 | marginBottom: theme.spacing(1)
|
90 | }
|
91 | }, {
|
92 | props: {
|
93 | orientation: 'vertical'
|
94 | },
|
95 | style: {
|
96 | height: '100%',
|
97 | borderBottomWidth: 0,
|
98 | borderRightWidth: 'thin'
|
99 | }
|
100 | }, {
|
101 | props: {
|
102 | flexItem: true
|
103 | },
|
104 | style: {
|
105 | alignSelf: 'stretch',
|
106 | height: 'auto'
|
107 | }
|
108 | }, {
|
109 | props: ({
|
110 | ownerState
|
111 | }) => !!ownerState.children,
|
112 | style: {
|
113 | display: 'flex',
|
114 | textAlign: 'center',
|
115 | border: 0,
|
116 | borderTopStyle: 'solid',
|
117 | borderLeftStyle: 'solid',
|
118 | '&::before, &::after': {
|
119 | content: '""',
|
120 | alignSelf: 'center'
|
121 | }
|
122 | }
|
123 | }, {
|
124 | props: ({
|
125 | ownerState
|
126 | }) => ownerState.children && ownerState.orientation !== 'vertical',
|
127 | style: {
|
128 | '&::before, &::after': {
|
129 | width: '100%',
|
130 | borderTop: `thin solid ${(theme.vars || theme).palette.divider}`,
|
131 | borderTopStyle: 'inherit'
|
132 | }
|
133 | }
|
134 | }, {
|
135 | props: ({
|
136 | ownerState
|
137 | }) => ownerState.orientation === 'vertical' && ownerState.children,
|
138 | style: {
|
139 | flexDirection: 'column',
|
140 | '&::before, &::after': {
|
141 | height: '100%',
|
142 | borderLeft: `thin solid ${(theme.vars || theme).palette.divider}`,
|
143 | borderLeftStyle: 'inherit'
|
144 | }
|
145 | }
|
146 | }, {
|
147 | props: ({
|
148 | ownerState
|
149 | }) => ownerState.textAlign === 'right' && ownerState.orientation !== 'vertical',
|
150 | style: {
|
151 | '&::before': {
|
152 | width: '90%'
|
153 | },
|
154 | '&::after': {
|
155 | width: '10%'
|
156 | }
|
157 | }
|
158 | }, {
|
159 | props: ({
|
160 | ownerState
|
161 | }) => ownerState.textAlign === 'left' && ownerState.orientation !== 'vertical',
|
162 | style: {
|
163 | '&::before': {
|
164 | width: '10%'
|
165 | },
|
166 | '&::after': {
|
167 | width: '90%'
|
168 | }
|
169 | }
|
170 | }]
|
171 | })));
|
172 | const DividerWrapper = styled('span', {
|
173 | name: 'MuiDivider',
|
174 | slot: 'Wrapper',
|
175 | overridesResolver: (props, styles) => {
|
176 | const {
|
177 | ownerState
|
178 | } = props;
|
179 | return [styles.wrapper, ownerState.orientation === 'vertical' && styles.wrapperVertical];
|
180 | }
|
181 | })(memoTheme(({
|
182 | theme
|
183 | }) => ({
|
184 | display: 'inline-block',
|
185 | paddingLeft: `calc(${theme.spacing(1)} * 1.2)`,
|
186 | paddingRight: `calc(${theme.spacing(1)} * 1.2)`,
|
187 | whiteSpace: 'nowrap',
|
188 | variants: [{
|
189 | props: {
|
190 | orientation: 'vertical'
|
191 | },
|
192 | style: {
|
193 | paddingTop: `calc(${theme.spacing(1)} * 1.2)`,
|
194 | paddingBottom: `calc(${theme.spacing(1)} * 1.2)`
|
195 | }
|
196 | }]
|
197 | })));
|
198 | const Divider = React.forwardRef(function Divider(inProps, ref) {
|
199 | const props = useDefaultProps({
|
200 | props: inProps,
|
201 | name: 'MuiDivider'
|
202 | });
|
203 | const {
|
204 | absolute = false,
|
205 | children,
|
206 | className,
|
207 | orientation = 'horizontal',
|
208 | component = children || orientation === 'vertical' ? 'div' : 'hr',
|
209 | flexItem = false,
|
210 | light = false,
|
211 | role = component !== 'hr' ? 'separator' : undefined,
|
212 | textAlign = 'center',
|
213 | variant = 'fullWidth',
|
214 | ...other
|
215 | } = props;
|
216 | const ownerState = {
|
217 | ...props,
|
218 | absolute,
|
219 | component,
|
220 | flexItem,
|
221 | light,
|
222 | orientation,
|
223 | role,
|
224 | textAlign,
|
225 | variant
|
226 | };
|
227 | const classes = useUtilityClasses(ownerState);
|
228 | return _jsx(DividerRoot, {
|
229 | as: component,
|
230 | className: clsx(classes.root, className),
|
231 | role: role,
|
232 | ref: ref,
|
233 | ownerState: ownerState,
|
234 | "aria-orientation": role === 'separator' && (component !== 'hr' || orientation === 'vertical') ? orientation : undefined,
|
235 | ...other,
|
236 | children: children ? _jsx(DividerWrapper, {
|
237 | className: classes.wrapper,
|
238 | ownerState: ownerState,
|
239 | children: children
|
240 | }) : null
|
241 | });
|
242 | });
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | if (Divider) {
|
249 | Divider.muiSkipListHighlight = true;
|
250 | }
|
251 | process.env.NODE_ENV !== "production" ? Divider.propTypes = {
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | |
257 |
|
258 |
|
259 |
|
260 | absolute: PropTypes.bool,
|
261 | |
262 |
|
263 |
|
264 | children: PropTypes.node,
|
265 | |
266 |
|
267 |
|
268 | classes: PropTypes.object,
|
269 | |
270 |
|
271 |
|
272 | className: PropTypes.string,
|
273 | |
274 |
|
275 |
|
276 |
|
277 | component: PropTypes.elementType,
|
278 | |
279 |
|
280 |
|
281 |
|
282 |
|
283 | flexItem: PropTypes.bool,
|
284 | |
285 |
|
286 |
|
287 |
|
288 |
|
289 | light: PropTypes.bool,
|
290 | |
291 |
|
292 |
|
293 |
|
294 | orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
295 | |
296 |
|
297 |
|
298 | role: PropTypes .string,
|
299 | |
300 |
|
301 |
|
302 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
303 | |
304 |
|
305 |
|
306 |
|
307 | textAlign: PropTypes.oneOf(['center', 'left', 'right']),
|
308 | |
309 |
|
310 |
|
311 |
|
312 | variant: PropTypes .oneOfType([PropTypes.oneOf(['fullWidth', 'inset', 'middle']), PropTypes.string])
|
313 | } : void 0;
|
314 | export default Divider; |
\ | No newline at end of file |