@@ -137,57 +137,116 @@ const Table = ({
137137 options = { union ( getTablePickerOptionsAsc , getTablePickerOptionsDesc ) } />
138138 </ div >
139139 ) }
140- < table className = { `usda-table ${ stackedClass } ${ classNames } ` } >
141- { screenReaderCaption && (
142- < caption className = "usa-dt-sr-only" > { screenReaderCaption } </ caption >
140+ { isStacked && isMobile
141+ ? (
142+ < div className = { `usda-table ${ stackedClass } ${ classNames } ` } >
143+ { screenReaderCaption && (
144+ < caption className = "usa-dt-sr-only" > { screenReaderCaption } </ caption >
145+ ) }
146+ { highlightedColumns
147+ && (
148+ < colgroup >
149+ < col span = { highlightedColumns . standardColumns } />
150+ < col span = { highlightedColumns . highlightedColumns } className = "usda-table__body-special-color" />
151+ </ colgroup >
143152 ) }
144- { highlightedColumns
153+ < div className = "usda-table__head" >
154+ < div className = "usda-table__row" style = { { height : headerRowHeight } } >
155+ { columns . map ( ( col , index ) => (
156+ < TableHeader
157+ key = { uniqueId ( ) }
158+ currentSort = { currentSort }
159+ updateSort = { updateSort }
160+ stickyFirstColumn = { stickyFirstColumn }
161+ highlightedColumns = { highlightedColumns }
162+ index = { index }
163+ isMobile = { isMobile }
164+ isStacked = { isStacked }
165+ { ...col } />
166+ ) ) }
167+ </ div >
168+ < div className = "usda-table__row" >
169+ { columns
170+ . filter ( ( col ) => col ?. subColumnNames ?. length )
171+ . reduce ( ( acc , col ) => {
172+ if ( col ?. subColumnNames ?. length ) {
173+ return acc . concat ( col . subColumnNames ) ;
174+ }
175+ return acc . concat ( [ {
176+ ...col , displayName : '' , className : 'empty-subheader'
177+ } ] ) ;
178+ } , [ ] )
179+ . map ( ( col , index ) => (
180+ < TableHeader
181+ key = { uniqueId ( ) }
182+ className = { col ?. title ? 'nested-header' : 'empty' }
183+ currentSort = { currentSort }
184+ updateSort = { updateSort }
185+ stickyFirstColumn = { stickyFirstColumn }
186+ index = { index }
187+ isMobile = { isMobile }
188+ isStacked = { isStacked }
189+ { ...col } />
190+ ) ) }
191+ </ div >
192+ </ div >
193+ < div className = "usda-table__body" >
194+ { body }
195+ </ div >
196+ </ div >
197+ ) : (
198+ < table className = { `usda-table ${ stackedClass } ${ classNames } ` } >
199+ { screenReaderCaption && (
200+ < caption className = "usa-dt-sr-only" > { screenReaderCaption } </ caption >
201+ ) }
202+ { highlightedColumns
145203 && (
146204 < colgroup >
147205 < col span = { highlightedColumns . standardColumns } />
148206 < col span = { highlightedColumns . highlightedColumns } className = "usda-table__body-special-color" />
149207 </ colgroup >
150208 ) }
151- < thead className = "usda-table__head" >
152- < tr className = "usda-table__row" style = { { height : headerRowHeight } } >
153- { columns . map ( ( col , index ) => (
154- < TableHeader
155- key = { uniqueId ( ) }
156- currentSort = { currentSort }
157- updateSort = { updateSort }
158- stickyFirstColumn = { stickyFirstColumn }
159- highlightedColumns = { highlightedColumns }
160- index = { index }
161- { ...col } />
162- ) ) }
163- </ tr >
164- < tr className = "usda-table__row" >
165- { columns
166- . filter ( ( col ) => col ?. subColumnNames ?. length )
167- . reduce ( ( acc , col ) => {
168- if ( col ?. subColumnNames ?. length ) {
169- return acc . concat ( col . subColumnNames ) ;
170- }
171- return acc . concat ( [ {
172- ...col , displayName : '' , className : 'empty-subheader'
173- } ] ) ;
174- } , [ ] )
175- . map ( ( col , index ) => (
176- < TableHeader
177- key = { uniqueId ( ) }
178- className = { col ?. title ? 'nested-header' : 'empty' }
179- currentSort = { currentSort }
180- updateSort = { updateSort }
181- stickyFirstColumn = { stickyFirstColumn }
182- index = { index }
183- { ...col } />
184- ) ) }
185- </ tr >
186- </ thead >
187- < tbody className = "usda-table__body" >
188- { body }
189- </ tbody >
190- </ table >
209+ < thead className = "usda-table__head" >
210+ < tr className = "usda-table__row" style = { { height : headerRowHeight } } >
211+ { columns . map ( ( col , index ) => (
212+ < TableHeader
213+ key = { uniqueId ( ) }
214+ currentSort = { currentSort }
215+ updateSort = { updateSort }
216+ stickyFirstColumn = { stickyFirstColumn }
217+ highlightedColumns = { highlightedColumns }
218+ index = { index }
219+ { ...col } />
220+ ) ) }
221+ </ tr >
222+ < tr className = "usda-table__row" >
223+ { columns
224+ . filter ( ( col ) => col ?. subColumnNames ?. length )
225+ . reduce ( ( acc , col ) => {
226+ if ( col ?. subColumnNames ?. length ) {
227+ return acc . concat ( col . subColumnNames ) ;
228+ }
229+ return acc . concat ( [ {
230+ ...col , displayName : '' , className : 'empty-subheader'
231+ } ] ) ;
232+ } , [ ] )
233+ . map ( ( col , index ) => (
234+ < TableHeader
235+ key = { uniqueId ( ) }
236+ className = { col ?. title ? 'nested-header' : 'empty' }
237+ currentSort = { currentSort }
238+ updateSort = { updateSort }
239+ stickyFirstColumn = { stickyFirstColumn }
240+ index = { index }
241+ { ...col } />
242+ ) ) }
243+ </ tr >
244+ </ thead >
245+ < tbody className = "usda-table__body" >
246+ { body }
247+ </ tbody >
248+ </ table >
249+ ) }
191250 </ >
192251 ) ;
193252} ;
0 commit comments