@@ -4,10 +4,11 @@ import PropTypes from 'prop-types';
4
4
import clsx from 'clsx' ;
5
5
import composeClasses from '@mui/utils/composeClasses' ;
6
6
import { alpha } from '@mui/system/colorManipulator' ;
7
- import styled from '../styles/styled' ;
8
- import useThemeProps from '../styles/useThemeProps' ;
7
+ import { styled , createUseThemeProps } from '../zero-styled' ;
9
8
import { getDividerUtilityClass } from './dividerClasses' ;
10
9
10
+ const useThemeProps = createUseThemeProps ( 'MuiDivider' ) ;
11
+
11
12
const useUtilityClasses = ( ownerState ) => {
12
13
const { absolute, children, classes, flexItem, light, orientation, textAlign, variant } =
13
14
ownerState ;
@@ -54,100 +55,140 @@ const DividerRoot = styled('div', {
54
55
styles . textAlignLeft ,
55
56
] ;
56
57
} ,
57
- } ) (
58
- ( { theme, ownerState } ) => ( {
59
- margin : 0 , // Reset browser default style.
60
- flexShrink : 0 ,
61
- borderWidth : 0 ,
62
- borderStyle : 'solid' ,
63
- borderColor : ( theme . vars || theme ) . palette . divider ,
64
- borderBottomWidth : 'thin' ,
65
- ...( ownerState . absolute && {
66
- position : 'absolute' ,
67
- bottom : 0 ,
68
- left : 0 ,
69
- width : '100%' ,
70
- } ) ,
71
- ...( ownerState . light && {
72
- borderColor : theme . vars
73
- ? `rgba(${ theme . vars . palette . dividerChannel } / 0.08)`
74
- : alpha ( theme . palette . divider , 0.08 ) ,
75
- } ) ,
76
- ...( ownerState . variant === 'inset' && {
77
- marginLeft : 72 ,
78
- } ) ,
79
- ...( ownerState . variant === 'middle' &&
80
- ownerState . orientation === 'horizontal' && {
58
+ } ) ( ( { theme } ) => ( {
59
+ margin : 0 , // Reset browser default style.
60
+ flexShrink : 0 ,
61
+ borderWidth : 0 ,
62
+ borderStyle : 'solid' ,
63
+ borderColor : ( theme . vars || theme ) . palette . divider ,
64
+ borderBottomWidth : 'thin' ,
65
+ variants : [
66
+ {
67
+ props : {
68
+ absolute : true ,
69
+ } ,
70
+ style : {
71
+ position : 'absolute' ,
72
+ bottom : 0 ,
73
+ left : 0 ,
74
+ width : '100%' ,
75
+ } ,
76
+ } ,
77
+ {
78
+ props : {
79
+ light : true ,
80
+ } ,
81
+ style : {
82
+ borderColor : theme . vars
83
+ ? `rgba(${ theme . vars . palette . dividerChannel } / 0.08)`
84
+ : alpha ( theme . palette . divider , 0.08 ) ,
85
+ } ,
86
+ } ,
87
+ {
88
+ props : {
89
+ variant : 'inset' ,
90
+ } ,
91
+ style : {
92
+ marginLeft : 72 ,
93
+ } ,
94
+ } ,
95
+ {
96
+ props : {
97
+ variant : 'middle' ,
98
+ orientation : 'horizontal' ,
99
+ } ,
100
+ style : {
81
101
marginLeft : theme . spacing ( 2 ) ,
82
102
marginRight : theme . spacing ( 2 ) ,
83
- } ) ,
84
- ...( ownerState . variant === 'middle' &&
85
- ownerState . orientation === 'vertical' && {
103
+ } ,
104
+ } ,
105
+ {
106
+ props : {
107
+ variant : 'middle' ,
108
+ orientation : 'vertical' ,
109
+ } ,
110
+ style : {
86
111
marginTop : theme . spacing ( 1 ) ,
87
112
marginBottom : theme . spacing ( 1 ) ,
88
- } ) ,
89
- ...( ownerState . orientation === 'vertical' && {
90
- height : '100%' ,
91
- borderBottomWidth : 0 ,
92
- borderRightWidth : 'thin' ,
93
- } ) ,
94
- ...( ownerState . flexItem && {
95
- alignSelf : 'stretch' ,
96
- height : 'auto' ,
97
- } ) ,
98
- } ) ,
99
- ( { ownerState } ) => ( {
100
- ...( ownerState . children && {
101
- display : 'flex' ,
102
- whiteSpace : 'nowrap' ,
103
- textAlign : 'center' ,
104
- border : 0 ,
105
- '&::before, &::after' : {
106
- content : '""' ,
107
- alignSelf : 'center' ,
108
113
} ,
109
- } ) ,
110
- } ) ,
111
- ( { theme, ownerState } ) => ( {
112
- ...( ownerState . children &&
113
- ownerState . orientation !== 'vertical' && {
114
+ } ,
115
+ {
116
+ props : {
117
+ orientation : 'vertical' ,
118
+ } ,
119
+ style : {
120
+ height : '100%' ,
121
+ borderBottomWidth : 0 ,
122
+ borderRightWidth : 'thin' ,
123
+ } ,
124
+ } ,
125
+ {
126
+ props : {
127
+ flexItem : true ,
128
+ } ,
129
+ style : {
130
+ alignSelf : 'stretch' ,
131
+ height : 'auto' ,
132
+ } ,
133
+ } ,
134
+ {
135
+ props : ( { ownerState } ) => ! ! ownerState . children ,
136
+ style : {
137
+ display : 'flex' ,
138
+ whiteSpace : 'nowrap' ,
139
+ textAlign : 'center' ,
140
+ border : 0 ,
141
+ '&::before, &::after' : {
142
+ content : '""' ,
143
+ alignSelf : 'center' ,
144
+ } ,
145
+ } ,
146
+ } ,
147
+ {
148
+ props : ( { ownerState } ) => ownerState . children && ownerState . orientation !== 'vertical' ,
149
+ style : {
114
150
'&::before, &::after' : {
115
151
width : '100%' ,
116
152
borderTop : `thin solid ${ ( theme . vars || theme ) . palette . divider } ` ,
117
153
} ,
118
- } ) ,
119
- } ) ,
120
- ( { theme , ownerState } ) => ( {
121
- ... ( ownerState . children &&
122
- ownerState . orientation === 'vertical' && {
154
+ } ,
155
+ } ,
156
+ {
157
+ props : ( { ownerState } ) => ownerState . orientation === 'vertical' && ownerState . children ,
158
+ style : {
123
159
flexDirection : 'column' ,
124
160
'&::before, &::after' : {
125
161
height : '100%' ,
126
162
borderLeft : `thin solid ${ ( theme . vars || theme ) . palette . divider } ` ,
127
163
} ,
128
- } ) ,
129
- } ) ,
130
- ( { ownerState } ) => ( {
131
- ...( ownerState . textAlign === 'right' &&
132
- ownerState . orientation !== 'vertical' && {
164
+ } ,
165
+ } ,
166
+ {
167
+ props : ( { ownerState } ) =>
168
+ ownerState . textAlign === 'right' && ownerState . orientation !== 'vertical' ,
169
+ style : {
133
170
'&::before' : {
134
171
width : '90%' ,
135
172
} ,
136
173
'&::after' : {
137
174
width : '10%' ,
138
175
} ,
139
- } ) ,
140
- ...( ownerState . textAlign === 'left' &&
141
- ownerState . orientation !== 'vertical' && {
176
+ } ,
177
+ } ,
178
+ {
179
+ props : ( { ownerState } ) =>
180
+ ownerState . textAlign === 'left' && ownerState . orientation !== 'vertical' ,
181
+ style : {
142
182
'&::before' : {
143
183
width : '10%' ,
144
184
} ,
145
185
'&::after' : {
146
186
width : '90%' ,
147
187
} ,
148
- } ) ,
149
- } ) ,
150
- ) ;
188
+ } ,
189
+ } ,
190
+ ] ,
191
+ } ) ) ;
151
192
152
193
const DividerWrapper = styled ( 'span' , {
153
194
name : 'MuiDivider' ,
@@ -157,14 +198,21 @@ const DividerWrapper = styled('span', {
157
198
158
199
return [ styles . wrapper , ownerState . orientation === 'vertical' && styles . wrapperVertical ] ;
159
200
} ,
160
- } ) ( ( { theme, ownerState } ) => ( {
201
+ } ) ( ( { theme } ) => ( {
161
202
display : 'inline-block' ,
162
203
paddingLeft : `calc(${ theme . spacing ( 1 ) } * 1.2)` ,
163
204
paddingRight : `calc(${ theme . spacing ( 1 ) } * 1.2)` ,
164
- ...( ownerState . orientation === 'vertical' && {
165
- paddingTop : `calc(${ theme . spacing ( 1 ) } * 1.2)` ,
166
- paddingBottom : `calc(${ theme . spacing ( 1 ) } * 1.2)` ,
167
- } ) ,
205
+ variants : [
206
+ {
207
+ props : {
208
+ orientation : 'vertical' ,
209
+ } ,
210
+ style : {
211
+ paddingTop : `calc(${ theme . spacing ( 1 ) } * 1.2)` ,
212
+ paddingBottom : `calc(${ theme . spacing ( 1 ) } * 1.2)` ,
213
+ } ,
214
+ } ,
215
+ ] ,
168
216
} ) ) ;
169
217
170
218
const Divider = React . forwardRef ( function Divider ( inProps , ref ) {
@@ -219,7 +267,9 @@ const Divider = React.forwardRef(function Divider(inProps, ref) {
219
267
* The following flag is used to ensure that this component isn't tabbable i.e.
220
268
* does not get highlight/focus inside of MUI List.
221
269
*/
222
- Divider . muiSkipListHighlight = true ;
270
+ if ( Divider ) {
271
+ Divider . muiSkipListHighlight = true ;
272
+ }
223
273
224
274
Divider . propTypes /* remove-proptypes */ = {
225
275
// ┌────────────────────────────── Warning ──────────────────────────────┐
0 commit comments