Skip to content

Commit 16a47b8

Browse files
committed
feat(BulkSelect): extend onSelect API with source param
1 parent a46b56b commit 16a47b8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/module/src/BulkSelect/BulkSelect.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export const BulkSelectValue = {
2222

2323
export type BulkSelectValue = (typeof BulkSelectValue)[keyof typeof BulkSelectValue];
2424

25+
export type BulkSelectSource = 'dropdown' | 'checkbox';
26+
2527
const defaultSelectPageLabel = (pageCount?: number) => `Select page${pageCount ? ` (${pageCount})` : ''}`;
2628
const defaultSelectAllLabel = (totalCount?: number) => `Select all${totalCount ? ` (${totalCount})` : ''}`;
2729
const defaultSelectedLabel = (selectedCount: number) => `${selectedCount} selected`;
@@ -45,7 +47,7 @@ export interface BulkSelectProps extends Omit<DropdownProps, 'toggle' | 'onSelec
4547
/** Indicates if ONLY some current page items are selected */
4648
pagePartiallySelected?: boolean;
4749
/** Callback called on item select */
48-
onSelect: (value: BulkSelectValue) => void;
50+
onSelect: (value: BulkSelectValue, source?: BulkSelectSource) => void;
4951
/** Custom OUIA ID */
5052
ouiaId?: string;
5153
/** Additional props for MenuToggleCheckbox */
@@ -119,7 +121,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
119121
ouiaId={`${ouiaId}-dropdown`}
120122
onSelect={(_e, value) => {
121123
setOpen(!isOpen);
122-
onSelect?.(value as BulkSelectValue);
124+
onSelect?.(value as BulkSelectValue, 'dropdown');
123125
}}
124126
isOpen={isOpen}
125127
onOpenChange={(isOpen: boolean) => setOpen(isOpen)}
@@ -142,7 +144,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
142144
? null
143145
: pageSelected || (selectedCount === totalCount && totalCount > 0)
144146
}
145-
onChange={(checked) => onSelect?.(!checked || checked === null ? noneOption : allOption)}
147+
onChange={(checked) => onSelect?.(!checked || checked === null ? noneOption : allOption, 'checkbox')}
146148
{...menuToggleCheckboxProps}
147149
>
148150
{selectedCount > 0 ? (

0 commit comments

Comments
 (0)