@@ -18,6 +18,8 @@ import { Score } from '../dynamic-icons/score/example';
1818import SvgIcon from '../../shared/svg-icon' ;
1919import { Radio } from '../radio-group/base/example' ;
2020
21+ const checkboxRadioGroupHeaderId = 'check-group-header' ;
22+
2123export const InlineEditTableContainer = props => (
2224 < div className = "slds-table_edit_container slds-is-relative" >
2325 { props . children }
@@ -51,18 +53,18 @@ export const AdvancedDataTable = props => (
5153/**
5254 * @name Thead - thead block for advanced, inline, and product edit grids
5355 * @param {* } props
56+ * @prop {array } columnHeaderIcons - List of column names->icon name blocks which show an icon
5457 * @prop {array } columns - Grid columns
5558 * @prop {boolean } actionableMode - Specifies whether the grid is in actionable or navigation mode
56- * @prop {array } columnHeaderIcons - List of column names->icon name blocks which show an icon
5759 * @prop {boolean } hasErrorColumn - Specifies whether the grid has a errors column
5860 * @prop {boolean } hasFocus - Specifies whether a cell in the thead is in user focus
59- * @prop {boolean } hasNoSelectability - Specifies whether the thead should not contain a "select all" checkbox
6061 * @prop {boolean } hasMenus - Specifies whether the cells in the thead have a menu button
62+ * @prop {boolean } hasNoSelectability - Specifies whether the thead should not contain a "select all" checkbox
63+ * @prop {boolean } isSingleSelect - Specifies if the row selection uses radio buttons
6164 * @prop {boolean } selectAll - Specifies whether the select all checkbox is marked
6265 * @prop {string } mainColumnWidth - Specifies width of main columns
6366 * @prop {string } singleColumnWidth - Specifies width of a specific column
6467 * @prop {string } sortDirection - Specifies the sort direction of a specific column
65- * @prop {string } radioGroupId - common id of radio group
6668 */
6769export const Thead = props => {
6870 const selectAllColumnWidth = props . hasErrorColumn ? '2rem' : '3.25rem' ;
@@ -73,7 +75,7 @@ export const Thead = props => {
7375 < tr className = "slds-line-height_reset" >
7476 { props . hasErrorColumn ? < ErrorsTh /> : null }
7577
76- { props . hasNoSelectability ? null : (
78+ { props . hasNoSelectability || props . isSingleSelect ? null : (
7779 < SelectAllTh
7880 actionableMode = { props . actionableMode }
7981 checked = { props . selectAll }
@@ -82,13 +84,9 @@ export const Thead = props => {
8284 />
8385 ) }
8486
85- { props . radioGroupId ? (
86- < RadioGroupTh
87- style = { { width : selectAllColumnWidth } }
88- radioGroupId = { props . radioGroupId }
89- label = { props . label }
90- />
91- ) : null }
87+ { props . isSingleSelect && (
88+ < RadioGroupTh style = { { width : selectAllColumnWidth } } />
89+ ) }
9290
9391 { _ . times ( props . columns . length , i => (
9492 < Th
@@ -278,12 +276,17 @@ export let Th = props => {
278276 */
279277export const SelectAllTh = props => (
280278 < th style = { props . style } className = { props . className } scope = "col" >
279+ < span id = { checkboxRadioGroupHeaderId } className = "slds-assistive-text" >
280+ Choose a row
281+ </ span >
281282 < div className = "slds-th__action slds-th__action_form" >
282283 < Checkbox
283284 tabIndex = { props . actionableMode ? '0' : '-1' }
285+ labelId = "check-select-all-label"
284286 label = "Select All"
285287 hideLabel
286288 checked = { props . checked ? true : null }
289+ groupId = { checkboxRadioGroupHeaderId }
287290 />
288291 </ div >
289292 </ th >
@@ -293,17 +296,12 @@ export const SelectAllTh = props => (
293296 * @name RadioGroupTh - Radio group column header
294297 * @param {* } props
295298 * @prop {object } style - React style object
296- * @prop {string } radioGroupId - common id of radio group
297- * @prop {string } label - header text for radio group column
298299 */
299300export const RadioGroupTh = props => (
300- < th
301- className = { props . className }
302- scope = "col"
303- style = { props . style }
304- id = { props . radioGroupId }
305- >
306- < span className = "slds-assistive-text" > { props . label } </ span >
301+ < th className = { props . className } scope = "col" style = { props . style } >
302+ < span id = "radio-group-header" className = "slds-assistive-text" >
303+ Choose a row to select
304+ </ span >
307305 </ th >
308306) ;
309307
@@ -337,6 +335,7 @@ export const ErrorsTh = props => (
337335 * @prop {boolean } actionableMode - Specifies whether the grid is in actionable or navigation mode
338336 * @prop {boolean } hasFocus - Specifies whether a specific cell is in focus
339337 * @prop {boolean } hasScore - Specifies whether a row has a score cell
338+ * @prop {boolean } isSingleSelect - Specifies whether to use a radio button for selection or not
340339 * @prop {boolean } rowSelected
341340 * @prop {integer } index - Row index in the Grid
342341 * @prop {string } accountName
@@ -349,7 +348,6 @@ export const ErrorsTh = props => (
349348 * @prop {string } contact
350349 * @prop {string } recordName
351350 * @prop {string } stage
352- * @prop {string } radioGroupId - common id of radio group
353351 */
354352export const AdvancedDataTableTr = props => (
355353 < AdvancedDataTableTrElement
@@ -361,7 +359,7 @@ export const AdvancedDataTableTr = props => (
361359 inputTabIndex = { props . actionableMode ? '0' : '-1' }
362360 checked = { props . rowSelected }
363361 index = { props . index }
364- radioGroupId = { props . radioGroupId }
362+ isSingleSelect = { props . isSingleSelect }
365363 />
366364 < ReadOnlyBodyTh
367365 actionableMode = { props . actionableMode }
@@ -484,11 +482,11 @@ export const AdvancedDataTableBodyTh = props => {
484482 * @prop {boolean } checked - Set checked on the cell checkbox
485483 * @prop {boolean } hasFocus - Determines whether the cell is in user focus
486484 * @prop {boolean } isEditable - Determines whether the cell is editable
485+ * @prop {boolean } isSingleSelect - Specifies whether to use a radio button for selection or not
487486 * @prop {integer } cellTabIndex - Set tabindex on the cell
488- * @prop {integer } inputTabIndex - Set tabindex on the checkbox
489487 * @prop {integer } index - Grid row index
488+ * @prop {integer } inputTabIndex - Set tabindex on the checkbox
490489 * @prop {string } className
491- * @prop {string } radioGroupId - common id of radio group
492490 */
493491export const SelectRowTd = props => (
494492 < AdvancedDataTableTd
@@ -497,22 +495,24 @@ export const SelectRowTd = props => (
497495 isEditable = { props . isEditable }
498496 tabIndex = { props . cellTabIndex }
499497 >
500- { props . radioGroupId ? (
498+ { props . isSingleSelect ? (
501499 < Radio
502500 checked = { props . checked }
503501 hideLabel
504502 id = { `radio-0${ props . index } ` }
505503 labelId = { `radio-button-label-0${ props . index } ` }
506504 label = { `Select item ${ props . index } ` }
507- radioGroupId = { props . radioGroupId }
505+ groupId = "radio-group-header"
508506 tabIndex = { props . inputTabIndex }
509507 />
510508 ) : (
511509 < Checkbox
512510 checked = { props . checked }
513511 hideLabel
512+ labelId = { `check-button-label-0${ props . index } ` }
514513 id = { `checkbox-0${ props . index } ` }
515514 label = { `Select item ${ props . index } ` }
515+ groupId = { checkboxRadioGroupHeaderId }
516516 tabIndex = { props . inputTabIndex }
517517 />
518518 ) }
0 commit comments