/* Selection Summary Component */ import { Box, Button, Typography } from '@mui/material' import type { WidgetSelectionSummaryProps, SelectionSummaryLabels, } from './types' import { styles } from './style' const DEFAULT_SELECTION_LABELS: SelectionSummaryLabels = { allSelected: 'All selected', selections: (count: number) => `${count} selected`, clear: 'Clear', } /** * Displays the count of selected items with an optional clear button. Commonly used with the LockSelection action to show selection state in widgets. * * @example * ```tsx * setSelectedItems([])} * /> * ``` */ export function WidgetSelectionSummary({ selections, onClear, labels, }: WidgetSelectionSummaryProps) { const allSelectedLabel = labels?.allSelected ?? DEFAULT_SELECTION_LABELS.allSelected const selectionsLabel = labels?.selections ?? DEFAULT_SELECTION_LABELS.selections const clearLabel = labels?.clear ?? DEFAULT_SELECTION_LABELS.clear const displayLabel = selections > 0 ? selectionsLabel(selections) : allSelectedLabel const showClearButton = selections > 0 && onClear return ( {displayLabel} {showClearButton && ( )} ) }