@@ -22,6 +22,10 @@ export const BulkSelectValue = {
2222
2323export type BulkSelectValue = ( typeof BulkSelectValue ) [ keyof typeof BulkSelectValue ] ;
2424
25+ const defaultSelectPageLabel = ( pageCount ?: number ) => `Select page${ pageCount ? ` (${ pageCount } )` : '' } ` ;
26+ const defaultSelectAllLabel = ( totalCount ?: number ) => `Select all${ totalCount ? ` (${ totalCount } )` : '' } ` ;
27+ const defaultSelectedLabel = ( selectedCount : number ) => `${ selectedCount } selected` ;
28+
2529/** extends DropdownProps */
2630export interface BulkSelectProps extends Omit < DropdownProps , 'toggle' | 'onSelect' > {
2731 /** BulkSelect className */
@@ -50,6 +54,14 @@ export interface BulkSelectProps extends Omit<DropdownProps, 'toggle' | 'onSelec
5054 dropdownListProps ?: Omit < DropdownListProps , 'children' > ;
5155 /** Additional props for MenuToggleProps */
5256 menuToggleProps ?: Omit < MenuToggleProps , 'children' | 'splitButtonItems' | 'ref' | 'isExpanded' | 'onClick' > ;
57+ /** Custom label for "Select none" option. Defaults to "Select none (0)" */
58+ selectNoneLabel ?: string ;
59+ /** Custom label for "Select page" option. Receives pageCount as parameter. Defaults to "Select page (N)" */
60+ selectPageLabel ?: ( pageCount ?: number ) => string ;
61+ /** Custom label for "Select all" option. Receives totalCount as parameter. Defaults to "Select all (N)" */
62+ selectAllLabel ?: ( totalCount ?: number ) => string ;
63+ /** Custom label formatter for selected count. Receives selectedCount as parameter. Defaults to "N selected" */
64+ selectedLabel ?: ( selectedCount : number ) => string ;
5365}
5466
5567export const BulkSelect : FC < BulkSelectProps > = ( {
@@ -65,6 +77,10 @@ export const BulkSelect: FC<BulkSelectProps> = ({
6577 menuToggleCheckboxProps,
6678 dropdownListProps,
6779 menuToggleProps,
80+ selectNoneLabel = 'Select none (0)' ,
81+ selectPageLabel = defaultSelectPageLabel ,
82+ selectAllLabel = defaultSelectAllLabel ,
83+ selectedLabel = defaultSelectedLabel ,
6884 ...props
6985} : BulkSelectProps ) => {
7086 const [ isOpen , setOpen ] = useState ( false ) ;
@@ -73,23 +89,25 @@ export const BulkSelect: FC<BulkSelectProps> = ({
7389 ( ) => (
7490 < >
7591 < DropdownItem ouiaId = { `${ ouiaId } -select-none` } value = { BulkSelectValue . none } key = { BulkSelectValue . none } >
76- Select none (0)
92+ { selectNoneLabel }
7793 </ DropdownItem >
7894 { isDataPaginated && (
7995 < DropdownItem ouiaId = { `${ ouiaId } -select-page` } value = { BulkSelectValue . page } key = { BulkSelectValue . page } >
80- { `Select page ${ pageCount ? ` ( ${ pageCount } )` : '' } ` }
96+ { selectPageLabel ( pageCount ) }
8197 </ DropdownItem >
8298 ) }
8399 { canSelectAll && (
84100 < DropdownItem ouiaId = { `${ ouiaId } -select-all` } value = { BulkSelectValue . all } key = { BulkSelectValue . all } >
85- { `Select all ${ totalCount ? ` ( ${ totalCount } )` : '' } ` }
101+ { selectAllLabel ( totalCount ) }
86102 </ DropdownItem >
87103 ) }
88104 </ >
89105 ) ,
90- [ isDataPaginated , canSelectAll , ouiaId , pageCount , totalCount ]
106+ [ isDataPaginated , canSelectAll , ouiaId , selectNoneLabel , selectPageLabel , selectAllLabel , pageCount , totalCount ]
91107 ) ;
92108
109+ const selectedLabelText = selectedLabel ( selectedCount ) ;
110+
93111 const allOption = isDataPaginated ? BulkSelectValue . page : BulkSelectValue . all ;
94112 const noneOption = isDataPaginated ? BulkSelectValue . nonePage : BulkSelectValue . none ;
95113
@@ -129,7 +147,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
129147 >
130148 { selectedCount > 0 ? (
131149 < span data-ouia-component-id = { `${ ouiaId } -text` } >
132- { ` ${ selectedCount } selected` }
150+ { selectedLabelText }
133151 </ span >
134152 ) : null }
135153 </ MenuToggleCheckbox >
0 commit comments