1
1
import React from 'react'
2
2
import { useId } from '../hooks/useId'
3
- import Box from '../Box'
4
3
import type { SxProp } from '../sx'
5
4
import { ListContext , type ActionListProps } from './shared'
6
5
import type { AriaRole } from '../utils/types'
@@ -9,10 +8,9 @@ import {useSlots} from '../hooks/useSlots'
9
8
import { defaultSxProp } from '../utils/defaultSxProp'
10
9
import { invariant } from '../utils/invariant'
11
10
import { clsx } from 'clsx'
12
- import { useFeatureFlag } from '../FeatureFlags'
13
11
import classes from './ActionList.module.css'
14
12
import groupClasses from './Group.module.css'
15
- import { actionListCssModulesFlag } from './featureflag '
13
+ import { BoxWithFallback } from '../internal/components/BoxWithFallback '
16
14
17
15
type HeadingProps = {
18
16
as ?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
@@ -31,9 +29,9 @@ const Heading: React.FC<HeadingProps & React.HTMLAttributes<HTMLHeadingElement>>
31
29
} ) => {
32
30
return (
33
31
// Box is temporary to support lingering sx usage
34
- < Box as = { Component } className = { className } sx = { sx } id = { id } { ...rest } >
32
+ < BoxWithFallback as = { Component } className = { className } sx = { sx } id = { id } { ...rest } >
35
33
{ children }
36
- </ Box >
34
+ </ BoxWithFallback >
37
35
)
38
36
}
39
37
@@ -94,7 +92,6 @@ export const Group: React.FC<React.PropsWithChildren<ActionListGroupProps>> = ({
94
92
sx = defaultSxProp ,
95
93
...props
96
94
} ) => {
97
- const enabled = useFeatureFlag ( actionListCssModulesFlag )
98
95
const id = useId ( )
99
96
const { role : listRole } = React . useContext ( ListContext )
100
97
@@ -114,70 +111,12 @@ export const Group: React.FC<React.PropsWithChildren<ActionListGroupProps>> = ({
114
111
groupHeadingId = id
115
112
}
116
113
117
- if ( enabled ) {
118
- if ( sx !== defaultSxProp ) {
119
- return (
120
- < Box
121
- as = "li"
122
- className = { clsx ( className , groupClasses . Group ) }
123
- role = { listRole ? 'none' : undefined }
124
- sx = { sx }
125
- { ...props }
126
- >
127
- < GroupContext . Provider value = { { selectionVariant, groupHeadingId} } >
128
- { title && ! slots . groupHeading ? (
129
- // Escape hatch: supports old API <ActionList.Group title="group title"> in a non breaking way
130
- < GroupHeading variant = { variant } auxiliaryText = { auxiliaryText } _internalBackwardCompatibleTitle = { title } />
131
- ) : null }
132
- { /* Supports new API ActionList.GroupHeading */ }
133
- { ! title && slots . groupHeading ? React . cloneElement ( slots . groupHeading ) : null }
134
- < ul
135
- // if listRole is set (listbox or menu), we don't label the list with the groupHeadingId
136
- // because the heading is hidden from the accessibility tree and only used for presentation role.
137
- // We will instead use aria-label to label the list. See a line below.
138
- aria-labelledby = { listRole ? undefined : groupHeadingId }
139
- aria-label = { listRole ? ( title ?? ( slots . groupHeading ?. props . children as string ) ) : undefined }
140
- role = { role || ( listRole && 'group' ) }
141
- >
142
- { slots . groupHeading ? childrenWithoutSlots : props . children }
143
- </ ul >
144
- </ GroupContext . Provider >
145
- </ Box >
146
- )
147
- }
148
- return (
149
- < li className = { clsx ( className , groupClasses . Group ) } role = { listRole ? 'none' : undefined } { ...props } >
150
- < GroupContext . Provider value = { { selectionVariant, groupHeadingId} } >
151
- { title && ! slots . groupHeading ? (
152
- // Escape hatch: supports old API <ActionList.Group title="group title"> in a non breaking way
153
- < GroupHeading variant = { variant } auxiliaryText = { auxiliaryText } _internalBackwardCompatibleTitle = { title } />
154
- ) : null }
155
- { /* Supports new API ActionList.GroupHeading */ }
156
- { ! title && slots . groupHeading ? React . cloneElement ( slots . groupHeading ) : null }
157
- < ul
158
- // if listRole is set (listbox or menu), we don't label the list with the groupHeadingId
159
- // because the heading is hidden from the accessibility tree and only used for presentation role.
160
- // We will instead use aria-label to label the list. See a line below.
161
- aria-labelledby = { listRole ? undefined : groupHeadingId }
162
- aria-label = { listRole ? ( title ?? ( slots . groupHeading ?. props . children as string ) ) : undefined }
163
- role = { role || ( listRole && 'group' ) }
164
- >
165
- { slots . groupHeading ? childrenWithoutSlots : props . children }
166
- </ ul >
167
- </ GroupContext . Provider >
168
- </ li >
169
- )
170
- }
171
114
return (
172
- < Box
115
+ < BoxWithFallback
173
116
as = "li"
117
+ className = { clsx ( className , groupClasses . Group ) }
174
118
role = { listRole ? 'none' : undefined }
175
- sx = { {
176
- '&:not(:first-child)' : { marginTop : 2 } ,
177
- listStyle : 'none' , // hide the ::marker inserted by browser's stylesheet
178
- ...sx ,
179
- } }
180
- className = { className }
119
+ sx = { sx }
181
120
{ ...props }
182
121
>
183
122
< GroupContext . Provider value = { { selectionVariant, groupHeadingId} } >
@@ -187,20 +126,19 @@ export const Group: React.FC<React.PropsWithChildren<ActionListGroupProps>> = ({
187
126
) : null }
188
127
{ /* Supports new API ActionList.GroupHeading */ }
189
128
{ ! title && slots . groupHeading ? React . cloneElement ( slots . groupHeading ) : null }
190
- < Box
191
- as = "ul"
192
- sx = { { paddingInlineStart : 0 } }
129
+ < ul
193
130
// if listRole is set (listbox or menu), we don't label the list with the groupHeadingId
194
131
// because the heading is hidden from the accessibility tree and only used for presentation role.
195
132
// We will instead use aria-label to label the list. See a line below.
196
133
aria-labelledby = { listRole ? undefined : groupHeadingId }
197
134
aria-label = { listRole ? ( title ?? ( slots . groupHeading ?. props . children as string ) ) : undefined }
198
135
role = { role || ( listRole && 'group' ) }
136
+ className = { groupClasses . GroupList }
199
137
>
200
138
{ slots . groupHeading ? childrenWithoutSlots : props . children }
201
- </ Box >
139
+ </ ul >
202
140
</ GroupContext . Provider >
203
- </ Box >
141
+ </ BoxWithFallback >
204
142
)
205
143
}
206
144
@@ -278,26 +216,15 @@ export const GroupHeading: React.FC<React.PropsWithChildren<ActionListGroupHeadi
278
216
as = { headingWrapElement }
279
217
data-component = "GroupHeadingWrap"
280
218
>
281
- { sx !== defaultSxProp ? (
282
- < Heading
283
- className = { clsx ( className , groupClasses . GroupHeading ) }
284
- as = { as || 'h3' }
285
- id = { groupHeadingId }
286
- sx = { sx }
287
- { ...props }
288
- >
289
- { _internalBackwardCompatibleTitle ?? children }
290
- </ Heading >
291
- ) : (
292
- < Heading
293
- className = { clsx ( className , groupClasses . GroupHeading ) }
294
- as = { as || 'h3' }
295
- id = { groupHeadingId }
296
- { ...props }
297
- >
298
- { _internalBackwardCompatibleTitle ?? children }
299
- </ Heading >
300
- ) }
219
+ < Heading
220
+ className = { clsx ( className , groupClasses . GroupHeading ) }
221
+ as = { as || 'h3' }
222
+ id = { groupHeadingId }
223
+ sx = { sx }
224
+ { ...props }
225
+ >
226
+ { _internalBackwardCompatibleTitle ?? children }
227
+ </ Heading >
301
228
{ auxiliaryText && < div className = { classes . Description } > { auxiliaryText } </ div > }
302
229
</ HeadingWrap >
303
230
) }
0 commit comments