import { useTranslation } from 'react-i18next'; import { Button } from 'antd'; interface SelectAllClearButtonsProps { options: Array<{ value: T }>; value: T[]; onChange: (value: T[]) => void; /** Override the default "Select all" label (defaults to the inbound copy). */ selectAllLabel?: string; /** Override the default "Clear all" label (defaults to the inbound copy). */ clearLabel?: string; } export default function SelectAllClearButtons({ options, value, onChange, selectAllLabel, clearLabel, }: SelectAllClearButtonsProps) { const { t } = useTranslation(); const optionValues = options.map((o) => o.value); // Treat as "all selected" when every option is chosen, rather than comparing // lengths — this stays correct even if `value` holds ids outside `options`. const allSelected = options.length > 0 && optionValues.every((v) => value.includes(v)); return (
); }